function writeLine()
local file = fs.open("file", "w")
if file then
file.writeLine(cmd)
file.close()
end
end
function runLine()
shell.run("file")
end
rednet.open("top")
rednet.open("bottom")
rednet.open("back")
rednet.open("front")
rednet.open("right")
rednet.open("left")
while true do
user, cmd = rednet.receive()
writeLine()
runLine()
end
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Lua]
Started by Spongy141, 16 December 2012 - 11:26 AMPosted 16 December 2012 - 12:26 PM
I was trying to make a program for my wireless turtle so it can turn a message I sent to it to a line, such as if I send it turtle.up() it would go up, ect. but No matter what the function wouldn't work right to do that.
Posted 16 December 2012 - 12:33 PM
loadstring(cmd)()
ofcourse you cant send "turtle.forward()" but you'll have to send just "turtle.forward" without parentheses
ofcourse you cant send "turtle.forward()" but you'll have to send just "turtle.forward" without parentheses
Posted 16 December 2012 - 12:36 PM
thanks, lol were do I put that. Im guessing in the "while true do" but Im not always right, lol.loadstring(cmd)()
ofcourse you cant send "turtle.forward()" but you'll have to send just "turtle.forward" without parentheses
Posted 16 December 2012 - 12:37 PM
When you receive a message put it.thanks, lol were do I put that. Im guessing in the "while true do" but Im not always right, lol.loadstring(cmd)()
ofcourse you cant send "turtle.forward()" but you'll have to send just "turtle.forward" without parentheses
Posted 16 December 2012 - 12:38 PM
Thanks human,When you receive a message put it.thanks, lol were do I put that. Im guessing in the "while true do" but Im not always right, lol.loadstring(cmd)()
ofcourse you cant send "turtle.forward()" but you'll have to send just "turtle.forward" without parentheses
Posted 16 December 2012 - 03:13 PM
Post your revised code.
Posted 18 December 2012 - 06:11 AM
I fixed it myself, and a little help from a friend, and when I did:Post your revised code.
loadstring(cmd)()
os.pullEvent = loadstring(cmd)()
it looped the one command I gave the turtle, and if something was in its path it crashed. But as you can see I edited it to work right, no offense but you guys weren't very good help.Posted 18 December 2012 - 08:43 AM
nice to see you got it finised, i was going to add my little fix in there :P/>
Posted 18 December 2012 - 12:48 PM
I fixed it myself, and a little help from a friend, and when I did:Post your revised code.it looped the one command I gave the turtle, and if something was in its path it crashed. But as you can see I edited it to work right, no offense but you guys weren't very good help.loadstring(cmd)() os.pullEvent = loadstring(cmd)()
Yeah, really easy to help when you cant post your code… if you edit something, you got to give us the new code. You weren't very co-operative either.
Posted 18 December 2012 - 08:35 PM
It's fixed, so that's good enough.