Posted 28 July 2012 - 05:38 PM
Hi, everyone! I was hoping if someone could give me a hand with this code, Im trying to send commands remotely via a "Master" computer to specific computers in my factory, however I've hit a snag and cant seem to fix it, I believe the error is somewhere withing my os.pullEvent(), without loadstring I can get it to say Completed, but as soon as i add it, the code gives me:
eListen:7: [string "string"]:1: unexpected symbol
and I've based all of this off of http://www.computerc...ands-over-wifi/
Also, is it even possible to send a computer a command and have it run a program? or can you just send text.
Here is the program for what i've dubbed the Master computer
http://pastebin.com/p93TGXAZ
http://pastebin.com/x5n1u5pm
I dont really hate lua, that was out of debugging frustration lol.
eListen:7: [string "string"]:1: unexpected symbol
and I've based all of this off of http://www.computerc...ands-over-wifi/
Also, is it even possible to send a computer a command and have it run a program? or can you just send text.
Here is the program for what i've dubbed the Master computer
http://pastebin.com/p93TGXAZ
term.setCursorPos(1,1)
-- Check if Modem is On
if rednet.open("right") == true then
print("kNet is open already!")
else
rednet.open("right")
print("kNet is Online!")
end
term.clear()
while true do
term.setCursorPos(1,1)
print("What Computer are Communicating with?\n")
print("88: Engine Controller\n90: Factory Controller\n105:Unknown")
local id = tonumber(io.read()) -- Get ID from LIST
os.sleep(.8)
term.clear()
term.setCursorPos(1,1)
print("You've Chosen Computer ", id, " Give it a Command!")
local command = tostring(io.read())
print("Sending Command!")
rednet.send(id, command)
local event, param1 = os.pullEvent("rednet_message")
if param1 == true then
print("Success!")
end
end
http://pastebin.com/x5n1u5pm
I dont really hate lua, that was out of debugging frustration lol.
rednet.open("back")
print("Computer is Listening")
command = os.pullEvent
while true do
local id, msg, dt = os.pullEvent("rednet_message")
if id == "rednet_message" then
assert (loadstring(msg))
print("Completed!")
else
print("I fucking hate lua")
end
end