SenpaiJody

tanksmelter frontend

Mar 28th, 2023 (edited)
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.80 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. tanksmelter = require("tanksmelter")
  4. button = require("buttonAPI")
  5. local event = require("event")
  6. local computer = require("computer")
  7. local term = require("term")
  8. local gpu = component.gpu
  9.  
  10. local rs = component.redstone
  11. local colors = require("colors")
  12. local side = require("sides")
  13.  
  14.  
  15.  
  16. local currentTankFluid = "Empty"
  17. local currentSmelterFluid = "Empty"
  18.  
  19. function button.fillTable()
  20.   button.setTable("Transfer 1 Block >>", SmelterToTank1, 10,40,6,11)  
  21.   button.setTable("Transfer All >>", SmelterToTank2, 10,40,13,18)
  22.   button.setTable("<< Transfer 1 Block", TankToSmelter1, 45,75,6,11)
  23.   button.setTable("<< Transfer All", TankToSmelter2, 45,75,13,18)
  24.   button.setTable("Crash", test2, 40,48,15,20)
  25.   button.screen()
  26. end
  27.  
  28. function getClick()
  29.   local _, _, x, y = event.pull(1,touch)
  30.   if x == nil or y == nil then
  31.     local h, w = gpu.getResolution()
  32.     gpu.set(h, w, ".")
  33.     gpu.set(h, w, " ")
  34.   else
  35.     button.checkxy(x,y)
  36.   end
  37. end
  38.  
  39. function SmelterToTank1()
  40.     button.flash("Transfer 1 Block >>", 0.5)
  41.     tanksmelter.transferToTank()
  42.     end
  43. function SmelterToTank2()
  44.     button.flash("Transfer All >>", 0.5)
  45.     tanksmelter.transferToTank(9999999999999)
  46.     end
  47. function TankToSmelter1()
  48.     button.flash("<< Transfer 1 Block", 0.5)
  49.     tanksmelter.transferToSmelter()
  50.     end
  51. function TankToSmelter2()
  52.     button.flash("<< Transfer All", 0.5)
  53.     tanksmelter.transferToSmelter(9999999999999999)
  54.     end
  55.  
  56.  
  57. function test2()
  58.   crash()
  59. end
  60.  
  61. button.fillTable()
  62. term.setCursorBlink(false)
  63. gpu.setResolution(80, 25)
  64.  
  65.  
  66. function draw()    
  67.     button.clear()
  68.     button.heading("Tinker Smeltery - Tank Controller")
  69.     button.label(22,4,"Smelter")
  70.     button.label(56,4, "Tank")
  71.     button.label(22, 20, currentSmelterFluid)
  72.     button.label(56, 20, currentTankFluid)
  73.     button.screen()
  74. end
  75. draw()
  76.  
  77. function updateTankInfo()
  78.     local _fluidInTank = tanksmelter.getCurrentFluidInTank()
  79.     if _fluidInTank == nil then
  80.         _fluidInTank = "Empty"
  81.         else
  82.         _fluidInTank = _fluidInTank[1].label
  83.         end
  84.    
  85.    
  86.     local _fluidInSmelter = tanksmelter.getCurrentFluidInSmelter()
  87.     if _fluidInSmelter == nil then
  88.         _fluidInSmelter = "Empty"
  89.         else
  90.         _fluidInSmelter = _fluidInSmelter[1].label
  91.         end
  92.    
  93.     if _fluidInSmelter == nil then
  94.         _fluidInSmelter = "Empty"
  95.         end
  96.     if _fluidInTank == nil then
  97.         _fluidInTank = "Empty"
  98.         end
  99.    
  100.     if _fluidInTank ~= currentTankFluid or _fluidInSmelter ~= currrentSmelterFluid then
  101.         currentTankFluid = _fluidInTank
  102.         currentSmelterFluid = _fluidInSmelter
  103.         draw()
  104.         end
  105.     end
  106.    
  107.  
  108. while true do
  109.   getClick()
  110.   updateTankInfo()
  111. end
  112.  
Advertisement
Add Comment
Please, Sign In to add comment