Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require("SmelteryA")
- require("SmelteryB")
- require("TankA")
- require("TankB")
- require("MixerA")
- require("void")
- require("ValvesA")
- require("IngotCast")
- local layer1 = "layer1"
- print(SmelteryA)
- local updateFreq = 4
- local touch = {x=0,y=0,q=false}
- mon1 = peripheral.wrap("monitor_1")
- rednet.open("left")
- local DirLookupTOP = {NA={ key="X", Name="NONE" },
- ValveClosed={ key=string.char(140), Name="Closed" },
- ValveOpen={ key=string.char(23), Name="Open" },
- PumpOff={ key=string.char(140), Name="Off" },
- MonoPumpIn={ key=string.char(30), Name="In" },
- MonoPumpOut={ key=string.char(31), Name="Out" },
- PumpIn={ key=string.char(30), Name="In" },
- PumpOut={ key=string.char(31), Name="Out" }}
- function updatePort(port,state)
- local col = port.color
- --print(string.format("col: %d val: %s comp: %s", col, tostring(state), port.computer))
- if state == nil then
- return
- end
- onSig = 65536
- if state == port.invert then
- print("disabled")
- onSig = 0
- end
- val = col+onSig
- print(val)
- rednet.send(port.computer,val)
- end
- function updateBus(bus)
- local states = {NA={ p1=nil, p2=nil },
- ValveClosed={ p1=false, p2=nil },
- ValveOpen={ p1=true, p2=nil },
- PumpOff={ p1=true, p2=nil },
- MonoPumpIn={ p1=false, p2=nil },
- MonoPumpOut={ p1=false, p2=nil },
- PumpIn={ p1=false, p2=false},
- PumpOut={ p1=false, p2=true }}
- end
- function updateBusses(devices)
- updateBus(devices.BusA)
- updateBus(devices.BusB)
- updateBus(devices.BusC)
- end
- function updateRedstone()
- updateBusses(smelteryA)
- updateBusses(smelteryB)
- updateBusses(tankA)
- updateBusses(tankB)
- end
- function respondMonitorTouched()
- while true do
- Event, EventAdress, EventPosX, EventPosY = os.pullEvent("monitor_touch")
- touch.x = EventPosX
- touch.y = EventPosY
- touch.q = true
- loop()
- end
- end
- function updateSmelteryA(smeltery,xPos)
- stateA = smeltery.BusA.state
- stateB = smeltery.BusB.state
- stateC = smeltery.BusC.state
- if smeltery.data.select == "A" then
- mon1.setCursorPos(xPos,16)
- mon1.setBackgroundColor(colors.gray)
- mon1.setTextColor(colors.white)
- mon1.write(string.char(31,140,30))
- else
- mon1.setCursorPos(xPos+1,16)
- mon1.setBackgroundColor(colors.black)
- mon1.setTextColor(colors.white)
- mon1.write(DirLookupTOP.stateA.key)
- end
- if smeltery.data.select == "B" then
- mon1.setCursorPos(xPos+3,16)
- mon1.setBackgroundColor(colors.gray)
- mon1.setTextColor(colors.white)
- mon1.write(string.char(31,140,30))
- else
- mon1.setCursorPos(xPos+4,16)
- mon1.setBackgroundColor(colors.black)
- mon1.setTextColor(colors.white)
- mon1.write(DirLookupTOP.stateB.key)
- end
- if smeltery.data.select == "C" then
- mon1.setCursorPos(xPos+7,16)
- mon1.setBackgroundColor(colors.gray)
- mon1.setTextColor(colors.white)
- mon1.write(string.char(31,140,30))
- else
- mon1.setCursorPos(xPos+8,16)
- mon1.setBackgroundColor(colors.black)
- mon1.setTextColor(colors.white)
- mon1.write(DirLookupTOP.stateC.key)
- end
- end
- function drawPipes()
- mon1.setTextScale(1)
- mon1.setBackgroundColor(colors.black)
- mon1.setTextColor(colors.white)
- mon1.setCursorPos(1,1)
- print(mon1.getSize())
- bgF = fs.open(layer1,"r")
- for i = 1,26,1 do
- line = bgF.read(83)
- print(line)
- mon1.setCursorPos(1,i)
- mon1.write(line)
- end
- bgF.close()
- end
- function loop()
- drawPipes()
- updateSmelteryA(smelteryA,3)
- updateRedstone()
- end
- function generalUpdate()
- while true do
- loop()
- sleep(1/updateFreq)
- end
- end
- parallel.waitForAny(respondMonitorTouched,generalUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement