Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- For 1.12.2 versions of Thermal Expansion and EnderIO
- -- Monitors TE5 Energy cells and EnderIO capacitor banks and output redstone signals once energy storage drops below set limits.
- -- Will automatically detect direction of adjacent storage device and (optional) Advanced Monitors. If chosen, monitor format should be 1 high and 2 wide. Now also with wired modem support for both storage and monitors. Directly adjacent devices will take priority over any wired devices.
- -- Redstone signal for the engines will be output out the back of the computer.
- --More details: http://forum.feed-the-beast.com/threads/rhns-1-6-monster-build-journal-and-guide-collection.42664/page-15#post-718973
- local upper = 14 --Upper limit for computer to stop transmitting redstone signal.
- local lower = 7 --Lower limit for computer to start transmitting redstone signal.
- local outSide = "back"
- --Device detection
- isError=0
- function detectDevice(DeviceName)
- DeviceSide="none"
- for k,v in pairs(redstone.getSides()) do
- if peripheral.getType(v) and string.find(peripheral.getType(v), DeviceName) then
- --if peripheral.getType(v)==DeviceName then
- --if string.find(peripheral.getType(v), DeviceName) then
- DeviceSide = v
- break
- --end
- end
- end
- return(DeviceSide)
- end
- cell="none"
- monitor="none"
- local peripheralList = peripheral.getNames()
- CellSide="right"
- MonitorSide=detectDevice("monitor")
- if MonitorSide~="none" then
- monitor=peripheral.wrap(MonitorSide)
- print ("Monitor on the " .. MonitorSide .. " connected.")
- else
- for Index = 1, #peripheralList do
- if string.find(peripheralList[Index], "monitor") then
- monitor=peripheral.wrap(peripheralList[Index])
- print ("Monitor on wired modem: "..peripheralList[Index].." connected.")
- end
- end --for
- if monitor == "none" then
- print ("Warning - No Monitor attached, continuing without.")
- end
- end
- --Main code
- redstone.setOutput(outSide, false) --Defaulting to off
- --If monitor is attached, write data on monitor
- if monitor ~= "none" then
- monitor.clear()
- monitor.setBackgroundColour((colours.grey))
- monitor.setCursorPos(1,3)
- monitor.write(" ON ")
- monitor.setBackgroundColour((colours.black))
- end
- --Main loop
- while true do
- --Compute ratio
- fill = redstone.getAnalogInput(CellSide)
- if fill >= upper then
- --energylevel is over upper level, turning redstone signal on
- redstone.setOutput(outSide, true)
- if monitor ~= "none" then
- monitor.setBackgroundColour((colours.grey))
- monitor.setCursorPos(1,3)
- monitor.write(" OFF ")
- monitor.setBackgroundColour((colours.black))
- end
- elseif fill <= lower then
- --energy level is below lower limit, turning redstone signal off
- redstone.setOutput(outSide, false)
- if monitor ~= "none" then
- monitor.setBackgroundColour((colours.grey))
- monitor.setCursorPos(1,3)
- monitor.write(" ON ")
- monitor.setBackgroundColour((colours.black))
- end
- end
- sleep(1)
- end --while
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement