Electric Train


Adds electric locomotives to the game.

Content
3 years ago
0.14 - 1.1
69.1K
Trains

b error while adding new Train

4 years ago

in global.ControlList the first entry is an invalid LuaEntity. My Control is on pos 2.
I added a new function:
function getValidControl()
for i,ctrl in pairs(global.ControlList) do
if(global.ControlList[i].valid) then
return i
end
end
return 0
end

and use this in function CreateProvider(loc)
local control = global.ControlList[getValidControl()]
local pos = control.position
local surface = control.surface
local force = control.force
local entity = surface.create_entity{name=loc.entity.name.."-power",position=pos,force=force}
loc.provider = entity
end

not sure what will happen if i delete all controls to, but at least i can place and use your trains again

New response