Posted 12 June 2015 - 08:29 PM
Hey guys!
Im creating a rednet sniffer program that will log all received rednet messages.
here is a part of the code:
Now you see that, it perfectly updates the time every second.
But it doesnt show any rednet messages.
Its a bit messy, but I hope you could see my problem.
Thanks and have a nice day :)/>
Im creating a rednet sniffer program that will log all received rednet messages.
here is a part of the code:
while controlLoop == true do
local senderId, message, protocol = rednet.receive(1)
local time = os.time()
local day = os.day()
local eventtime = textutils.formatTime(time, true)
if message ~= "" then
local snifftime = eventtime
term.setCursorPos(1,5)
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.black)
term.clearLine()
term.write("Most recent sniffed data:")
term.setBackgroundColor(colors.gray)
term.setTextColor(colors.black)
term.setCursorPos(1,6)
term.clearLine()
term.setCursorPos(1,7)
term.clearLine()
term.write("Time: "..tostring(snifftime))
term.setCursorPos(1,8)
term.clearLine()
term.write("Sender ID: "..tostring(senderId))
term.setCursorPos(1,9)
term.clearLine()
term.write("Protocol: "..tostring(protocol))
term.setCursorPos(1,10)
term.clearLine()
term.write("Payload: "..tostring(message))
end
-- render
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1,h)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.clearLine()
term.write("Time: "..eventtime.." - Day: "..day)
end
Now you see that, it perfectly updates the time every second.
But it doesnt show any rednet messages.
Its a bit messy, but I hope you could see my problem.
Thanks and have a nice day :)/>