file: Use io.lines

This commit is contained in:
Lars Mueller 2022-07-17 21:33:54 +02:00
parent b7c6514bc8
commit 318e737a08

@ -121,13 +121,9 @@ end
function process_bridge_listen(name, line_consumer, step) function process_bridge_listen(name, line_consumer, step)
local bridge = process_bridges[name] local bridge = process_bridges[name]
modlib.minetest.register_globalstep(step or 0.1, function() modlib.minetest.register_globalstep(step or 0.1, function()
local content = io.open(bridge.input, "r") for line in io.lines(bridge.input) do
local line = content:read()
while line do
line_consumer(line) line_consumer(line)
line = content:read()
end end
content:close()
write(bridge.input, "") write(bridge.input, "")
end) end)
end end