In 0.0.4, I'm now sometimes getting the same "attempt to index global 'BB_glob_amount' ( a nil value)" errors but on line 103 of control.lua. Line 103 seems to just be when clicking on the checkboxes.
Weirdly, it worked fine for a while. This is about the third load of that game before it happened.
Maybe you're correctly setting it on first run, but not on subsequent game loads? (I might not have placed any belts during the second session).
Edit: I'm going to try shoving the BB_glob_amount into script.on_load - it might reset the glob size every time the game is loaded, but if it works I won't care

(Alas, it resets it on every autosave as well)
Edit2: For that matter, in a multiplayer context, on line 156ish, won't setting BB_glob_amount = {} once for any player in the game that doesn't have the glob toolbar setup also silently break all other players?
Edit3: Okay, after some reading of the modding documentation I believe you're meant to store this sort of thing in the global data object, so that it gets saved and loaded with the mod. Then you just need a migration from version 0 (no mod installed) to any other version that initializes the global object with a BB_glob_amount, and then the ontick handler that adds players interface bar widgets can also set the BB_glob_amount[playerIndex] to 0? Trying that now...
Edit4: This is approaching the limit of effort I'll put in to get something to work, I'm just gonna uninstall this mod (useful as it is) if this doesn't work. Plus, I mostly just wanted an up to date easybelt anyway...
Here, this seems to work for me. If I had git installed on this computer / I could be bothered, I'd submit a pull request. As it is, you can paste it in yourself
First you'll need to find-and-replace all instances of BB_glob_amount with global.BB_glob_amount
Then paste this in wherever you feel appropriate. Then just increment the version number to higher than 0.0.4... hmm, speaking of, if you're being considerate you might also want to consider migrations for people who aren't on 0.0.4, though I feel they'll probably be the most affected.
Code: Select all
script.on_configuration_changed(function(data)
if data.mod_changes ~= nil
and data.mod_changes["BeltBrush"] ~= nil
and (data.mod_changes["BeltBrush"].old_version == nil or data.mod_changes["BeltBrush"].old_version == "0.0.4")
then
global.BB_glob_amount = {}
for i in ipairs(game.players) do
global.BB_glob_amount[i] = 0
end
end
end)
script.on_init(function()
if not global.BB_glob_amount then
global.BB_glob_amount = {}
end
end)