Posted 14 November 2013 - 02:43 AM
Hello guys.
I am experiencing huge brain problems as i cant sort out how to program a combined sender/listener.
I'm trying to make an automatic sorting/retrieval system with computercraft
The purpose for my program is to use a main wireless computer where you e.g. could type "redstone" and then the computer will request a message from the computer controlling the redstone chest in the sorting system for a variable which will determine how many stacks of a given item the user wants.
The problem is, the main computer must be able to send and retrieve at all times.
What i mean is the program must not exit its while loop and neither does the listening computer (that controls a chest with redstone for example)
The key problems i'm experiencing is that i cant retrieve messages and send an input to the listening computer, whilst the listening computer also should be able to send back a message without breaking its listening loop.
I don't know if i have expressed my self clear enough as i find it quite hard to explain the concept of what the computers should be able to do.
I am experiencing huge brain problems as i cant sort out how to program a combined sender/listener.
I'm trying to make an automatic sorting/retrieval system with computercraft
The purpose for my program is to use a main wireless computer where you e.g. could type "redstone" and then the computer will request a message from the computer controlling the redstone chest in the sorting system for a variable which will determine how many stacks of a given item the user wants.
The problem is, the main computer must be able to send and retrieve at all times.
What i mean is the program must not exit its while loop and neither does the listening computer (that controls a chest with redstone for example)
The key problems i'm experiencing is that i cant retrieve messages and send an input to the listening computer, whilst the listening computer also should be able to send back a message without breaking its listening loop.
--Listener
rednet.open("back")
while true do
event, senderId,message,distance = os.pullEvent("rednet_message")
if message == "redstone" then
local a = read()
rs.setOutput("left", true)
sleep(a*3.35)
rs.setOutput("left", false)
print(a," redstone stacks sent")
end
end
--Sender
rednet.open("back")
while true do
local sendmsg=read()
rednet.broadcast(sendmsg)
end
I don't know if i have expressed my self clear enough as i find it quite hard to explain the concept of what the computers should be able to do.