here is the relevant code:
Code: Select all
if glob.easy_death.print then
return
elseif game.difficulty == defines.difficulty.easy then glob.easy_death.print = true
else glob.easy_death.print = false
end
if glob.easy_death.remains then
return
elseif game.difficulty == defines.difficulty.easy or game.difficulty == defines.difficulty.normal then glob.easy_death.remains = true
else glob.easy_death.remains = false
end
fixed and working mod (though incomplete): edit: first this has been explained as caused by the calling order of Factorio script loading (Thanks slpwnd).
1) the global scope is executed
2) oninit method is called
second, I was tired when I posted (it was 3am and I'd been up for a long time) and I mistakenly wrote that it crashed Factorio. It actually just caused an attempt to index nil (easy_death), though I did experience several crashes when I was rewriting the code to allow for it to use the difficulty setting so that is probably why lol.