Add server.lua

This commit is contained in:
Dominic Zimmer 2020-07-05 00:46:50 +02:00
parent 4d5f826e63
commit da2accfc67

25
dominic/server.lua Normal file
View File

@ -0,0 +1,25 @@
rednet.open("back")
curjob = 20
function getNextJob()
curjob = curjob + 1
return curjob
end
while true do
sender, message, proto = rednet.receive("jobs")
if not message then
sleep(0.6)
else
if message == "gibjob" then
job = getNextJob()
rednet.broadcast(tostring(job), "newjob")
print("Found request for job. Offering "..tostring(job))
else
-- numberic job is complete
completejob = tonumber(message)
print("Job "..tostring(completejob).." was completed")
rednet.broadcast("thanks", "jobcomplete")
end
end