Hi! I get the following error on starting a new game with this mod enabled:
4632.244 Error MainLoop.cpp:1288: Exception at tick 1: The mod Vehicle Cruise Control (0.0.8) caused a non-recoverable error.
Please report this error to the mod author.
Error while running event Vehicle_Cruise_Control::on_tick (ID 0)
__Vehicle_Cruise_Control__/control.lua:83: attempt to index field 'cc_state' (a nil value)
The problem is here:
script.on_configuration_changed(function(data)
if (global.init or 0) < 1
then global.init, global.guis, global.cc_state = 1, {}, {} end
end)
script.on_init(function() strict_mode_enable() end)
script.on_load(function() strict_mode_enable() end)
You don't initialize the global tables in on_init
, just in on_configuration_changed
-- which will only run if the mod has been added to a running game or if mods/modsettings have been changed, but not if a new game is started.
EDIT: If on_configuration_changed
is run because some other mod has changed, global.guis
and global.cc_state
will always be reset to {}. Is that intentional, or shouldn't you preserve existing tables?