Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mtn: Fix bugs and small changes #490

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions maps/mountain_fortress_v3/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ Public.disable_minable_callback =
Task.register(
function (entity)
if entity and entity.valid then
entity.minable = false
entity.minable_flag = false
end
end
)
Expand All @@ -953,7 +953,7 @@ Public.disable_minable_and_ICW_callback =
function (entity)
if entity and entity.valid then
local wagons_in_the_wild = Public.get('wagons_in_the_wild')
entity.minable = false
entity.minable_flag = false
entity.destructible = false
ICW.register_wagon(entity)

Expand All @@ -967,7 +967,7 @@ Public.disable_destructible_callback =
function (entity)
if entity and entity.valid then
entity.destructible = false
entity.minable = false
entity.minable_flag = false
end
end
)
Expand Down Expand Up @@ -1059,7 +1059,7 @@ Public.magic_item_crafting_callback =
return
end

entity.minable = false
entity.minable_flag = false
entity.destructible = false
entity.operable = false

Expand Down Expand Up @@ -1122,7 +1122,7 @@ Public.magic_item_crafting_callback_weighted =
entity.destructible = false
end

entity.minable = false
entity.minable_flag = false
entity.operable = false

local p = entity.position
Expand Down Expand Up @@ -2354,6 +2354,28 @@ function Public.set_spawn_position()
::continue::
end

local function on_marked_for_deconstruction(event)
local entity = event.entity
if not entity or not entity.valid then
return
end

if not event.player_index then
return
end

local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end

if player.controller_type == defines.controllers.remote then
entity.cancel_deconstruction(player.force, player)
player.print("You cannot deconstruct while in remove view!", { r = 1, g = 0.5, b = 0.5 })
end
end


function Public.on_player_joined_game(event)
local players = Public.get('players')
local player = game.players[event.player_index]
Expand All @@ -2362,7 +2384,7 @@ function Public.on_player_joined_game(event)
Difficulty.clear_top_frame(player)
Modifiers.update_player_modifiers(player)
local active_surface_index = Public.get('active_surface_index')
local surface = game.surfaces[active_surface_index or 'nauvis']
local surface = game.surfaces[active_surface_index or 'fortress']

local current_task = Public.get('current_task')
if not current_task.done then
Expand Down Expand Up @@ -2964,6 +2986,7 @@ Event.add(de.on_player_driving_changed_state, on_player_driving_changed_state)
Event.add(de.on_pre_player_toggled_map_editor, on_pre_player_toggled_map_editor)
Event.add(de.on_player_cursor_stack_changed, on_player_cursor_stack_changed)
Event.add(de.on_chart_tag_added, on_chart_tag_added)
Event.add(de.on_marked_for_deconstruction, on_marked_for_deconstruction)
Event.on_nth_tick(10, tick)
Event.add(WD.events.on_wave_created, on_wave_created)
Event.add(WD.events.on_primary_target_missing, on_primary_target_missing)
Expand Down
18 changes: 9 additions & 9 deletions maps/mountain_fortress_v3/ic/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ local enable_car_to_be_mined =
local entity = event.entity
local owner_name = event.owner_name
if entity and entity.valid then
entity.minable = true
entity.minable_flag = true
local msg = owner_name .. "'s vehicle is now minable!"
local p = {
position = entity.position
Expand Down Expand Up @@ -706,7 +706,7 @@ local function construct_doors(car)
}
)
e.destructible = false
e.minable = false
e.minable_flag = false
e.operable = false
e.get_inventory(defines.inventory.fuel).insert({ name = 'coal', count = 1 })
if type(car.entity) == 'boolean' then
Expand Down Expand Up @@ -1034,7 +1034,7 @@ function Public.kill_car_but_save_surface(entity)
kick_players_out_of_vehicles(car)
kick_players_from_surface(car)

car.entity.minable = true
car.entity.minable_flag = true

local trust_system = IC.get('trust_system')
local owner = car.owner
Expand Down Expand Up @@ -1226,7 +1226,7 @@ function Public.create_car_room(car)
}
)
e1.destructible = false
e1.minable = false
e1.minable_flag = false

local e2 =
surface.create_entity(
Expand All @@ -1238,7 +1238,7 @@ function Public.create_car_room(car)
}
)
e2.destructible = false
e2.minable = false
e2.minable_flag = false
car.transfer_entities = { e1, e2 }
end

Expand Down Expand Up @@ -1445,7 +1445,7 @@ function Public.use_door_with_entity(player, door)
state = 'add'
}
)
car.entity.minable = false
car.entity.minable_flag = false
end

if not validate_entity(surface) then
Expand Down Expand Up @@ -1476,7 +1476,7 @@ function Public.use_door_with_entity(player, door)
state = 'remove'
}
)
car.entity.minable = true
car.entity.minable_flag = true
end
local surface = car.entity.surface
local x_vector = (door.position.x / math.abs(door.position.x)) * 2
Expand Down Expand Up @@ -1514,7 +1514,7 @@ function Public.on_player_died(player)
if car.owner == player.name then
local entity = car.entity
if entity and entity.valid then
entity.minable = false
entity.minable_flag = false
end
end
end
Expand All @@ -1526,7 +1526,7 @@ function Public.on_player_respawned(player)
if car.owner == player.name then
local entity = car.entity
if entity and entity.valid then
entity.minable = true
entity.minable_flag = true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion maps/mountain_fortress_v3/ic/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ local function transfer_player_table(player, new_player)
end
car.owner = new_player.name

car.entity.minable = true
car.entity.minable_flag = true

Functions.render_owner_text(renders, player, car.entity, new_player)

Expand Down
2 changes: 1 addition & 1 deletion maps/mountain_fortress_v3/ic/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Public.reset()
this.renders = {}
this.saved_surfaces = {}
this.surfaces_deleted_by_button = {}
this.allowed_surface = 'nauvis'
this.allowed_surface = 'fortress'
this.trust_system = {}
this.players = {}
this.players_persistent = {}
Expand Down
45 changes: 20 additions & 25 deletions maps/mountain_fortress_v3/icw/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ local deepcopy = table.deepcopy
local random = math.random
local sqrt = math.sqrt

local is_modded = script.active_mods['MtnFortressAddons'] or false

local out_of_map_tile = 'out-of-map'
if is_modded then
out_of_map_tile = 'void-tile'
end

local scenario_name = WPT.scenario_name
local fallout_width = 64
Expand Down Expand Up @@ -57,67 +52,67 @@ local add_chests_to_wagon_token =
return error('Surface was invalid, please check this out!')
end
left_1.destructible = false
left_1.minable = false
left_1.minable_flag = false

local left_2 = LinkedChests.add(surface, { position1[1] - 1, position1[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_2')
left_2.destructible = false
left_2.minable = false
left_2.minable_flag = false

local left_3 = LinkedChests.add(surface, { position1[1] - 2, position1[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_3')
left_3.destructible = false
left_3.minable = false
left_3.minable_flag = false

local left_4 = LinkedChests.add(surface, { position1[1] - 3, position1[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_4')
left_4.destructible = false
left_4.minable = false
left_4.minable_flag = false

local right_1 = LinkedChests.add(surface, position2, 'player', 'wagon_' .. wagon.entity.unit_number .. '_5')
right_1.destructible = false
right_1.minable = false
right_1.minable_flag = false

local right_2 = LinkedChests.add(surface, { position2[1] + 1, position2[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_6')
right_2.destructible = false
right_2.minable = false
right_2.minable_flag = false

local right_3 = LinkedChests.add(surface, { position2[1] + 2, position2[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_7')
right_3.destructible = false
right_3.minable = false
right_3.minable_flag = false

local right_4 = LinkedChests.add(surface, { position2[1] + 3, position2[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_8')
right_4.destructible = false
right_4.minable = false
right_4.minable_flag = false

local bottom_left_1 = LinkedChests.add(surface, position3, 'player', 'wagon_' .. wagon.entity.unit_number .. '_9')
bottom_left_1.destructible = false
bottom_left_1.minable = false
bottom_left_1.minable_flag = false

local bottom_left_2 = LinkedChests.add(surface, { position3[1] - 1, position3[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_10')
bottom_left_2.destructible = false
bottom_left_2.minable = false
bottom_left_2.minable_flag = false

local bottom_left_3 = LinkedChests.add(surface, { position3[1] - 2, position3[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_11')
bottom_left_3.destructible = false
bottom_left_3.minable = false
bottom_left_3.minable_flag = false

local bottom_left_4 = LinkedChests.add(surface, { position3[1] - 3, position3[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_12')
bottom_left_4.destructible = false
bottom_left_4.minable = false
bottom_left_4.minable_flag = false

local bottom_right_1 = LinkedChests.add(surface, position4, 'player', 'wagon_' .. wagon.entity.unit_number .. '_13')
bottom_right_1.destructible = false
bottom_right_1.minable = false
bottom_right_1.minable_flag = false

local bottom_right_2 = LinkedChests.add(surface, { position4[1] + 1, position4[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_14')
bottom_right_2.destructible = false
bottom_right_2.minable = false
bottom_right_2.minable_flag = false

local bottom_right_3 = LinkedChests.add(surface, { position4[1] + 2, position4[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_15')
bottom_right_3.destructible = false
bottom_right_3.minable = false
bottom_right_3.minable_flag = false

local bottom_right_4 = LinkedChests.add(surface, { position4[1] + 3, position4[2] }, 'player', 'wagon_' .. wagon.entity.unit_number .. '_16')
bottom_right_4.destructible = false
bottom_right_4.minable = false
bottom_right_4.minable_flag = false
end
)

Expand Down Expand Up @@ -227,7 +222,7 @@ local function teleport_char(position, destination_area, wagon)
player.physical_position.x,
player.physical_position.y + (destination_area.left_top.y - wagon.area.left_top.y)
}
player.teleport({ 0, 0 }, game.surfaces.nauvis)
player.teleport({ 0, 0 }, game.surfaces.fortress)
end
end
end
Expand Down Expand Up @@ -513,7 +508,7 @@ local function construct_wagon_doors(icw, wagon)
}
)
e.destructible = false
e.minable = false
e.minable_flag = false
e.operable = false
e.get_inventory(defines.inventory.fuel).insert({ name = 'coal', count = 1 })
icw.doors[e.unit_number] = wagon.entity.unit_number
Expand Down Expand Up @@ -686,7 +681,7 @@ function Public.create_wagon_room(icw, wagon)
}
)
e.destructible = false
e.minable = false
e.minable_flag = false
wagon.transfer_entities = { e }
return
end
Expand Down Expand Up @@ -740,7 +735,7 @@ function Public.migrate_wagon(icw, source, target)
return
end

target.minable = false
target.minable_flag = false

local target_wagon = target.unit_number
local source_wagon = source.unit_number
Expand Down
Loading
Loading