Posted 21 November 2012 - 01:24 PM
I'm currently trying to have the computer that is controlling my elevator to send the current position to a group of computers that will display its general position on each floor. If i remove the line pointed out in the code below it works fine. Any subjection would be welcome. thanks
term.clear()
term.setCursorPos(1,1)
print("server is running")
local up = "left"
local down = "right"
local senders = { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 24}
local monitors = { 16, 17, 18, 19, 20, 21}
local elvPos = 0
local posChange = 0
while true do
rednet.open("back")
senders, posChange, distance = rednet.receive()
posChange=tonumber(posChange)
rednet.close("back")
while posChange ~= elvPos do
rednet.send( monitors, tostring(elvPos), true) <- the error is with this line
term.clear()
term.setCursorPos(1,1)
print("server is running")
if posChange < elvPos then
term.clear()
term.setCursorPos(1,1)
print("server is moving")
rs.setOutput(up, true)
sleep(0.5)
rs.setOutput(up, false)
sleep(0.5)
elvPos = elvPos - 1
elseif posChange > elvPos then
term.clear()
term.setCursorPos(1,1)
print("server is moving")
rs.setOutput(down, true)
sleep(0.5)
rs.setOutput(down, false)
sleep(0.5)
elvPos = elvPos + 1
else
sleep(3)
end
end
end