osmarks

Ender Chest Seeker

Mar 30th, 2020
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local ec = peripheral.find "ender_chest"
  2. local ecinv = peripheral.find "minecraft:ender chest"
  3.  
  4. local f = fs.open("escan.log", "w")
  5.  
  6. local z = ...
  7. if z then
  8.     ec.setFrequency(tonumber(z, 16))
  9.     return
  10. end
  11.  
  12. for i = 0, 0xFFF do
  13.     ec.setFrequency(i)
  14.     local count = 0
  15.     for _, s in pairs(ecinv.list()) do
  16.         count = count + s.count
  17.     end
  18.     if count > 0 then
  19.         local log = ("%s %s 0x%03x %d"):format(os.date "!%X", table.concat(ec.getFrequencyColors(), "/"), i, count)
  20.         print(log)
  21.         f.writeLine(log)
  22.     end
  23.     if i % 256 == 255 then
  24.         f.flush()
  25.     end
  26.     os.queueEvent ""
  27.     os.pullEvent ""
  28. end
  29.  
  30. f.close()
Add Comment
Please, Sign In to add comment