Advertisement
JaMaNi133

smeltery thingi

Oct 28th, 2023 (edited)
704
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.73 KB | None | 0 0
  1. print("smeltery dings v0.3")
  2.  
  3. local monAdr = "back"
  4. local netSide = "left"
  5.  
  6. local RecIds = {5,7,6,9,11,10}
  7. local RecNames = {"Mixer     ","Smeltery  ","Storage A ","Storage B ","Ingot Cast","VOID      "}
  8. local RecAct = {false,false,false,false,false,false}
  9. local RecOptions = {16,0,0,0,0,42}
  10.  
  11. local numRec = 6
  12. --disables
  13. --ioioio
  14. --CCBBAA
  15.  
  16.  
  17.  
  18.  
  19.  
  20. RecStatesA = {"-","-","-","-","-","-","-","-"}
  21. RecStatesB = {"-","-","-","-","-","-","-","-"}
  22. RecStatesC = {"-","-","-","-","-","-","-","-"}
  23.  
  24. rednet.open(netSide)
  25. rednet.broadcast("533")
  26. local mon = peripheral.wrap("back")
  27. mon.setTextScale(1)
  28. os.queueEvent("monitor_touch",manAdr,111,111)
  29. while true do
  30.    
  31.     Event, EventAdress, EventPosX, EventPosY = os.pullEvent("monitor_touch")
  32.     mon.setTextColor(1)
  33.     mon.setCursorPos(1,1)
  34.     mon.setBackgroundColor(512)
  35.     mon.write("Smeltery v0.2     ")
  36.     local RecN
  37.     print(string.format("event: %s   adr: %s   X: %d   Y: %d",Event, EventAdress, EventPosX, EventPosY))
  38.  
  39.     cur = 1
  40.     while cur <= numRec do
  41.         RecN = cur
  42.         local opts = 0
  43.         print(RecStatesA[RecN])
  44.         if EventPosY == cur+2 then
  45.             if EventPosX <= 10 then
  46.                 RecAct[RecN] = not RecAct[RecN]
  47.             end
  48.             if EventPosX == 12 then
  49.                 if RecStatesA[RecN] == "-" then
  50.                     RecStatesA[RecN] = "i"
  51.                 elseif RecStatesA[RecN] == "i" then
  52.                     RecStatesA[RecN] = "o"
  53.                 elseif RecStatesA[RecN] == "o" then
  54.                     RecStatesA[RecN] = "-"
  55.                 end
  56.                
  57.                 opts = bit.band(RecOptions[RecN],3)
  58.                 if opts == 1 then
  59.                     if RecStatesA[RecN] == "i" then
  60.                         RecStatesA[RecN] = "o"
  61.                     end
  62.                 elseif opts == 2 then
  63.                     if RecStatesA[RecN] == "o" then
  64.                         RecStatesA[RecN] = "-"
  65.                     end
  66.                 elseif opts == 3 then
  67.                     RecStatesA[RecN] = ""
  68.                 end
  69.                
  70.             end
  71.            
  72.             if EventPosX == 14 then
  73.                 if RecStatesB[RecN] == "-" then
  74.                     RecStatesB[RecN] = "i"
  75.                 elseif RecStatesB[RecN] == "i" then
  76.                     RecStatesB[RecN] = "o"
  77.                 elseif RecStatesB[RecN] == "o" then
  78.                     RecStatesB[RecN] = "-"
  79.                 end
  80.                 opts = bit.band(RecOptions[RecN],12)
  81.                 if opts == 4 then
  82.                     if RecStatesB[RecN] == "i" then
  83.                         RecStatesB[RecN] = "o"
  84.                     end
  85.                 elseif opts == 8 then
  86.                     if RecStatesB[RecN] == "o" then
  87.                         RecStatesB[RecN] = "-"
  88.                     end
  89.                 elseif opts == 12 then
  90.                     RecStatesB[RecN] = ""
  91.                 end
  92.             end
  93.             if EventPosX == 16 then
  94.                 if RecStatesC[RecN] == "-" then
  95.                     RecStatesC[RecN] = "i"
  96.                 elseif RecStatesC[RecN] == "i" then
  97.                     RecStatesC[RecN] = "o"
  98.                 elseif RecStatesC[RecN] == "o" then
  99.                     RecStatesC[RecN] = "-"
  100.                 end
  101.                 opts = bit.band(RecOptions[RecN],48)
  102.                 if opts == 16 then
  103.                     if RecStatesC[RecN] == "i" then
  104.                         RecStatesC[RecN] = "o"
  105.                     end
  106.                 elseif opts == 32 then
  107.                     if RecStatesC[RecN] == "o" then
  108.                         RecStatesC[RecN] = "-"
  109.                     end
  110.                 elseif opts == 48 then
  111.                     RecStatesC[RecN] = ""
  112.                 end
  113.             end
  114.  
  115.             --rednet
  116.  
  117.  
  118.             magik = 0
  119.             if RecStatesA[RecN] == "-" then
  120.                 magik = magik + 1
  121.             elseif RecStatesA[RecN] == "i" then
  122.                 magik = magik + 0
  123.             elseif RecStatesA[RecN] == "o" then
  124.                 magik = magik + 2
  125.             end
  126.  
  127.             if RecStatesB[RecN] == "-" then
  128.                 magik = magik + 4
  129.             elseif RecStatesB[RecN] == "i" then
  130.                 magik = magik + 0
  131.             elseif RecStatesB[RecN] == "o" then
  132.                 magik = magik + 8
  133.             end
  134.  
  135.             if RecStatesC[RecN] == "-" then
  136.                 magik = magik + 16
  137.             elseif RecStatesC[RecN] == "i" then
  138.                 magik = magik + 0
  139.             elseif RecStatesC[RecN] == "o" then
  140.                 magik = magik + 32
  141.             end
  142.             if not RecAct[RecN] then
  143.                 magik = 533
  144.             end
  145.            
  146.  
  147.            
  148.            
  149.                
  150.            
  151.             rednet.send(RecIds[RecN],magik)
  152.                
  153.                
  154.         end
  155.         mon.setCursorPos(1,cur + 2)
  156.         if RecAct[RecN] then
  157.             mon.setBackgroundColor(colors.green)
  158.         else
  159.             mon.setBackgroundColor(colors.red)
  160.         end
  161.         mon.write(RecNames[RecN])
  162.    
  163.    
  164.    
  165.    
  166.         mon.setCursorPos(12,cur + 2)
  167.         if RecStatesA[RecN] == "i" then
  168.             mon.setBackgroundColor(colors.green)
  169.         end
  170.         if RecStatesA[RecN] == "o" then
  171.             mon.setBackgroundColor(colors.blue)
  172.         end
  173.         if RecStatesA[RecN] == "-" then
  174.             mon.setBackgroundColor(colors.red)
  175.         end
  176.         mon.write(RecStatesA[RecN])
  177.    
  178.    
  179.    
  180.    
  181.         mon.setCursorPos(14,cur + 2)
  182.         if RecStatesB[RecN] == "i" then
  183.             mon.setBackgroundColor(colors.green)
  184.         end
  185.         if RecStatesB[RecN] == "o" then
  186.             mon.setBackgroundColor(colors.blue)
  187.         end
  188.         if RecStatesB[RecN] == "-" then
  189.             mon.setBackgroundColor(colors.red)
  190.         end
  191.         mon.write(RecStatesB[RecN])
  192.    
  193.    
  194.    
  195.         mon.setCursorPos(16,cur + 2)
  196.         if RecStatesC[RecN] == "i" then
  197.             mon.setBackgroundColor(colors.green)
  198.         end
  199.         if RecStatesC[RecN] == "o" then
  200.             mon.setBackgroundColor(colors.blue)
  201.         end
  202.         if RecStatesC[RecN] == "-" then
  203.             mon.setBackgroundColor(colors.red)
  204.         end
  205.         mon.write(RecStatesC[RecN])
  206.  
  207.  
  208.         cur = cur + 1
  209.     end
  210.  
  211.  
  212.  
  213.    
  214.          
  215.  
  216.     --mon.clear()
  217.  
  218. end
  219.  
  220.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement