1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00

Mtn: fix locomotive issue

This commit is contained in:
Gerkiz 2024-11-11 18:47:52 +01:00
parent 81a167f081
commit fa4db3891f
2 changed files with 14 additions and 4 deletions

View File

@ -2511,7 +2511,7 @@ function Public.on_player_changed_position(event)
if not loco_surface or not loco_surface.valid then
return
end
if player.surface.index == loco_surface.index then
if player.character ~= nil and player.character.surface.index == loco_surface.index then
local map_gen = loco_surface.map_gen_settings
if player.position.y > map_gen.height then player.set_controller { type = 1, character = player.character } end
if player.position.y < (-map_gen.height / 2) then player.set_controller { type = 1, character = player.character } end

View File

@ -972,7 +972,12 @@ function Public.reconstruct_all_trains(icw)
if not validate_entity(wagon.entity) then
icw.wagons[unit_number] = nil
Public.request_reconstruction(icw)
goto cont
return
end
local locomotive = WPT.get('locomotive')
if not (locomotive and locomotive.valid) then
return
end
if not wagon.surface then
@ -981,8 +986,13 @@ function Public.reconstruct_all_trains(icw)
end
local carriages = wagon.entity.train.carriages
Public.construct_train(icw, wagon.entity, carriages)
::cont::
for _, carriage in pairs(carriages) do
if not icw.wagons[carriage.unit_number] then
Public.create_wagon(icw, carriage)
end
end
Public.construct_train(icw, locomotive, carriages)
end
delete_empty_surfaces(icw)
return true