Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require("event")
- local fs = require('filesystem')
- local component = require("component")
- local m = component.modem
- local sides = require("sides")
- local colors = require("colors")
- local ae = require("ae")
- local timerID = -1
- local rsSignal = {0, 25, 52, 77, 98}
- local config = {}
- function start(msg)
- if (timerID ~= -1) then
- print("Already running")
- return
- end
- timerID = event.timer(30, tick, math.huge)
- c = loadConfig()
- config = c or {}
- end
- function stop(msg)
- if (timerID == -1) then
- print("Not running")
- return
- end
- event.cancel(timerID)
- timerID = -1
- end
- function getSapling()
- item = ae.getItem("Forestry:sapling", 0) or {}
- return item.size or 0
- end
- function updateFarm()
- wood = getSapling()
- if(wood >= 40000) then
- m.broadcast(500, 4)
- return
- end
- if(wood >= 30000) then
- m.broadcast(500, 3)
- return
- end
- if(wood >= 20000) then
- m.broadcast(500, 2)
- return
- end
- if(wood >= 10000) then
- m.broadcast(500, 1)
- return
- end
- m.broadcast(500, 0)
- end
- function tick()
- updateFarm()
- end
- function loadConfig()
- local env = {}
- local result, reason = loadfile('/etc/farm.cfg', 't', env)
- if result then
- result, reason = xpcall(result, debug.traceback)
- if result then
- return env
- end
- end
- return nil, reason
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement