Sam's Trains deprecated

by bMac59

>> Originally by Kiasyn << A simple, easy-to-use, no circuits required train scheduler for people who just want their trains to work. Incompatible with INFORMATRON mod

Content
4 years ago
0.18
8
Trains

g error

4 years ago

getting this error

SamTrain_v18/control.lua:12: SamTrain_v18/config.lua:77: bad argument #2 of 3 to 'setmetatable' (nil or table expected got userdata)
stack traceback:
[C]: in function 'setmetatable'
SamTrain_v18/config.lua:77: in main chunk
[C]: in function 'require'
SamTrain_v18/control.lua:12: in main chunk
stack traceback:
[C]: in function 'require'
SamTrain_v18/control.lua:12: in main chunk

4 years ago

ok, I'll see what I can find.
might need a save-game to reproduce/test it.

what were you doing when it came up?

4 years ago

it may be another mod you have running that it's not compatible with. I don't know which mods you are using.

4 years ago
(updated 4 years ago)

I have this problem too.. I doubt it could be a different mod..
FYI, I am running the following mods

   5.887 Checksum for core: 3958517679
   5.887 Checksum of base: 2595428403
   5.887 Checksum of TogglePeacefulMode: 1879486285
   5.887 Checksum of aai-industry: 3736519540
   5.887 Checksum of auto-research-redistributed: 3894696288
   5.887 Checksum of AutoDeconstruct: 934032342
   5.887 Checksum of AutomaticStationNames: 3834326227
   5.887 Checksum of Automatic_Train_Painter: 954947820
   5.887 Checksum of ColorblindCircuitNetwork: 1298983855
   5.887 Checksum of even-distribution: 3142890650
   5.887 Checksum of inbuilt_lighting: 3963065095
   5.887 Checksum of miniloader: 2476366911
   5.887 Checksum of romulinhoeasystart: 0
   5.888 Checksum of SpaceMod: 1358565566
   5.888 Checksum of stdlib: 0
   5.888 Checksum of Todo-List: 3182550957
   5.888 Checksum of robotworld-continued: 1470902191
   5.888 Checksum of SamTrain_v18: 3663253643

Anyway.. I dug into the code a bit and found a fix.
Here is what I fixed. In config.lua.. scroll to the bottom to line 75 which is

for name, data in pairs(config) do
    if data.exclude ~= nil then
        setmetatable(data.exclude, string_array)
    end
end

and change it to..

local string_array_metatable = getmetatable(string_array({}))
for name, data in pairs(config) do
    if data.exclude ~= nil then
        setmetatable(data.exclude, string_array_metatable)
    end
end
4 years ago

BTW I was adding the mod into an existing game.. and the error showed when I enabled the mod and tried to load the save.. Not while playing a game.

4 years ago

Great, thanks. I'll implement it.

4 years ago

Hey bMac59,
Would you like to share your source via github?

New response