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

ImageIO Peripheral Setup Help

Started by coranos, 03 October 2012 - 01:38 AM
coranos #1
Posted 03 October 2012 - 03:38 AM
Hi,
I'm creating a new peripheral that reads an image from a URL and returns it as a list of rgb values, but I can't seem to get the peripheral method call working.

this returns "test"
public Object[] callMethod(IComputerAccess computer, int method,
Object[] arguments) throws Exception {

return new Object[] { "test" };
}
but this doesn't return an array, it only returns "4":
public Object[] callMethod(IComputerAccess computer, int method,
Object[] arguments) throws Exception {

return new Object[] { 4,3,2 };
}
Am I doing something wrong?
I also tried returning a LuaTable, but that returned 'nil' to the turtle.
immibis #2
Posted 03 October 2012 - 04:41 AM
It returned 4 and 3 and 2. I'm guessing you only assigned it to one variable so the rest were discarded. Try this:

a, b, c = peripheral.call("side", "methodName")
or this:

myTable = {peripheral.call("side", "methodName")}
coranos #3
Posted 03 October 2012 - 05:14 AM
I did print(tostring(peripheral.call("side", "methodName")), will try the table approach :(/>/>

here's what I'm making btw (create statues from skin files).
https://www.youtube.com/watch?v=53RkV8hc3yQ

The script currently works but needs 2 stages, since I can't call luajava from within computercraft anymore (thus the periperal) I need to create the turtles script outside of minecraft, then run the script inside of minecraft.
Xfel #4
Posted 03 October 2012 - 08:29 AM
try print without tostring.