[0.16.16] Game freezes on very simple mod script
Posted: Thu Jan 11, 2018 9:47 pm
The scripting code in question is very simple and innocuous, but even if it has an error - somehow - there is at least a sandboxing failure because the game is not supposed to completely lock up like that.
The code in question is this:
The actual line triggering the freeze is that last one, the table.insert. Removing it fixes the issue. I cannot imagine what I might be doing wrong; I have done this sort of thing 40 times and all it is doing is adding an entry to the global data table.
I checked the obvious solution of a runaway loop; that is not in fact occurring (the function is only ever called once).
As for the freeze, memory usage is not continuously climbing, so it is not a runaway allocation. But one CPU core does get maxed out. The only way to recover is to use Task Manager to kill the process.
The log contains nothing of value, with the last line being related to the world loading, and nothing being printed after that.
This code is for the idea described here.
The code in question is this:
Code: Select all
local function onEntityAdded(entity)
if string.find(entity.name, "depot-placer", 1, true) then
local depot = global.depot
local type = string.match(entity.name, "%d+")
local render = entity.surface.create_entity({name = "depot-render-type-" .. type, position = entity.position, force = entity.force})
local storage = entity.surface.create_entity({name = "depot-type-" .. type, position = entity.position, force = entity.force})
local entry = {main = storage, placer = entity, render = render, type = type}
table.insert(depot.entries, entry)
end
end
I checked the obvious solution of a runaway loop; that is not in fact occurring (the function is only ever called once).
As for the freeze, memory usage is not continuously climbing, so it is not a runaway allocation. But one CPU core does get maxed out. The only way to recover is to use Task Manager to kill the process.
The log contains nothing of value, with the last line being related to the world loading, and nothing being printed after that.
This code is for the idea described here.