Advertisement
MagmaLP

1

Oct 21st, 2023 (edited)
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. sen = sensor.wrap("top")
  3. os.pullEvent = os.pullEventRaw
  4.  
  5. s = sen.getTargets()
  6. function getS()
  7.     for v, k  in pairs(s) do
  8.         if k.Name == "ME Wireless Access Point" then  
  9.             target = v
  10.         end
  11.     end
  12.     return target
  13. end
  14.  
  15. Shard_Of_Minium_Amount = 0
  16. print("1 "..Shard_Of_Minium_Amount)
  17.  
  18. f = getS()
  19. s1 = sen.getTargetDetails(target)
  20. for v, k in pairs(s1.Items) do
  21.  
  22.     if k.Name == "Shard of Minium" then
  23.         Shard_Of_Minium_Amount = k.Size
  24.     end
  25.    
  26.     print("2 "..Shard_Of_Minium_Amount)
  27.     if Shard_Of_Minium_Amount > 0 then
  28.         local file = fs.open("Craftings", "r")
  29.         Craftings = file.readLine()
  30.         file.close()
  31.  
  32.         Craftings = Craftings + (Shard_Of_Minium_Amount * 40)
  33.         print("NEW Craftings "..Craftings)
  34.        
  35.         local file = fs.open("Craftings", "w")
  36.         file.write(Craftings)
  37.         file.close()
  38.  
  39.         if Craftings == 0 then
  40.             sleep(5)
  41.             os.reboot()
  42.         end
  43.        
  44.         sleep(1)
  45.         rs.setOutput("bottom", true)
  46.         sleep(3)
  47.         rs.setOutput("bottom", false)
  48.         sleep(1)
  49.     end
  50. end
  51.  
  52. local file = fs.open("Craftings", "r")
  53. Craftings = file.readLine()
  54. file.close()
  55. print("Abfrage Craftings "..Craftings)
  56. Craftings = tonumber(Craftings)
  57.  
  58. x = 0
  59. while true do
  60.     if Craftings >= 8 then
  61.         a = turtle.getItemCount(1)
  62.         print("Übrige Craftings "..Craftings)
  63.         if a == 64 then
  64.             turtle.drop(64)
  65.             Craftings = Craftings - 8
  66.             local file = fs.open("Craftings", "w")
  67.             file.write(Craftings)
  68.             file.close()
  69.         end
  70.     else    
  71.         print("sleep10")
  72.         sleep(30)
  73.         os.reboot()
  74.     end
  75.    
  76.     x = x + 1
  77.     if x == 50 then
  78.         os.reboot()
  79.     end  
  80.    
  81.     sleep(0.5)
  82. end
  83.    
  84.  
  85.      
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement