Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ender lily farm using TE autonomous activators, rednet cabling, vacuum hoppers, and itemducts
- local side = "bottom" --side the monitor is on
- local tcolor = colors.white --text color
- local bgcolor = colors.red -- background color
- local m =peripheral.wrap(side) -- wraps the peripheral for use
- local heading = "Time Remaining" --header text
- m.clear() -- clears the monitor
- m.setCursorPos(1,1) --sets the cursor to the top left
- m.setTextScale(1) --sets the text scale on the monitor
- m.setTextColor(tcolor) -- sets text color
- m.setBackgroundColor(bgcolor) --sets background color
- function center(text) --pretty self explanatory here.
- x,y = m.getSize()
- x1,y1 = m.getCursorPos()
- m.setCursorPos((math.floor(x/2) - (math.floor(#text/2))), y1)
- m.write(text)
- end
- local function cycle()
- rs.setBundledOutput("back", colors.white) --redstone on
- sleep(1)
- rs.setBundledOutput("back", 0) --redstone off
- end
- function time() --the countdown timer
- local su = fs.open("time", "r") -- opens the backup file in read only
- local i = tonumber(su.readAll()) -- reads the time remaining
- repeat
- m.setCursorPos(1,3)
- center(heading) --centers the heading
- m.setCursorPos(1,5)
- i=i-1
- center(tostring(i)) --centers the count down timer
- sleep(1)
- su.close() -- closes the read only file
- local f=fs.open("time", "w") -- opens the backup file in writable mode
- f.write(tonumber(i)) -- updates the file
- f.close() -- closes and saves the updates to the file
- until i<1 --ending condition for the repeat loop
- m.clear() --clears the monitor
- center("Harvesting and Planting") --display output when the timer finishes
- cycle() -- fires the redstone pulse
- m.clear() --clears the monitor again when done
- local Res = fs.open("time", "w") --opens the backup in writable mode again
- Res.write(tonumber(8500)) --resets the time for ~1 minecraft week
- Res.close() --saves the update and closes the file
- end
- while true do
- --center(textutils.formatTime(os.time(), false)) displays the current minecraft time @start. won't update yet.
- local h = fs.open("time", fs.exists("time") and "a" or "w") --checks if the file exits
- local defTime = "8500" --rough time in a minecraft week in seconds
- if not h then
- print("File not found. Creating new file.")
- h.write(tonumber(defTime)) --creates the file with you starting run time
- h.close()
- else
- print("Reading file...")
- local r=fs.open("time", "r")
- local res=r.readAll()
- sleep(1)
- time()
- print("Resetting")
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement