Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local FILE_PATH = "storage.dat"
- local SLEEP_WAIT = 60
- local GROWTH_TIME = 8200 * 1000
- function getLast()
- if not fs.exists(FILE_PATH) then
- return 0
- end
- local file = fs.open(FILE_PATH, "r")
- local contents = file.readAll()
- file.close()
- return tonumber(contents)
- end
- function setLast(value)
- local file = fs.open(FILE_PATH, "w")
- file.write("" .. value)
- file.close()
- end
- function iterate()
- print("[cr] waiting for growth ...")
- while (os.epoch("utc") - getLast()) < GROWTH_TIME do
- sleep(SLEEP_WAIT)
- end
- print("[cr] growth assumed to be finished!")
- setLast(os.epoch("utc"))
- redstone.setOutput("back", true)
- sleep(2)
- redstone.setOutput("back", false)
- end
- function main()
- print("\n\n-------------------------------")
- print("[cr] starting the program; v1.0")
- print("-------------------------------\n\n");
- while true do
- iterate()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement