Jump to content




Accept and Return Tables

lua

  • You cannot reply to this topic
5 replies to this topic

#1 wjykk

  • Members
  • 10 posts

Posted 14 December 2012 - 09:11 PM

Is there any way I can accept a table (or its equivalent) as an argument of IPeripheral.callMethod(), or return something as a table? Or is there any other way to do it? E.g.
myTable = {1,2,3}
otherTable = peripheral.myFunction(myTable)


#2 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 14 December 2012 - 10:55 PM

No, you cannot accept tables. You can however return a table - just return a map in the object array.

#3 Xfel

    Peripheral Designer

  • Members
  • 515 posts

Posted 15 December 2012 - 03:52 AM

will that ever be changed? you could convert a table to a java map the same way you do it the other way round, couldn't you?

#4 SNCPlay42

  • New Members
  • 6 posts

Posted 16 December 2012 - 08:37 AM

View PostCloudy, on 14 December 2012 - 10:55 PM, said:

No, you cannot accept tables. You can however return a table - just return a map in the object array.

Just FYI, this isn't mentioned anywhere in the doc.

#5 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 16 December 2012 - 04:37 PM

View PostSNCPlay42, on 16 December 2012 - 08:37 AM, said:

View PostCloudy, on 14 December 2012 - 10:55 PM, said:

No, you cannot accept tables. You can however return a table - just return a map in the object array.

Just FYI, this isn't mentioned anywhere in the doc.

That's because we haven't updated the doc since this was added.

#6 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 30 December 2012 - 03:58 PM

View PostCloudy, on 14 December 2012 - 10:55 PM, said:

No, you cannot accept tables. You can however return a table - just return a map in the object array.
OMG, I can't believe it. I was just looking at some peripheral code and was stumped why a map was returned where I so painstakingly put together a string-representation of a table...
So I immediately searched for it, landed here and... what do you know, simply returning a map actually works.

Well that makes life much easier. Just goes to show how studying others' code can yield more information than studying the actual documentation, hehe. :P
Anyway, a big thanks for implementing that! ^_^





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users