Advertisement
Darking560

BloodAltarCraftauto

Aug 19th, 2015
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.18 KB | None | 0 0
  1. ---------Zone Editable-----------
  2. --ici les direction sont par rapport a l'altar (down,up,east,west,north,south)
  3. local sStone = "down" --direction du coffre stone
  4. local sOut = "east"   --direction du coffre sortie
  5. local sOrb = "west"   --direction du coffre BloodOrb
  6.  
  7. --ici les direction sont par rapport au computer (top,bottom,left,right,forward,back)
  8. m = peripheral.wrap("top") --direction de monitor
  9. altar = peripheral.wrap("back") --direction de l'altar
  10. ---------Zone Non Editable--------
  11.  
  12. local max,amount,pourcent
  13. local pmax = 60
  14. local pmin = 10
  15. local maj = true
  16.  
  17. slot={
  18. [1] = {["id"] = "blankSlate",["lp"] = 1000,["lpt"] = 1000},
  19. [2] = {["id"] = "reinforcedSlate",["lp"] = 2000, ["lpt"] = 3000},
  20. [3] = {["id"] = "imbuedSlate",["lp"] = 5000, ["lpt"] = 8000},
  21. [4] = {["id"] = "demonicSlate",["lp"] = 15000, ["lpt"] = 23000},
  22. [5] = {["id"] = "bloodMagicBaseItems",["lp"] = 30000, ["lpt"] = 53000}
  23. }
  24.  
  25. local craft = {["id"] = "", ["count"] = 0, ["lpt"] = 0}
  26.  
  27. function myread(de,a,reset)
  28.     truc = tonumber(read())
  29.     if truc ~= nil and (truc < a and truc > de) then
  30.         return truc
  31.     else
  32.         return reset
  33.     end
  34. end
  35.  
  36. function screen()
  37.     m.clear()
  38.     m.setCursorPos(1,2)
  39.     m.write(amount.." /")
  40.     m.setCursorPos(1,3)
  41.     m.write(max.."")
  42.     m.setCursorPos(1,4)
  43.     m.write(math.ceil(pourcent).." %")
  44.    
  45.     term.clear()
  46.     term.setCursorPos(2,2)
  47.     term.write("current pourcentage : "..pourcent)
  48.     term.setCursorPos(2,3)
  49.     term.write("1 : pourcentage min (redstone+) : "..pmin)
  50.     temp = max*(pmin/100)
  51.     term.write(" ("..temp..")")
  52.     term.setCursorPos(2,4)
  53.     term.write("2 : pourcentage max (redstone-) : "..pmax)
  54.     temp = max*(pmax/100)
  55.     term.write(" ("..temp..")")
  56.     term.setCursorPos(2,5)
  57.     term.write("current redstone signal : ")
  58.     term.write(tostring(rs.getOutput("right")))
  59.     --zone auto
  60.     if craft.count ~= 0 then
  61.     term.setCursorPos(2,7)
  62.     term.write("Craft en cours : "..craft.id.." encore "..craft.count)
  63.     end
  64.     term.setCursorPos(2,8)
  65.     term.write("3 : blank slate")
  66.     term.setCursorPos(2,9)
  67.     term.write("4 : reinforced slate")
  68.     term.setCursorPos(2,10)
  69.     term.write("5 : imbued slate")
  70.     term.setCursorPos(2,11)
  71.     term.write("6 : demonic slate")
  72.     term.setCursorPos(2,12)
  73.     term.write("7 : ethereal slate")
  74.  
  75. end
  76.  
  77. function craftauto()
  78.     if craft.count ~= 0 then
  79.         item = altar.getStackInSlot(1)
  80.         if item ~= nil then
  81.             if string.find(item.name,"BloodOrb") then
  82.                 altar.pushItem(sOrb,1)
  83.             end
  84.             if item.name == craft.id then
  85.                 altar.pushItem(sOut,1)
  86.                 craft.count = craft.count - 1
  87.             end
  88.         else
  89.             if amount >= craft.lpt then
  90.             altar.pullItem(sStone,1,1)
  91.             end
  92.         end
  93.     end
  94.     if craft.count == 0 and altar.getStackInSlot(1) == nil then
  95.         altar.pullItem(sOrb,1,1)
  96.     end
  97. end
  98.  
  99.  
  100. function principal()
  101. while true do
  102.     if maj then
  103.         l=peripheral.call("back","getTankInfo")
  104.         max = l[1].capacity
  105.         amount = l[1].contents.amount
  106.         pourcent=amount*100/max
  107.        
  108.         if pourcent <= pmin then
  109.             rs.setOutput("right",true)
  110.         end
  111.         if pourcent >= pmax then
  112.             rs.setOutput("right",false)
  113.         end
  114.        
  115.         screen()
  116.     end
  117.    
  118.     craftauto()
  119.    
  120.     sleep(1)
  121. end
  122. end
  123.  
  124. function red()
  125.     m.setBackgroundColor(0x4000)
  126.     m.clear()
  127.     m.setBackgroundColor(0x8000)
  128.     term.clear()
  129.     term.setCursorPos(1,1)
  130. end
  131.  
  132. function selectCraft(nb)
  133.     if craft.count == 0 then
  134.     sleep(0.5)
  135.     maj = false
  136.     red()
  137.     craft.id = slot[nb].id
  138.     craft.lpt = slot[nb].lpt
  139.     print("selection nb de "..slot[nb].id.." a creer (0 pour annuler)")
  140.     craft.count = myread(0,64,0)
  141.     m.clear()
  142.     end
  143. end
  144.  
  145. function event()
  146. while true do
  147.     local event, key, isHeld = os.pullEvent("key")
  148.     key = keys.getName(key)
  149.     if key == "numPad1" then
  150.         sleep(0.5)
  151.         maj = false
  152.         red()
  153.         print("Changement de pourcentage min ("..pmin..")")
  154.         pmin = myread(0,100,pmin)
  155.         m.clear()
  156.     elseif key == "numPad2" then
  157.         sleep(0.5)
  158.         maj = false
  159.         red()
  160.         print("Changement de pourcentage max ("..pmax..")")
  161.         pmax = myread(0,100,pmax)
  162.         m.clear()
  163.     end
  164.    
  165.     if key == "numPad3" then
  166.         selectCraft(1)
  167.     elseif key == "numPad4" then
  168.         selectCraft(2)
  169.     elseif key == "numPad5" then
  170.         selectCraft(3)
  171.     elseif key == "numPad6" then
  172.         selectCraft(4)
  173.     elseif key == "numPad7" then
  174.         selectCraft(5)
  175.     end
  176.     maj = true
  177. end
  178. end
  179.  
  180. parallel.waitForAny(principal,event)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement