Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m1 = peripheral.wrap("railcraft:tank_iron_valve_2")
- m2 = peripheral.wrap("railcraft:tank_iron_valve_1")
- m3 = peripheral.wrap("railcraft:tank_iron_valve_0")
- os.startTimer(1)
- creosote_oil = false
- tree_oil = false
- function set(value1, value2)
- creosote_oil = value1
- tree_oil = value2
- rs.setOutput("left", creosote_oil)
- rs.setOutput("right", tree_oil)
- end
- function getValue(device)
- tanksTable = device.getTanks()
- maintank = tanksTable[1]
- return math.floor(100 * (maintank.amount or 0) / maintank.capacity)
- end
- function sendUpdate(v1, v2, v3, currentState)
- url = "http://gorgony.nl:25586/update?vals="
- url = url .. v1 .. ";"
- url = url .. v2 .. ";"
- url = url .. v3
- url = url .. "&state=" .. currentState
- http.get(url)
- end
- while true do
- e, r1, r2, r3, r4 = os.pullEvent()
- if e == "timer" then
- v1 = getValue(m1)
- v2 = getValue(m2)
- v3 = getValue(m3)
- if not creosote_oil and v1 > 95 then
- set(true, false)
- elseif creosote_oil and v1 < 5 then
- set(false, v2 > 30)
- end
- if not (creosote_oil or tree_oil) and v2 > 60 then
- set(false, true)
- elseif tree_oil and v2 < 20 then
- set(false, false)
- end
- sendUpdate(v1, v2, v3, ((creosote_oil or tree_oil) and "on") or "off")
- os.startTimer(60)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement