Skip to content

Instantly share code, notes, and snippets.

@sshilovsky
Last active June 15, 2018 20:34
Show Gist options
  • Save sshilovsky/176f5fc9e187623c018060c3ccc4fe32 to your computer and use it in GitHub Desktop.
Save sshilovsky/176f5fc9e187623c018060c3ccc4fe32 to your computer and use it in GitHub Desktop.
function sleep_until(alarm)
while alarm>computer.uptime() do
local timeout=alarm-computer.uptime()
computer.pullSignal(timeout)
end
end
while 1 do
sleep_until(math.min(next_breed,next_farm))
if next_breed<next_farm then
breed()
next_breed=computer.uptime()+BREED_INTERVAL
else
farm()
next_farm=computer.uptime()+FARM_INTERVAL
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment