9 posts
Posted 03 March 2012 - 11:10 PM
Is there a way to tell another computer to do something through rednet? say you have a piston doorway and an exterior and interior terminal designed to open it. Obviously the redstone current holding the door closed has to be shut off in order for the door to open, no problem for the exterior terminal, I wrote this for it but I need to make a program for the interior terminal so that when i run it it tells the other computer to stop the current… any possible ways to do so? Tell me if you need the exterior terminal's code and I'll edit it into the post…
473 posts
Location
Poland
Posted 03 March 2012 - 11:14 PM
well, like:
local id=1
while true do
local _, id2, msg=os.pullEvent("rednet_message")
if id2==id then
local tmp=loadstring(msg)
tmp()
end
end
return true
set id to the sender's id. then on the sender terminal type like rednet.send(2, "print(1)")
9 posts
Posted 03 March 2012 - 11:37 PM
well, like:
local id=1
while true do
local _, id2, msg=os.pullEvent("rednet_message")
if id2==id then
local tmp=loadstring(msg)
tmp()
end
end
return true
set id to the sender's id. then on the sender terminal type like rednet.send(2, "print(1)")
would i place that program on the sender terminal? or the receiving terminal? Cause I need the sending terminal to basically send a message that tells the other terminal to run these lines:
redstone.setOutput("bottom", false)
sleep(7)
redstone.setOutput("bottom", true)
411 posts
Posted 03 March 2012 - 11:48 PM
Sender:
data =
[[==
rs.setOutput("bottom", false)
sleep(7)
rs.setOutput("bottom", true)
==]]
rednet.open(side)
rednet.send(receiverid, data)
Receiver:
rednet.open(side)
id, msg = rednet.receive()
if id == senderid then
tmp = loadstring(msg)
tmp()
end
9 posts
Posted 03 March 2012 - 11:53 PM
Sender:
data =
[[==
rs.setOutput("bottom", false)
sleep(7)
rs.setOutput("bottom", true)
==]]
rednet.open(side)
rednet.send(receiverid, data)
Receiver:
rednet.open(side)
id, msg = rednet.receive()
if id == senderid then
tmp = loadstring(msg)
tmp()
end
Thanks :unsure:/>/> Two more things, how would I integrate the receiver code into this:
redstone.setOutput("bottom", true)
term.clear()
term.setCursorPos(1,1)
print("Exterior Door Terminal")
write ("Enter Access Code:")
passcode = read()
if passcode == "passcode" then
term.clear()
term.setCursorPos(1,1)
print ("Access Granted")
sleep(2)
redstone.setOutput("bottom", false)
sleep(5)
redstone.setOutput("bottom", true)
shell.run("startup")
else
term.clear()
term.setCursorPos(1,1)
print ("Access Denied")
sleep(2)
shell.run("startup")
end
That's my code for the exterior terminal opening the door from the outside.
Second, how would i set up the sending terminal program to send if the password in this code is entered:
term.clear()
term.setCursorPos(1,1)
print("Exterior Door Terminal")
write ("Enter Access Code:")
passcode = read()
if passcode == "passcode" then