This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Keridos's profile picture

How to return a table in your own Peripheral?

Started by Keridos, 09 February 2016 - 11:39 AM
Keridos #1
Posted 09 February 2016 - 12:39 PM
Since the answers present here in the forum seem to be outdated/diffuse and the official Wiki seems to have 0 information on that and the API does not mention it as well (at least I could not find it): How can I return a table in the callMethod(…) function for a custom Peripheral? I tried using a Hashmap but it does not give back a table, it gives more like a String with several lines.
SquidDev #2
Posted 09 February 2016 - 02:12 PM
Can you post your code? Returning a map should work correctly.
Keridos #3
Posted 09 February 2016 - 04:25 PM
https://gist.github....-java-L942-L950

That gives something like

{
    Keridos = 7
}
instead of a table
Edited on 09 February 2016 - 03:26 PM
SquidDev #4
Posted 09 February 2016 - 04:58 PM
Your code is correct.

If you are running this in the "lua" program, then if will format all tables like that to allow easier debugging. eg:

> a = { hello = "foo", world = "bar" }
> a
{
   hello = "foo",
   world = "bar"
}

You should still be able to use it as a table.
Keridos #5
Posted 09 February 2016 - 05:37 PM
ah thats new then. thanks.