GreatShooter, on 11 January 2014 - 02:13 PM, said:
And my computer's code:
local names = {
[20] = "Water bottler",
}
local monitor = peripheral.wrap("back")
os.startTimer(600)
while true do
rednet.open("right")
event, id, text = os.pullEvent()
if event == "rednet_message" then
local name
if names[id] then name = names[id] else name = id end
term.redirect(monitor)
print(name.." says:"..text)
term.restore()
print(os.pullEvent())
local executetime = os.time()
local executetime = executetime + 12
while executetime == os.time() do
term.redirect(monitor)
term.clear()
term.restore()
end
end
end
Do you think they are ok/ need tweaking?
The server code here will not work correctly. There is only a fraction of a tick where executetime and os.time() will match, the timer updates faster than the tick on the program so it could actually pass the matching time before it activates, hence I used >= in my check system.
Also due to the fact that our turtle is only sending a message once 10 minutes passes, you should have the server running on the os.pullEvent() as a wait and not the os.time() way. as waiting on os.time() will only trigger on one event.
local names = {
[20] = "Water bottler",
}
local monitor = peripheral.wrap("back")
os.startTimer(600)
while true do
rednet.open("right")
event, id, text = os.pullEvent()
if event == "rednet_message" then
local name
if names[id] then name = names[id] else name = id end
term.redirect(monitor)
print(name.." says:"..text)
term.restore()
print(event) --// print(os.pullEvent()) will make the system pause for a event to print, not print the captured event.
--// Removed the section that paused script for 10 minutes, this would have errored as well, because there was no yielding events.
end
end