Fix section_occupancy: Return empty table

Fixes the functioning of the LuaATC function section_occupancy in
the presence of no trains.

Currently, if there is no train in the section,
advtrains.interlocking.db.get_ts will return a table with a nil entry.
When that nil value is passed to table.copy, Minetest throws out an error.
Instead of passing nil to table.copy, just make a new empty table.
This commit is contained in:
Blockhead 2024-06-05 04:09:04 +10:00 committed by orwell
parent a820318ecf
commit 7c4f1377e4
1 changed files with 1 additions and 1 deletions

View File

@ -233,7 +233,7 @@ if advtrains.interlocking then
ts_id = tostring(ts_id) ts_id = tostring(ts_id)
local response = advtrains.interlocking.db.get_ts(ts_id) local response = advtrains.interlocking.db.get_ts(ts_id)
if not response then return false end if not response then return false end
return table.copy(response.trains) return (response.trains and table.copy(response.trains)) or {}
end end
end end