1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00

mtn fortress tweaks

This commit is contained in:
Gerkiz 2020-12-02 09:20:35 +01:00
parent 8521eb4278
commit 9f4890c218
7 changed files with 30 additions and 42 deletions

View File

@ -109,14 +109,12 @@ local function do_turret_energy()
for index = 1, #power_sources do
local ps_data = power_sources[index]
if not (ps_data or ps_data.valid) then
if not (ps_data and ps_data.valid) then
fast_remove(power_sources, index)
return
end
if ps_data and ps_data.valid then
ps_data.energy = 0xfffff
end
ps_data.energy = 0xfffff
end
end

View File

@ -315,10 +315,7 @@ local function kick_players_from_surface(ic, car)
if validate_entity(main_surface) then
for _, e in pairs(car.surface.find_entities_filtered({area = car.area})) do
if validate_entity(e) and e.name == 'character' and e.player then
e.player.teleport(
main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5),
main_surface
)
e.player.teleport(main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), main_surface)
end
end
end
@ -360,10 +357,7 @@ local function kick_player_from_surface(ic, player, target)
if p then
target.teleport(p, car.entity.surface)
else
target.teleport(
main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5),
main_surface
)
target.teleport(main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), main_surface)
end
target.print('You were kicked out of ' .. player.name .. ' vehicle.', Color.warning)
end
@ -590,10 +584,7 @@ function Public.save_car(ic, event)
}
Task.set_timeout_in_ticks(10, remove_car, params)
if ic.restore_on_theft then
local e =
player.surface.create_entity(
{name = car.name, position = position, force = player.force, create_build_effect_smoke = false}
)
local e = player.surface.create_entity({name = car.name, position = position, force = player.force, create_build_effect_smoke = false})
e.health = health
restore_surface(ic, p, e)
else
@ -932,13 +923,16 @@ function Public.use_door_with_entity(ic, player, door)
end
function Public.item_transfer(ic)
for _, car in pairs(ic.cars) do
if validate_entity(car.entity) then
if car.transfer_entities then
for k, e in pairs(car.transfer_entities) do
if validate_entity(e) then
transfer_functions[e.name](car, e)
end
local car
ic.current_car_index, car = next(ic.cars, ic.current_car_index)
if not car then
return
end
if validate_entity(car.entity) then
if car.transfer_entities then
for k, e in pairs(car.transfer_entities) do
if validate_entity(e) then
transfer_functions[e.name](car, e)
end
end
end

View File

@ -81,7 +81,7 @@ local function on_tick()
local ic = IC.get()
local tick = game.tick
if tick % 60 == 0 then
if tick % 10 == 1 then
Functions.item_transfer(ic)
end

View File

@ -30,6 +30,7 @@ function Public.reset()
this.restore_on_theft = false
this.doors = {}
this.cars = {}
this.current_car_index = nil
this.renders = {}
this.saved_surfaces = {}
this.allowed_surface = 'nauvis'

View File

@ -36,10 +36,7 @@ local function kick_players_from_surface(wagon)
if validate_entity(main_surface) then
for _, e in pairs(wagon.surface.find_entities_filtered({area = wagon.area})) do
if validate_entity(e) and e.name == 'character' and e.player then
e.player.teleport(
main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5),
main_surface
)
e.player.teleport(main_surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(main_surface), 3, 0, 5), main_surface)
end
end
end
@ -734,10 +731,7 @@ local function move_room_to_train(icw, train, wagon)
train.top_y = destination_area.right_bottom.y
if
destination_area.left_top.x == wagon.area.left_top.x and destination_area.left_top.y == wagon.area.left_top.y and
wagon.surface.name == train.surface.name
then
if destination_area.left_top.x == wagon.area.left_top.x and destination_area.left_top.y == wagon.area.left_top.y and wagon.surface.name == train.surface.name then
return
end
kick_players_from_surface(wagon)
@ -842,15 +836,15 @@ function Public.reconstruct_all_trains(icw)
end
function Public.item_transfer(icw)
for _, wagon in pairs(icw.wagons) do
if not validate_entity(wagon.entity) then
return
end
if wagon.transfer_entities then
for k, e in pairs(wagon.transfer_entities) do
if validate_entity(e) then
transfer_functions[e.name](wagon, e)
end
local wagon
icw.current_wagon_index, wagon = next(icw.wagons, icw.current_wagon_index)
if not wagon then
return
end
if validate_entity(wagon.entity) and wagon.transfer_entities then
for k, e in pairs(wagon.transfer_entities) do
if validate_entity(e) then
transfer_functions[e.name](wagon, e)
end
end
end

View File

@ -95,7 +95,7 @@ local function on_tick()
local icw = ICW.get()
local tick = game.tick
if tick % 60 == 0 then
if tick % 10 == 1 then
Functions.item_transfer(icw)
end
if tick % 240 == 0 then

View File

@ -23,6 +23,7 @@ function Public.reset()
end
this.doors = {}
this.wagons = {}
this.current_wagon_index = nil
this.trains = {}
this.players = {}
this.surfaces = {}