1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-12-28 02:50:33 +00:00
random-stuff/computercraft/ender-chest-seeker.lua

30 lines
652 B
Lua
Raw Normal View History

2023-11-13 19:37:05 +00:00
local ec = peripheral.find "ender_chest"
local ecinv = peripheral.find "minecraft:ender chest"
local f = fs.open("escan.log", "w")
local z = ...
if z then
ec.setFrequency(tonumber(z, 16))
return
end
for i = 0, 0xFFF do
ec.setFrequency(i)
local count = 0
for _, s in pairs(ecinv.list()) do
count = count + s.count
end
if count > 0 then
local log = ("%s %s 0x%03x %d"):format(os.date "!%X", table.concat(ec.getFrequencyColors(), "/"), i, count)
print(log)
f.writeLine(log)
end
if i % 256 == 255 then
f.flush()
end
os.queueEvent ""
os.pullEvent ""
end
f.close()