Advertisement
Sir_Popsilots

SmelteryTankUI

Aug 2nd, 2021 (edited)
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.63 KB | None | 0 0
  1. print()
  2. local modem = peripheral.find("modem")
  3. modem.open(3777)
  4. local exitPressed = false
  5. local AnimationTable = {"[O---]","[-O--]","[--O-]","[---O]"}
  6. local function DrawExit()
  7.     term.setCursorPos(17,1)
  8.     term.setBackgroundColor(colors.red)
  9.     term.setTextColor(colors.black)
  10.     print("<")
  11.     term.setBackgroundColor(colors.black)
  12.     term.setTextColor(1)
  13. end
  14.  
  15. local function findWhichButton(x,y)
  16.     if (y == 5) and x == 2 then
  17.         return 0
  18.     elseif y==5 and (x==5 or x==6) then
  19.         return -3
  20.     elseif (y==5) and (13<x and x<17) then
  21.         return 10
  22.     elseif y==1 and x == 17 then
  23.         return -1
  24.     elseif x==2 or x==4 or x==6 then
  25.         if y==2 then
  26.             return x/2
  27.         elseif y==3 then
  28.             return x/2 + 3
  29.         elseif y==4 then
  30.             return x/2 + 6
  31.         end
  32.     end
  33.     return -2
  34. end
  35.  
  36. local function useKeyPad(BlocksOrIngots)
  37.     shell.execute("clear")
  38.     exitPressed = false
  39.     local Num = 0
  40.     print()
  41.     for i = 1 ,9 do
  42.         write("|")
  43.         term.setTextColor(colors.lightBlue)
  44.         write(i)
  45.         term.setTextColor(1)
  46.         if i%3==0 then write("|\n") end
  47.     end
  48.     write("|")
  49.     term.setTextColor(colors.lightBlue)
  50.     write(0)
  51.     term.setTextColor(1)
  52.     write("|[")
  53.     term.setTextColor(colors.orange)
  54.     write("<<")
  55.     term.setTextColor(1)
  56.     write("]")
  57.     term.setCursorPos(12,5)
  58.     write("[")
  59.     term.setTextColor(colors.lime)
  60.     write("Enter")
  61.     term.setTextColor(1)
  62.     write("]")
  63.     sleep(0.1)
  64.     if BlocksOrIngots == "Blocks" then
  65.         term.setCursorPos(9,2)
  66.         write("Enter num")
  67.         term.setCursorPos(9,3)
  68.         write("of Blocks")
  69.     elseif BlocksOrIngots == "Ingots" then
  70.         term.setCursorPos(9,2)
  71.         write("Enter num")
  72.         term.setCursorPos(9,3)  
  73.         write("of Ingots")
  74.     end
  75.     DrawExit()
  76.     local i = 0
  77.     repeat
  78.         local event, button, x, y = os.pullEvent("mouse_click")
  79.         local Button = findWhichButton(x,y)
  80.         if Button == 0 and i ~= 0 then
  81.             Num = Num * 10
  82.             i = i + 1
  83.         elseif Button == 10 then
  84.             i = 5
  85.         elseif Button == -2 then
  86.         elseif Button == -1 then
  87.             i = 5
  88.             exitPressed = true
  89.         elseif Button == -3 then
  90.             if i~=0 then
  91.                 Num = (Num - (Num%10))/10
  92.                 i = i - 1
  93.             end
  94.         else
  95.             Num = Num*10 + Button
  96.             i = i + 1
  97.         end
  98.         term.setCursorPos(1,1)
  99.         term.clearLine(0)
  100.         write(Num)
  101.         DrawExit()
  102.     until i > 3
  103.     if exitPressed == true then
  104.     else
  105.         return Num
  106.     end
  107. end
  108.  
  109. local function UseCastingManu()
  110.     exitPressed = false
  111.     shell.execute("clear")
  112.     term.setCursorPos(1,3)
  113.     write("[")
  114.     term.setTextColor(colors.lightBlue)
  115.     write("Blocks")
  116.     term.setTextColor(1)
  117.     write("]  [")
  118.     term.setTextColor(colors.lightBlue)
  119.     write("Ingots")
  120.     term.setTextColor(1)
  121.     write("]")
  122.     DrawExit()
  123.     local tempOwO = 0
  124.     repeat
  125.         local event, button, x, y = os.pullEvent("mouse_click")
  126.         if 1<x and x<8 and y == 3 then
  127.             tempOwO = "Blocks"
  128.         elseif 11<x and x<18 and y == 3 then
  129.             tempOwO = "Ingots"
  130.         elseif x==17 and y==1 then
  131.             tempOwO = 1
  132.             exitPressed = true
  133.         end
  134.     until tempOwO ~= 0
  135.     if exitPressed == false then
  136.         local ItemNum = useKeyPad(tempOwO)
  137.         if ItemNum ~= nil then
  138.             local MsgPackage = {ItemNum,tempOwO}
  139.             modem.transmit(3777,3777,MsgPackage)
  140.             shell.execute("clear")
  141.             term.getCursorPos(6,3)
  142.             write("Casting")
  143.             local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  144.         end
  145.     end
  146. end
  147.  
  148. local function UseTankOrMixing(TankOrMixing)
  149.     exitPressed = false
  150.     shell.execute("clear")
  151.     term.setCursorPos(7,3)
  152.     write("[")
  153.     term.setTextColor(colors.lightBlue)
  154.     write("Pour")
  155.     term.setTextColor(1)
  156.     write("]")
  157.     DrawExit()
  158.     local i = false
  159.     repeat
  160.         local event, button, x, y = os.pullEvent("mouse_click")
  161.         if y == 1 and x == 17 then
  162.             exitPressed = true
  163.             i = true
  164.         elseif y == 3 and 7<x and x<12 then
  165.             i = true
  166.         end
  167.     until i == true
  168.     if exitPressed == false then
  169.         if TankOrMixing == "Mixing" then
  170.             redstone.setOutput("left",true)
  171.             sleep(0.3)
  172.             redstone.setOutput("left",false)
  173.         elseif TankOrMixing == "Tank" then
  174.             redstone.setOutput("back",true)
  175.             sleep(0.4)
  176.             redstone.setOutput("back",false)
  177.         end
  178.         shell.execute("clear")
  179.         for j = 1 , 25 do
  180.             for i = 1 , 4 do
  181.                 term.setCursorPos(7,3)
  182.                 write(AnimationTable[i])
  183.                 sleep(0.3)
  184.             end
  185.         end
  186.     end
  187. end
  188.  
  189. local function UseTankManu()
  190.     exitPressed = false
  191.     shell.execute("clear")
  192.     term.setCursorPos(1,2)
  193.     write("[")
  194.     term.setTextColor(colors.lightBlue)
  195.     write("Casting")
  196.     term.setTextColor(1)
  197.     write("]")
  198.     term.setCursorPos(1,4)
  199.     write("[")
  200.     term.setTextColor(colors.lightBlue)
  201.     write("Mixing")
  202.     term.setTextColor(1)
  203.     write("]")
  204.     DrawExit()
  205.     local tempUwU = 0
  206.     repeat
  207.         local event, button, x, y = os.pullEvent("mouse_click")
  208.         if y==2 and 1<x and x<9 then
  209.             tempUwU = "Casting"
  210.         elseif y==4 and 1<x and x<8 then
  211.             tempUwU = "Mixing"
  212.         elseif y==1 and x==17 then
  213.             tempUwU = 1
  214.             exitPressed = true
  215.         end
  216.     until tempUwU ~= 0
  217.     if exitPressed == false then
  218.         if tempUwU == "Casting" then
  219.             UseCastingManu()
  220.         elseif tempUwU == "Mixing" then
  221.             UseTankOrMixing("Mixing")
  222.         end
  223.     end
  224. end
  225.  
  226. while true do
  227.     shell.execute("clear")
  228.     term.setCursorPos(1,2)
  229.     write("[")
  230.     term.setTextColor(colors.orange)
  231.     write("Smeltery")
  232.     term.setTextColor(1)
  233.     write("]")
  234.     term.setCursorPos(1,4)
  235.     write("[")
  236.     term.setTextColor(colors.blue)
  237.     write("Tank")
  238.     term.setTextColor(1)
  239.     write("]")
  240.     local i = 0
  241.     repeat
  242.         local event, button, x, y = os.pullEvent("mouse_click")
  243.         if y == 2 and 1<x and x<9 then
  244.             i = "Smeltery"
  245.         elseif y == 4 and 1<x and x<6 then
  246.             i = "Tank"
  247.         end
  248.     until i ~= 0
  249.     if i == "Smeltery" then
  250.         UseTankOrMixing("Tank")
  251.     elseif i == "Tank" then
  252.         UseTankManu()
  253.     end
  254. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement