Advertisement
cenestral

smelty

Jan 26th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.83 KB | None | 0 0
  1. -- Smeltery Program UNTESTED
  2. -- FTB Infinty Evolved
  3.  
  4. -----
  5. perif=nil
  6. mon=nil
  7. cont=nil
  8. ---
  9. ingotSide = "right"
  10. blockSide = "left"
  11.  
  12. ingotTimerGoal = 10
  13. blockTimerGoal = 36
  14.  
  15. ingotTimer = 0
  16. blockTimer = 0
  17. ---------
  18.  
  19. function scanPer()
  20.     if (mon==nil) and (cont==nil) then
  21.         print("---===###===---")
  22.  
  23.         while perif == nil do
  24.             perif= peripheral.getNames()
  25.             print("[*] Scanning network...")
  26.             sleep(.5)
  27.         end
  28.  
  29.         while (mon==nil) and (cont==nil) do
  30.             print("[*] Connected peripherals: ")
  31.             for i=1, #perif do
  32.                 print("[+] ---> : "..perif[i])
  33.                 if string.find(perif[i],"monitor") then
  34.                     mon = peripheral.wrap(perif[i])
  35.                 elseif string.find(perif[i],"smeltery") then
  36.                     cont = peripheral.wrap(perif[i])
  37.                 end
  38.             end
  39.  
  40.             print("[-] Failed!")
  41.             print("[-] Retry!")
  42.             sleep(.5)
  43.         end
  44.  
  45.         print("[+] Success!")
  46.         print("---===###===---")
  47.     end
  48. end
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. function posWrite(x,y,z,s)
  57.     mon.setTextScale(s)
  58.     mon.setCursorPos(x,y)
  59.     mon.write(z)
  60. end
  61.  
  62. function getNumber(inp,typ)
  63.     calc = inp / typ
  64.    
  65.     if calc < 1 then
  66.         leftover = inp
  67.         number = 0
  68.     else
  69.         number = math.floor(calc)
  70.         leftover = inp - ((number) * typ)
  71.     end
  72.    
  73.     return number,leftover
  74. end
  75.  
  76.  
  77. function castIngot(inp,inn)
  78.     if inp >= 1 then
  79.         print("[~] Casting "..inn.." ingot!")
  80.         redstone.setOutput(ingotSide,true)
  81.         sleep(.1)
  82.         redstone.setOutput(ingotSide,false)
  83.     end
  84. end
  85.  
  86. function castBlock(inp,inn)
  87.     if inp >= 1  then
  88.         print("[~] Casting "..inn.." block!")
  89.         redstone.setOutput(blockSide,true)
  90.         sleep(.1)
  91.         redstone.setOutput(blockSide,false)
  92.     end
  93. end
  94.  
  95. function doCasting(ina,inc,inn)
  96.  
  97.         if ina ~= 0 then
  98.        
  99.             if blockTimer <= 0 and ingotTimer <= 0 then
  100.                 castBlock(ina,inn)
  101.                 blockTimer = blockTimerGoal
  102.             end
  103.            
  104.         else
  105.        
  106.             if blockTimer <= 0 and ingotTimer <= 0 then
  107.                 castIngot(inc,inn)
  108.                 ingotTimer = ingotTimerGoal
  109.             end
  110.            
  111.         end
  112.  
  113. end
  114.  
  115.  
  116.  
  117.  
  118.  
  119. while true do
  120.  
  121.     scanPer()
  122.  
  123.     tbl = cont.getInfo()
  124.     mon.clear()
  125.    
  126.     if tbl["contents"]~=nil then
  127.    
  128.         name = tbl["contents"]["rawName"]
  129.         a,b = getNumber(tbl["contents"]["amount"],1296)
  130.         c,d = getNumber(b,144)
  131.         e,f = getNumber(d,16)
  132.  
  133.        
  134.        
  135.         if string.find(name,"Molten") then
  136.             shortName = string.sub(name,8)
  137.         else
  138.             shortName = name
  139.         end
  140.        
  141.         posWrite(1,1,shortName,0.5)
  142.        
  143.         posWrite(1,3,"> "..a.." Block",0.5)
  144.  
  145.         posWrite(1,5,"> "..c.." Ingot",0.5)
  146.  
  147.         posWrite(1,7,"> "..e.." Nugget",0.5)
  148.  
  149.         posWrite(1,9,"> "..f.." mB",0.5)
  150.        
  151.         posWrite(1,10,"   -= "..ingotTimer.."|"..blockTimer.." =-",0.5)
  152.                
  153.         doCasting(a,c,shortName)
  154.  
  155.        
  156.     else
  157.    
  158.         posWrite(1,9,"   -= "..ingotTimer.."|"..blockTimer.." =-",0.75)
  159.         posWrite(1,1,"  -=|Empty|=-",.75)
  160.  
  161.  
  162.     end
  163.    
  164.     blockTimer = blockTimer - 1
  165.     ingotTimer = ingotTimer - 1
  166.    
  167.     blockTimer=math.max(blockTimer,0)
  168.     ingotTimer=math.max(ingotTimer,0)
  169.    
  170.     sleep(.5)
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement