Advertisement
Muzze77

HV_Terminal_Lycodon

Aug 14th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.74 KB | None | 0 0
  1. shell.run("clear")
  2. mon = peripheral.wrap("right")
  3. pipe = peripheral.wrap("back")
  4. craftings = {}
  5. function getCrafts()
  6. pipe.getCraftableItems()
  7. evt, craftings = os.pullEvent("craftable_items_return")
  8. end
  9. items= {}
  10. function getItems()
  11. pipe.getAvailableItems()
  12. evt, items = os.pullEvent("available_items_return")
  13. end
  14. resources = {"Lapis Lazuli","UU-Matter","Gold Ingot","Iron Ingot","Refined Iron","Redstone","Glowstone Dust","Cobblestone","Glass","Rubber","Coal Dust","Coal", "Sticky Resin","Oak Wood","Oak Wood Planks","Diamond","Uranium Cell","Uranium Ore", "Refined Uranium"}
  15. crafts = {"Copper Cable","2xIns. Gold Cable","Furnace","Iron Furnace","Electronic Circuit","RE-Battery","LV-Transformer","MV-Transformer","HV-Transformer"}
  16. solars = {"Solar Panel","High Voltage Solar Array","Medium Voltage Solar Array", "Low Voltage Solar Array"}
  17. gx,gy = mon.getSize()
  18. mon.setTextScale(0.5)
  19. mon.clear()
  20. function cbut(cx,cy,text,bcol,tcol)
  21.     if bcol == nil then
  22.         bcol = colors.black
  23.     end
  24.     if tcol == nil then
  25.         tcol = colors.white
  26.     end
  27.  
  28.   mon.setCursorPos(cx-1,cy)
  29.   for a = 0, string.len(text)+1,1 do
  30.     write(" ")
  31.   end
  32.   mon.setBackgroundColor(bcol)
  33.   mon.setTextColor(tcol)
  34.   mon.setCursorPos(cx,cy)
  35.   mon.write(text)
  36.   mon.setBackgroundColor(colors.black)
  37.   mon.setTextColor(colors.white)
  38. end
  39.  
  40. config = {}
  41. while true do
  42. getItems()
  43. getCrafts()
  44. x = 2
  45. y = 3
  46. cbut(x,y-1,"Resources")
  47. for v, k in pairs(items) do
  48.  
  49.   item = pipe.getItemName(k[1])
  50.   size = k[2]
  51.   s = string.format("%-8dx %15s", size,string.sub(item,0,15))
  52.   for v2,k2 in pairs(resources) do
  53.     if item == k2 then
  54.       cbut(x,y,s)
  55.       y = y+ 1
  56.       if y >= gy/2-2 then
  57.         y = 2
  58.         x = x + 15
  59.       end
  60.    
  61.     end
  62.  
  63.   end
  64. end
  65.  
  66.  
  67.  
  68. x= 40
  69. y = 3
  70. cbut(x,y-1,"Craftings")
  71. for v, k in pairs(items) do
  72.  
  73.   item = pipe.getItemName(k[1])
  74.   size = k[2]
  75.   s = string.format("%-8dx %15s", size,string.sub(item,0,15))
  76.   for v2,k2 in pairs(crafts) do
  77.     if item == k2 then
  78.       cbut(x,y,s)
  79.       y = y+ 1
  80.       if y >= gy/2-2 then
  81.         y = 2
  82.         x = x + 15
  83.       end
  84.    
  85.     end
  86.  
  87.   end
  88. end
  89.  
  90. x = 80
  91. y =3
  92.  
  93. cbut(x,y-1,"Solars")
  94. for v, k in pairs(items) do
  95.  
  96.   item = pipe.getItemName(k[1])
  97.   size = k[2]
  98.   s = string.format("%-8dx %15s", size,string.sub(item,0,15))
  99.   for v2,k2 in pairs(solars) do
  100.     if item == k2 then
  101.       cbut(x,y,s)
  102.       y = y+ 1
  103.       if y >= gy/2-2 then
  104.         y = 2
  105.         x = x + 15
  106.       end
  107.    
  108.     end
  109.  
  110.   end
  111. end
  112.  
  113. x = 2
  114. y = gy/2
  115. cbut(x,y-1,"Craftable")
  116.  
  117. for v, k in pairs(craftings) do
  118.  
  119.   item = pipe.getItemName(k)
  120.   s = string.format("%-20s",string.sub(item,0,15))
  121.  
  122. if #config == 0 then
  123.     table.insert(config,{["Name"]= s, ["X"] = x,["Y"] = y , ["State"] = 0})
  124. else
  125.  
  126.   for a,b in pairs(config) do
  127.     if b["Name"]== s then
  128.         if b["State"] == 0 then
  129.             cbut(x,y,s,nil,colors.red)
  130.         else
  131.             cbut(x,y,s,nil,colors.green)
  132.         end
  133.    
  134.     else
  135.         table.insert(config,{["Name"]= s, ["X"] = x,["Y"] = y , ["State"] = 0})
  136.     end
  137. end
  138.       y = y+ 1
  139.       if y >= gy-2 then
  140.         y = gy/2
  141.         x = x + 20
  142.  
  143.    
  144.     end
  145.  
  146.  
  147. end
  148. end
  149. x = 1
  150. y = 1
  151. for v, k in pairs(config) do
  152.    
  153.    
  154.     term.setCursorPos(x,y)
  155.     term.write(string.format("%d" ,v))
  156.     term.setCursorPos(x+4,y)
  157.     term.write(k["Name"])  
  158.     term.setCursorPos(x+20,y)
  159.     term.write(string.format("%d" ,k["X"]))
  160.     term.setCursorPos(x+25,y)
  161.     term.write(string.format("%d" ,k["Y"]))
  162.     term.setCursorPos(x+30,y)
  163.     term.write(string.format("%d" ,k["State"]))
  164.     y = y + 1
  165. end
  166.  
  167. evt, side, x,y = os.pullEvent("monitor_touch")
  168.     for v, k in pairs(config) do
  169.         if x >= k["X"] and x <= k["X"] + 15 and y == k["Y"] then
  170.             if k["State"]  == 0 then
  171.                 k["State"] = 1
  172.             elseif k["State"]  == 1 then
  173.                 k["State"] = 0
  174.             end
  175.         end
  176.     end
  177.  
  178. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement