Advertisement
chuzAUzername

rescue NBT-tag garbage from ME-network

Apr 30th, 2022 (edited)
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local component = require("component")
  2. local db = component.database
  3. local exportbus = component.me_exportbus
  4. local controller = component.me_controller
  5. local args = {...}
  6. local item = args[1]
  7.  
  8.  
  9. local function getDbSize()
  10.   if not pcall(function() db.get(10) end) then
  11.     return 9
  12.   elseif not pcall(function() db.get(26) end) then
  13.     return 25
  14.   else
  15.     return 81
  16.   end
  17. end
  18.  
  19.  
  20. local function noneItemID()
  21.   if item == nil then
  22.     print("Enter the object ID as an argument. For example: rescue minecraft:axe")
  23.       return true
  24.   end
  25. end
  26.  
  27.  
  28. local function mainExport()
  29.   for i = 1, getDbSize() do
  30.     db.clear(i)
  31.   end
  32. end
  33.  
  34.  
  35. local function setExportConfig()
  36.   controller.store({name = item}, db.addres, 1, 1)
  37.   for i=1,6 do
  38.     if exportbus.setExportConfiguration(i, 1, db.address, 1) then
  39.       break
  40.     end
  41.   end
  42. end
  43.  
  44. checkItem = controller.getItemsInNetwork({name = item}).n
  45.  
  46. if checkItem == 0 then
  47.   print("You have 0 items. Programm stops. Cooldown is approx. 1 min.")
  48. else
  49.   print("You have", checkItem, "items. Be patient... Export will start soon...")
  50.   for i = 1, checkItem do
  51.     if noneItemID() then break end
  52.     setExportConfig()
  53.     mainExport()
  54.   end
  55.   print("Check the storage.")
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement