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

Accept and Return Tables

Started by wjykk, 14 December 2012 - 08:11 PM
wjykk #1
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)
Cloudy #2
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.
Xfel #3
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?
SNCPlay42 #4
Posted 16 December 2012 - 08:37 AM
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.
Cloudy #5
Posted 16 December 2012 - 04:37 PM
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.
Espen #6
Posted 30 December 2012 - 03:58 PM
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! ^_^/>