Posted 27 August 2014 - 03:33 AM
I'm trying to pass commands from a Pocket Computer to a set of Turtles, and I'm having issues telling it where it is in the world.
I've narrowed it down to "textutils.unserialize(message) just doesn't want to work" - here's my evidence:
When I send the update command, the control Pocket Computer sends out a packet to all of the turtles that reads thus:
However, when I'm running the setPos command, I send out a packet like this:
I go through the LUA live interpreter, and get both packets from in there. Both times, I run t = textutils.unserialize(msg), where msg is the fourth returned object from os.pullEvent("modem_message"). When msg is the first of the above packets, I can ask t.type and get back the expected "update" - I ask t, I get back the same packet (though oddly the order's a bit different - it ends up lines, program, type). The other packet, not so much - I ask for t, I get nil back. I ask for t.type, I get an error in my face.
I swear that I'm trying to pass a legit serialized object to the turtles, it's just that for some reason textutils just doesn't like it. If necessary, I can pastebin my code for perusal.
I've narrowed it down to "textutils.unserialize(message) just doesn't want to work" - here's my evidence:
When I send the update command, the control Pocket Computer sends out a packet to all of the turtles that reads thus:
{
type = "update",
program = {
--snip--
},
lines = 88,
}
…and it reads it just perfectly, replaces startup, and reboots itself, launching the new code immediately.However, when I'm running the setPos command, I send out a packet like this:
{
for = 4,
type = "setpos",
pos = {
face = 2,
z = -10,
y = 0,
x = 13,
},
}
…and for some reason it doesn't like it.I go through the LUA live interpreter, and get both packets from in there. Both times, I run t = textutils.unserialize(msg), where msg is the fourth returned object from os.pullEvent("modem_message"). When msg is the first of the above packets, I can ask t.type and get back the expected "update" - I ask t, I get back the same packet (though oddly the order's a bit different - it ends up lines, program, type). The other packet, not so much - I ask for t, I get nil back. I ask for t.type, I get an error in my face.
I swear that I'm trying to pass a legit serialized object to the turtles, it's just that for some reason textutils just doesn't like it. If necessary, I can pastebin my code for perusal.