Advertisement
JaMaNi133

Redstone Functions

Nov 2nd, 2023 (edited)
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. function updatePort(port,state)
  2.     local col = port.color
  3.     print(col)
  4.     if state == true and port.invert == false then
  5.         rednet.send(port.computer,65536+col)
  6.     elseif state == false and port.invert == false then
  7.         rednet.send(port.computer,col)
  8.     elseif state == true and port.invert == true then
  9.         rednet.send(port.computer,col)
  10.     elseif state == false and port.invert == true then
  11.         rednet.send(port.computer,65536+col)
  12.     end
  13. end
  14.  
  15. function updateBusses(device = nil)
  16.     if device == nil then
  17.         updateBus(device.BusA)
  18.         updateBus(device.BusB) 
  19.         updateBus(device.BusC)
  20.     end
  21. end
  22.  
  23. function updateBus(bus)
  24.     local states = {{"NA",          p1=nil,     p2=nil  },
  25.                     {"ValveClosed", p1=false,   p2=nil  },
  26.                     {"ValveOpen",   p1=true,    p2=nil  },
  27.                     {"PumpOff",     p1=true,    p2=nil  },
  28.                     {"MonoPumpIn",  p1=false,   p2=nil  },
  29.                     {"MonoPumpOut", p1=false,   p2=nil  },
  30.                     {"PumpIn",      p1=false,   p2=false},
  31.                     {"PumpOut",     p1=false,   p2=true }}
  32.     updatePort(bus.Port1,states[bus.state].p1)
  33.     updatePort(bus.Port2,states[bus.state].p2)
  34. end
  35.  
  36.  
  37.  
  38. function updateRedstone()
  39.     updateBusses(SmelteryA)
  40.     updateBusses(SmelteryB)
  41.     updateBusses(TankA)
  42.     updateBusses(TankB)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement