Advertisement
Tawok

HohlraumStorage

May 6th, 2022 (edited)
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Programme pour relancer le reacteur
  2.  
  3. chestType = "dimstorage:dimensional_chest"
  4. chest = peripheral.find(chestType)
  5.  
  6. monitor = peripheral.find("monitor")
  7. monitor.clear()
  8. monitor.setTextScale(1.2)
  9.  
  10. if chest == nill then
  11.     error(chestType.." non trouvé, verifier la configuration (l3)")
  12.     else
  13.         print(chestType.." trouvé")
  14. end
  15.  
  16.  
  17. function stored(chest)
  18.     local cpt = 0
  19.     local list = {}
  20.     list = chest.list()
  21.     for i=1, chest.size(), 1 do
  22.         if list[i] ~= nil then
  23.             cpt = cpt+list[i].count
  24.         end
  25.     end
  26.     return cpt
  27. end
  28.  
  29. --pour afficher les nouvelles informations
  30. function resetPos(time)
  31.     os.sleep(time)
  32.     monitor.clear()
  33.     monitor.setCursorPos(1,1)
  34. end
  35.  
  36. function launch(cpt)
  37.     monitor.write("Hohlraum restant: ")
  38.     monitor.setCursorPos(1,2)
  39.     monitor.write(cpt)
  40.     resetPos(1)
  41.     monitor.write("Lancement du reacteur")
  42.     redstone.setAnalogOutput("right", 10)
  43.     resetPos(0.5)
  44.     for i=1,5,1 do
  45.         monitor.write(".")
  46.         os.sleep(0.4)
  47.     end
  48.     redstone.setAnalogOutput("right", 0)
  49.     resetPos(0.5)
  50.     monitor.write("Reacteur lancé!")
  51. end
  52.  
  53.  
  54. while true do
  55.    
  56.     --On effectue les actions lors du declenchement du bouton
  57.  
  58.     if redstone.getAnalogInput("bottom")>0 then
  59.    
  60.  
  61.         count = stored(chest)
  62.         print(count)
  63.  
  64.  
  65.         monitor.clear()
  66.         monitor.setCursorPos(1,1)
  67.  
  68.  
  69.         --si plus d'holhraum on ne demarre pas le reacteur
  70.  
  71.         if count == 0 then
  72.             print("Plus d'Hohlraum, remplir dimChest 701")
  73.             monitor.write("Plus d'Hohlraum")
  74.             monitor.setCursorPos(1,2)
  75.             monitor.write("Remplir le dimensional Chest 701")
  76.         else
  77.             launch(count)            
  78.         end
  79.  
  80.     resetPos(2)
  81.     monitor.write("Appuyer sur le bouton")
  82.     monitor.setCursorPos(1,2)
  83.     monitor.write("pour lancer le réacteur")
  84.     end
  85.    
  86.     os.sleep(0.5)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement