Jump to content




How to return a table in your own Peripheral?

api peripheral help

4 replies to this topic

#1 Keridos

  • Members
  • 75 posts

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.

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 09 February 2016 - 02:12 PM

Can you post your code? Returning a map should work correctly.

#3 Keridos

  • Members
  • 75 posts

Posted 09 February 2016 - 04:25 PM

https://gist.github....-java-L942-L950

That gives something like
{
    Keridos = 7
}
instead of a table

Edited by Keridos, 09 February 2016 - 04:26 PM.


#4 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

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.

#5 Keridos

  • Members
  • 75 posts

Posted 09 February 2016 - 05:37 PM

ah thats new then. thanks.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users