mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
fix for train disconnections
This commit is contained in:
parent
c928626318
commit
2e2aa87de5
@ -35,7 +35,6 @@ function Public.locomotive_spawn(surface, position)
|
||||
})
|
||||
|
||||
global.locomotive.color = {0, 255, 0}
|
||||
global.locomotive.minable = false
|
||||
global.locomotive_cargo.minable = false
|
||||
|
||||
for y = -1, 0, 0.05 do
|
||||
@ -45,6 +44,7 @@ function Public.locomotive_spawn(surface, position)
|
||||
|
||||
Immersive_cargo_wagons.register_wagon(global.locomotive)
|
||||
local wagon = Immersive_cargo_wagons.register_wagon(global.locomotive_cargo)
|
||||
wagon.entity_count = 999
|
||||
|
||||
local surface = wagon.surface
|
||||
local center_position = {x = wagon.area.left_top.x + (wagon.area.right_bottom.x - wagon.area.left_top.x) * 0.5, y = wagon.area.left_top.y + (wagon.area.right_bottom.y - wagon.area.left_top.y) * 0.5}
|
||||
|
@ -7,7 +7,7 @@ local table_remove = table.remove
|
||||
local math_round = math.round
|
||||
local math_random = math.random
|
||||
|
||||
local function request_reconstruction(icw)
|
||||
function Public.request_reconstruction(icw)
|
||||
icw.rebuild_tick = game.tick + 30
|
||||
end
|
||||
|
||||
@ -162,7 +162,7 @@ function Public.kill_wagon(icw, entity)
|
||||
surface.set_tiles({{name = "out-of-map", position = tile.position}}, true)
|
||||
end
|
||||
icw.wagons[entity.unit_number] = nil
|
||||
request_reconstruction(icw)
|
||||
Public.request_reconstruction(icw)
|
||||
end
|
||||
|
||||
function Public.create_room_surface(icw, unit_number)
|
||||
@ -304,7 +304,7 @@ function Public.create_wagon(icw, created_entity)
|
||||
entity_count = 0,
|
||||
}
|
||||
Public.create_wagon_room(icw, icw.wagons[created_entity.unit_number])
|
||||
request_reconstruction(icw)
|
||||
Public.request_reconstruction(icw)
|
||||
return icw.wagons[created_entity.unit_number]
|
||||
end
|
||||
|
||||
|
@ -80,6 +80,8 @@ local function on_gui_closed(event)
|
||||
local entity = event.entity
|
||||
if not entity then return end
|
||||
if not entity.valid then return end
|
||||
if not entity.unit_number then return end
|
||||
if not icw.wagons[entity.unit_number] then return end
|
||||
Functions.kill_minimap(game.players[event.player_index])
|
||||
end
|
||||
|
||||
@ -97,6 +99,10 @@ local function on_player_died(event)
|
||||
Functions.kill_minimap(game.players[event.player_index])
|
||||
end
|
||||
|
||||
local function on_train_created(event)
|
||||
Functions.request_reconstruction(icw)
|
||||
end
|
||||
|
||||
local function on_tick()
|
||||
local tick = game.tick
|
||||
if tick % 60 == 0 then Functions.item_transfer(icw) end
|
||||
@ -125,6 +131,7 @@ Event.add(defines.events.on_tick, on_tick)
|
||||
Event.add(defines.events.on_player_driving_changed_state, on_player_driving_changed_state)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||
Event.add(defines.events.on_train_created, on_train_created)
|
||||
Event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
|
||||
Event.add(defines.events.on_player_died, on_player_died)
|
||||
--Event.add(defines.events.on_player_created, on_player_created)
|
||||
|
Loading…
Reference in New Issue
Block a user