Posted 17 January 2016 - 02:36 PM
I am coding a program that will sent big reactor information via rednet to another computer that will display it on a screen. however for some reason i get the attempt to call nil error when calling the function sentWater() and SentSteam() but sentTemp() and sendFuel() work and the code is near identical the only difference is the string that is being send via rednet. can anyone help me out please?
code: http://pastebin.com/sUHy9qVW
error: reactorTransmiter:52: attempt to call nill
code: http://pastebin.com/sUHy9qVW
local reactor = peripheral.wrap("top")
local controlID = 7
local active = false
function listen()
rednet.open("left")
while true do
id, msg = rednet.receive()
if msg == "Reactor true" then
active = true
print(msg)
elseif msg == "Reactor false" then
active = false
print(msg)
end
end
end
function main_loop()
while true do
os.queueEvent("randomEvent")
os.pullEvent()
sendDetails()
if active == false then
reactor.setActive(false)
else
reactor.setActive(true)
end
end
end
function sendTemp()
rednet.send(controlID, "Reactor 1 temperature = " .. reactor.getFuelTemperature())
end
function sendFuel()
rednet.send(controlID, "Reactor 1 fuel amount = " .. reactor.getFuelAmount() .. "/" .. reactor.getFuelAmountMax())
end
function sentWater()
rednet.send(controlID, "Reactor 1 water level = " .. reactor.getCoolantAmount() .. "/" .. reactor.CoolantAmountMax())
end
function sentSteam()
rednet.send(controlID, "Reactor 1 steam level = " .. reactor.getHotFluidAmount() .. "/" .. reactor.getHotFluidAmountMax())
end
function sendDetails()
sendTemp()
sendFuel()
sendWater()
sendSteam()
sleep(1)
end
parallel.waitForAll(listen, main_loop)
error: reactorTransmiter:52: attempt to call nill