From a51d3618244ce120a7d37c550239ddbfa7381957 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Apr 2022 12:00:13 +0200 Subject: [PATCH 01/24] tweaks and changes --- comfy_panel/score.lua | 14 +++-- maps/mountain_fortress_v3/functions.lua | 83 +++++-------------------- modules/rpg.lua | 20 ++---- modules/rpg/functions.lua | 27 ++++++-- modules/rpg/main.lua | 35 +++++------ modules/wave_defense/pause_waves.lua | 7 ++- 6 files changed, 73 insertions(+), 113 deletions(-) diff --git a/comfy_panel/score.lua b/comfy_panel/score.lua index b6465e9c..0dd97163 100644 --- a/comfy_panel/score.lua +++ b/comfy_panel/score.lua @@ -1,10 +1,12 @@ --scoreboard by mewmew +-- modified by Gerkiz local Event = require 'utils.event' local Global = require 'utils.global' local Tabs = require 'comfy_panel.main' local SpamProtection = require 'utils.spam_protection' local Token = require 'utils.token' +local format_number = require 'util'.format_number local Public = {} local this = { @@ -129,7 +131,7 @@ local function add_global_stats(frame, player) l.style.font_color = {r = 175, g = 75, b = 255} l.style.minimal_width = 140 - local rocketsLaunched_label = t.add {type = 'label', caption = player.force.rockets_launched} + local rocketsLaunched_label = t.add {type = 'label', caption = format_number(player.force.rockets_launched, true)} rocketsLaunched_label.style.font = 'default-listbox' rocketsLaunched_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} rocketsLaunched_label.style.minimal_width = 123 @@ -139,7 +141,7 @@ local function add_global_stats(frame, player) bugs_dead_label.style.font_color = {r = 0.90, g = 0.3, b = 0.3} bugs_dead_label.style.minimal_width = 100 - local killcount_label = t.add {type = 'label', caption = tostring(get_total_biter_killcount(player.force))} + local killcount_label = t.add {type = 'label', caption = format_number(tonumber(get_total_biter_killcount(player.force)), true)} killcount_label.style.font = 'default-listbox' killcount_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} killcount_label.style.minimal_width = 145 @@ -227,10 +229,10 @@ local function show_score(data) } local lines = { {caption = entry.name, color = special_color}, - {caption = tostring(entry.killscore)}, - {caption = tostring(entry.deaths)}, - {caption = tostring(entry.built_entities)}, - {caption = tostring(entry.mined_entities)} + {caption = format_number(tonumber(entry.killscore), true)}, + {caption = format_number(tonumber(entry.deaths), true)}, + {caption = format_number(tonumber(entry.built_entities), true)}, + {caption = format_number(tonumber(entry.mined_entities), true)} } local default_color = {r = 0.9, g = 0.9, b = 0.9} diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 36cbf75e..2afb295a 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -149,19 +149,6 @@ local function do_refill_turrets() end end ---[[ local function do_turret_energy() - local power_sources = this.power_sources - - for index = 1, #power_sources do - local ps_data = power_sources[index] - if not (ps_data and ps_data.valid) then - fast_remove(power_sources, index) - return - end - - ps_data.energy = 0xfffff - end -end ]] local function do_magic_crafters() local magic_crafters = this.magic_crafters local limit = #magic_crafters @@ -367,7 +354,7 @@ local function add_magic_crafter_output(entity, output, distance) local fluidbox_index = output.fluidbox_index local data = { entity = entity, - last_tick = round(game.tick), + last_tick = game.tick, base_rate = round(rate, 8), rate = round(rate, 8), item = output.item, @@ -1139,57 +1126,22 @@ function Public.boost_difficulty() local force = game.forces.player - if name == "I'm too young to die" then - force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5 - force.character_running_speed_modifier = 0.15 - force.manual_crafting_speed_modifier = 0.15 - WPT.set('coin_amount', 1) - WPT.set('upgrades').flame_turret.limit = 12 - WPT.set('upgrades').landmine.limit = 50 - WPT.set('locomotive_health', 10000) - WPT.set('locomotive_max_health', 10000) - WPT.set('bonus_xp_on_join', 500) - WD.set('next_wave', game.tick + 3600 * 15) - WPT.set('spidertron_unlocked_at_zone', 10) - WD.set_normal_unit_current_health(1.0) - WD.set_unit_health_increment_per_wave(0.15) - WD.set_boss_unit_current_health(2) - WD.set_boss_health_increment_per_wave(1.5) - WPT.set('difficulty_set', true) - elseif name == 'Hurt me plenty' then - force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.25 - force.character_running_speed_modifier = 0.1 - force.manual_crafting_speed_modifier = 0.1 - WPT.set('coin_amount', 2) - WPT.set('upgrades').flame_turret.limit = 10 - WPT.set('upgrades').landmine.limit = 50 - WPT.set('locomotive_health', 7000) - WPT.set('locomotive_max_health', 7000) - WPT.set('bonus_xp_on_join', 300) - WD.set('next_wave', game.tick + 3600 * 8) - WPT.set('spidertron_unlocked_at_zone', 8) - WD.set_normal_unit_current_health(1.6) - WD.set_unit_health_increment_per_wave(0.5) - WD.set_boss_unit_current_health(3) - WD.set_boss_health_increment_per_wave(5) - WPT.set('difficulty_set', true) - elseif name == 'Ultra-violence' then - force.character_running_speed_modifier = 0 - force.manual_crafting_speed_modifier = 0 - WPT.set('coin_amount', 4) - WPT.set('upgrades').flame_turret.limit = 3 - WPT.set('upgrades').landmine.limit = 10 - WPT.set('locomotive_health', 5000) - WPT.set('locomotive_max_health', 5000) - WPT.set('bonus_xp_on_join', 50) - WD.set('next_wave', game.tick + 3600 * 5) - WPT.set('spidertron_unlocked_at_zone', 6) - WD.set_normal_unit_current_health(2) - WD.set_unit_health_increment_per_wave(1) - WD.set_boss_unit_current_health(4) - WD.set_boss_health_increment_per_wave(10) - WPT.set('difficulty_set', true) - end + force.manual_mining_speed_modifier = force.manual_mining_speed_modifier + 0.5 + force.character_running_speed_modifier = 0.15 + force.manual_crafting_speed_modifier = 0.15 + WPT.set('coin_amount', 1) + WPT.set('upgrades').flame_turret.limit = 12 + WPT.set('upgrades').landmine.limit = 50 + WPT.set('locomotive_health', 10000) + WPT.set('locomotive_max_health', 10000) + WPT.set('bonus_xp_on_join', 500) + WD.set('next_wave', game.tick + 3600 * 15) + WPT.set('spidertron_unlocked_at_zone', 10) + WD.set_normal_unit_current_health(1.0) + WD.set_unit_health_increment_per_wave(0.15) + WD.set_boss_unit_current_health(2) + WD.set_boss_health_increment_per_wave(1.5) + WPT.set('difficulty_set', true) end function Public.set_spawn_position() @@ -1556,6 +1508,5 @@ Event.add(defines.events.on_player_changed_position, on_player_changed_position) Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) Event.add(defines.events.on_player_respawned, on_player_respawned) Event.on_nth_tick(10, tick) --- Event.on_nth_tick(5, do_turret_energy) return Public diff --git a/modules/rpg.lua b/modules/rpg.lua index 0635f7ce..d47ef18a 100644 --- a/modules/rpg.lua +++ b/modules/rpg.lua @@ -119,7 +119,7 @@ local function get_one_punch_chance(player) if rpg_t[player.index].strength < 100 then return 0 end - local chance = math.round(rpg_t[player.index].strength * 0.01, 1) + local chance = math.round(rpg_t[player.index].strength * 0.007, 1) if chance > 100 then chance = 100 end @@ -152,8 +152,8 @@ end local function update_player_stats(player) local strength = rpg_t[player.index].strength - 10 - P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', math.round(strength * 0.2, 3)) - P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', math.round(strength * 0.008, 3)) + P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', math.round(strength * 0.1, 3)) + P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', math.round(strength * 0.007, 3)) local magic = rpg_t[player.index].magic - 10 local v = magic * 0.15 @@ -831,10 +831,7 @@ local function on_entity_damaged(event) if not event.entity.valid then return end - if - event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].valid_for_read and - event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].valid_for_read - then + if event.cause.get_inventory(defines.inventory.character_ammo)[event.cause.selected_gun_index].valid_for_read and event.cause.get_inventory(defines.inventory.character_guns)[event.cause.selected_gun_index].valid_for_read then return end if not event.cause.player then @@ -873,9 +870,7 @@ local function on_entity_damaged(event) event.cause.surface.create_entity({name = 'blood-explosion-huge', position = event.entity.position}) else damage = damage * math_random(100, 125) * 0.01 - event.cause.player.create_local_flying_text( - {text = math.floor(damage), position = event.entity.position, color = {150, 150, 150}, time_to_live = 90, speed = 2} - ) + event.cause.player.create_local_flying_text({text = math.floor(damage), position = event.entity.position, color = {150, 150, 150}, time_to_live = 90, speed = 2}) end --Handle the custom health pool of the biter health booster, if it is used in the map. @@ -960,10 +955,7 @@ local function on_pre_player_mined_item(event) end local player = game.players[event.player_index] - if - rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and - rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y - then + if rpg_t[player.index].last_mined_entity_position.x == event.entity.position.x and rpg_t[player.index].last_mined_entity_position.y == event.entity.position.y then return end rpg_t[player.index].last_mined_entity_position.x = entity.position.x diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index 005be6a9..84c07c63 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -519,8 +519,8 @@ function Public.update_player_stats(player) local rpg_extra = Public.get('rpg_extra') local rpg_t = Public.get_value_from_player(player.index) local strength = rpg_t.strength - 10 - P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.2, 3)) - P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.007, 3)) + P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.1, 3)) + P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.006, 3)) P.update_single_modifier(player, 'character_maximum_following_robot_count_bonus', 'rpg', round(strength / 2 * 0.03, 3)) local magic = rpg_t.magicka - 10 @@ -555,7 +555,24 @@ function Public.level_up_effects(player) } player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}}) end - player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.40} + player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.50} +end + +function Public.cast_spell(player, failed) + local position = {x = player.position.x - 0.75, y = player.position.y - 1} + local b = 0.75 + if not failed then + for _ = 1, 3, 1 do + local p = { + (position.x + 0.4) + (b * -1 + math.random(0, b * 20) * 0.1), + position.y + (b * -1 + math.random(0, b * 20) * 0.1) + } + player.surface.create_entity({name = 'flying-text', position = p, text = '✔️', color = {255, math.random(0, 100), 0}}) + end + player.play_sound {path = 'utility/scenario_message', volume_modifier = 0.50} + else + player.play_sound {path = 'utility/cannot_build', volume_modifier = 0.50} + end end function Public.xp_effects(player) @@ -569,7 +586,7 @@ function Public.xp_effects(player) } player.surface.create_entity({name = 'flying-text', position = p, text = '✚', color = {255, math.random(0, 100), 0}}) end - player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.40} + player.play_sound {path = 'utility/achievement_unlocked', volume_modifier = 0.50} end function Public.get_range_modifier(player) @@ -682,7 +699,7 @@ function Public.get_one_punch_chance(player) if rpg_t.strength < 100 then return 0 end - local chance = round(rpg_t.strength * 0.012, 1) + local chance = round(rpg_t.strength * 0.007, 1) if chance > 100 then chance = 100 end diff --git a/modules/rpg/main.lua b/modules/rpg/main.lua index 38fdaaa5..dcf3522e 100644 --- a/modules/rpg/main.lua +++ b/modules/rpg/main.lua @@ -680,10 +680,7 @@ local function on_entity_damaged(event) local original_damage_amount = event.original_damage_amount local final_damage_amount = event.final_damage_amount - if - cause.get_inventory(defines.inventory.character_ammo)[cause.selected_gun_index].valid_for_read or - cause.get_inventory(defines.inventory.character_guns)[cause.selected_gun_index].valid_for_read - then + if cause.get_inventory(defines.inventory.character_ammo)[cause.selected_gun_index].valid_for_read or cause.get_inventory(defines.inventory.character_guns)[cause.selected_gun_index].valid_for_read then local is_explosive_bullets_enabled = Public.get_explosive_bullets() if is_explosive_bullets_enabled then Public.explosive_bullets(event) @@ -1160,7 +1157,7 @@ local function on_player_used_capsule(event) local p = player.print if rpg_t.last_spawned >= game.tick then - return p(({'rpg_main.mana_casting_too_fast', player.name}), Color.warning) + return Public.cast_spell(player, true) end local mana = rpg_t.mana @@ -1183,7 +1180,7 @@ local function on_player_used_capsule(event) } if rpg_t.level < object.level then - return p(({'rpg_main.low_level'}), Color.fail) + return Public.cast_spell(player, true) end if not object.enabled then @@ -1191,12 +1188,12 @@ local function on_player_used_capsule(event) end if not Math2D.bounding_box.contains_point(area, player.position) then - player.print(({'rpg_main.not_inside_pos'}), Color.fail) + Public.cast_spell(player, true) return end if mana < object.mana_cost then - return p(({'rpg_main.no_mana'}), Color.fail) + return Public.cast_spell(player, true) end local target_pos @@ -1223,11 +1220,11 @@ local function on_player_used_capsule(event) if object.entityName == 'suicidal_comfylatron' then Public.suicidal_comfylatron(position, surface) - p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success) + Public.cast_spell(player) Public.remove_mana(player, object.mana_cost) elseif object.entityName == 'repair_aoe' then - local ents = Public.repair_aoe(player, position) - p(({'rpg_main.repair_aoe', ents}), Color.success) + Public.repair_aoe(player, position) + Public.cast_spell(player) Public.remove_mana(player, object.mana_cost) elseif object.entityName == 'pointy_explosives' then local entities = @@ -1245,11 +1242,9 @@ local function on_player_used_capsule(event) if detonate_chest and detonate_chest.valid then local success = Explosives.detonate_chest(detonate_chest) if success then - player.print(({'rpg_main.detonate_chest'}), Color.success) Public.remove_mana(player, object.mana_cost) - else - player.print(({'rpg_main.detonate_chest_failed'}), Color.fail) end + Public.cast_spell(player) end elseif object.entityName == 'warp-gate' then local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5) @@ -1262,10 +1257,10 @@ local function on_player_used_capsule(event) Public.remove_mana(player, 999999) Public.damage_player_over_time(player, random(8, 16)) player.play_sound {path = 'utility/armor_insert', volume_modifier = 1} - p(({'rpg_main.warped_ok'}), Color.info) + Public.cast_spell(player) elseif object.capsule then -- spawn in capsules i.e objects that are usable with mouse-click player.insert({name = object.entityName, count = object.amount}) - p(({'rpg_main.object_spawned', object.entityName}), Color.success) + Public.cast_spell(player) Public.remove_mana(player, object.mana_cost) elseif projectile_types[object.entityName] then -- projectiles for i = 1, object.amount do @@ -1280,12 +1275,12 @@ local function on_player_used_capsule(event) end end end - p(({'rpg_main.object_spawned', object.entityName}), Color.success) + Public.cast_spell(player) Public.remove_mana(player, object.mana_cost) else if object.target then -- rockets and such surface.create_entity({name = object.entityName, position = position, force = force, target = target_pos, speed = 1}) - p(({'rpg_main.object_spawned', object.entityName}), Color.success) + Public.cast_spell(player) Public.remove_mana(player, object.mana_cost) elseif surface.can_place_entity {name = object.entityName, position = position} then if object.biter then @@ -1311,9 +1306,9 @@ local function on_player_used_capsule(event) e.direction = player.character.direction Public.remove_mana(player, object.mana_cost) end - p(({'rpg_main.object_spawned', object.entityName}), Color.success) + Public.cast_spell(player) else - p(({'rpg_main.out_of_reach'}), Color.fail) + Public.cast_spell(player, true) return end end diff --git a/modules/wave_defense/pause_waves.lua b/modules/wave_defense/pause_waves.lua index b27c8b51..1a1e5ad2 100644 --- a/modules/wave_defense/pause_waves.lua +++ b/modules/wave_defense/pause_waves.lua @@ -69,8 +69,7 @@ function Public.main_gui(player, text) inside_table.add( { type = 'label', - caption = 'We have played for ' .. - Server.format_time(game.ticks_played) .. ' now.\nIf you want to take a quick break,\nplease vote to pause the waves for 5 minutes.' + caption = 'We have played for ' .. Server.format_time(game.ticks_played) .. ' now.\nIf you want to take a quick break,\nplease vote to pause the waves for 5 minutes.' } ) local info_sub_style = info_sub.style @@ -200,6 +199,10 @@ Event.on_nth_tick( return end + if Server.format_time(game.ticks_played) == 0 then + return + end + local greeting = random_greetings[random(1, random_greetings_size)] local players = game.connected_players From f74e99f3f417f08f5ee78516883a5e7d13bfdfe1 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Apr 2022 19:27:46 +0200 Subject: [PATCH 02/24] refactor gui --- maps/mountain_fortress_v3/breached_wall.lua | 14 +- maps/mountain_fortress_v3/functions.lua | 22 +-- maps/mountain_fortress_v3/mystical_chest.lua | 1 - .../resource_generator.lua | 134 ++++++++++++------ maps/mountain_fortress_v3/terrain.lua | 14 +- 5 files changed, 114 insertions(+), 71 deletions(-) diff --git a/maps/mountain_fortress_v3/breached_wall.lua b/maps/mountain_fortress_v3/breached_wall.lua index 16fca28e..5df020bc 100644 --- a/maps/mountain_fortress_v3/breached_wall.lua +++ b/maps/mountain_fortress_v3/breached_wall.lua @@ -186,13 +186,13 @@ local compare_player_and_train = function(player, entity) if c_y - t_y <= spidertron_warning_position then local surface = player.surface surface.create_entity( - { - name = 'flying-text', - position = position, - text = 'Warning!!! You are too far from the train!!!', - color = {r = 0.9, g = 0.0, b = 0.0} - } - ) + { + name = 'flying-text', + position = position, + text = 'Warning!!! You are too far from the train!!!', + color = {r = 0.9, g = 0.0, b = 0.0} + } + ) end if c_y - t_y <= gap_between_zones.neg_gap then diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 2afb295a..2bfef1a6 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -533,10 +533,12 @@ Public.magic_item_crafting_callback = local force = game.forces.player local tech = callback_data.tech - if tech then - if not force.technologies[tech].researched then - entity.destroy() - return + if not callback_data.testing then + if tech then + if not force.technologies[tech].researched then + entity.destroy() + return + end end end @@ -603,11 +605,13 @@ Public.magic_item_crafting_callback_weighted = local force = game.forces.player local tech = stack.tech - if tech then - if force.technologies[tech] then - if not force.technologies[tech].researched then - entity.destroy() - return + if not callback_data.testing then + if tech then + if force.technologies[tech] then + if not force.technologies[tech].researched then + entity.destroy() + return + end end end end diff --git a/maps/mountain_fortress_v3/mystical_chest.lua b/maps/mountain_fortress_v3/mystical_chest.lua index 1b029dc2..7507b535 100644 --- a/maps/mountain_fortress_v3/mystical_chest.lua +++ b/maps/mountain_fortress_v3/mystical_chest.lua @@ -157,7 +157,6 @@ local item_worths = { ['explosive-uranium-cannon-shell'] = 64, ['rocket'] = 8, ['explosive-rocket'] = 8, - ['atomic-bomb'] = 16384, ['flamethrower-ammo'] = 32, ['grenade'] = 16, ['cluster-grenade'] = 64, diff --git a/maps/mountain_fortress_v3/resource_generator.lua b/maps/mountain_fortress_v3/resource_generator.lua index aead9ed7..dc6fad48 100644 --- a/maps/mountain_fortress_v3/resource_generator.lua +++ b/maps/mountain_fortress_v3/resource_generator.lua @@ -8,11 +8,24 @@ local types = { 'furnace' } +local testing = false + +local testing_loot = { + { + stack = { + recipe = 'speed-module-2', + tech = 'speed-module-2', + output = {item = 'speed-module-2', min_rate = 1 / 8 / 60 / 2, distance_factor = 1 / 8 / 60 / 20480} + }, + weight = 4 + } +} + local science_loot = { { stack = { recipe = 'automation-science-pack', - output = {item = 'automation-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 5 / 60 / 512} + output = {item = 'automation-science-pack', min_rate = 3 / 800, distance_factor = 1 / 8 / 60 / 20480} }, weight = 4 }, @@ -20,7 +33,7 @@ local science_loot = { stack = { recipe = 'logistic-science-pack', tech = 'logistic-science-pack', - output = {item = 'logistic-science-pack', min_rate = 0.5 / 8 / 60, distance_factor = 1 / 15 / 60 / 512} + output = {item = 'logistic-science-pack', min_rate = 2 / 800, distance_factor = 1 / 8 / 60 / 20480} }, weight = 2 } @@ -31,21 +44,21 @@ local ammo_loot = { stack = { recipe = 'piercing-rounds-magazine', tech = 'military-2', - output = {item = 'piercing-rounds-magazine', min_rate = 1 / 2 / 60, distance_factor = 1 / 10 / 60 / 512} + output = {item = 'piercing-rounds-magazine', min_rate = 1 / 800, distance_factor = 1 / 8 / 60 / 20480} }, weight = 1 }, { stack = { recipe = 'firearm-magazine', - output = {item = 'firearm-magazine', min_rate = 1 / 2 / 60, distance_factor = 1 / 4 / 60 / 512} + output = {item = 'firearm-magazine', min_rate = 2 / 800, distance_factor = 1 / 8 / 60 / 20480} }, weight = 4 }, { stack = { recipe = 'shotgun-shell', - output = {item = 'shotgun-shell', min_rate = 1 / 2 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'shotgun-shell', min_rate = 2 / 800, distance_factor = 1 / 8 / 60 / 20480} }, weight = 4 }, @@ -53,7 +66,7 @@ local ammo_loot = { stack = { recipe = 'uranium-rounds-magazine', tech = 'uranium-ammo', - output = {item = 'uranium-rounds-magazine', min_rate = 0.1 / 8 / 60, distance_factor = 1 / 25 / 60 / 512} + output = {item = 'uranium-rounds-magazine', min_rate = 2 / 1800, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.25 } @@ -66,7 +79,7 @@ local oil_loot = { tech = 'oil-processing', output = { min_rate = 1 / 60, - distance_factor = 1 / 10 / 60 / 512, + distance_factor = 1 / 8 / 60 / 20480, item = 'petroleum-gas', fluidbox_index = 2 } @@ -78,9 +91,9 @@ local oil_loot = { recipe = 'advanced-oil-processing', tech = 'advanced-oil-processing', output = { - {min_rate = 0.7 / 60, distance_factor = 3.125 / 60 / 512, item = 'heavy-oil', fluidbox_index = 3}, - {min_rate = 0.82 / 60, distance_factor = 5.625 / 60 / 512, item = 'light-oil', fluidbox_index = 4}, - {min_rate = 0.83 / 60, distance_factor = 6.875 / 60 / 512, item = 'petroleum-gas', fluidbox_index = 5} + {min_rate = 0.7 / 60, distance_factor = 1 / 8 / 60 / 20480, item = 'heavy-oil', fluidbox_index = 3}, + {min_rate = 0.82 / 60, distance_factor = 1 / 8 / 60 / 20480, item = 'light-oil', fluidbox_index = 4}, + {min_rate = 0.83 / 60, distance_factor = 1 / 8 / 60 / 20480, item = 'petroleum-gas', fluidbox_index = 5} } }, weight = 0.1 @@ -95,7 +108,7 @@ local oil_prod_loot = { output = { item = 'lubricant', min_rate = 0.7 / 60, - distance_factor = 1 / 10 / 60 / 512, + distance_factor = 1 / 8 / 60 / 20480, fluidbox_index = 2 } }, @@ -108,7 +121,7 @@ local oil_prod_loot = { output = { item = 'solid-fuel', min_rate = 0.7 / 60, - distance_factor = 1 / 4 / 60 / 512 + distance_factor = 1 / 8 / 60 / 20480 } }, weight = 4 @@ -120,7 +133,7 @@ local oil_prod_loot = { output = { item = 'sulfuric-acid', min_rate = 0.8 / 60, - distance_factor = 1 / 8 / 60 / 512, + distance_factor = 1 / 8 / 60 / 20480, fluidbox_index = 2 } }, @@ -133,7 +146,7 @@ local oil_prod_loot = { output = { item = 'battery', min_rate = 0.6 / 60, - distance_factor = 1 / 25 / 60 / 512 + distance_factor = 1 / 8 / 60 / 20480 } }, weight = 0.75 @@ -145,7 +158,7 @@ local oil_prod_loot = { output = { item = 'sulfur', min_rate = 0.8 / 60, - distance_factor = 1 / 25 / 60 / 512 + distance_factor = 1 / 8 / 60 / 20480 } }, weight = 0.55 @@ -157,7 +170,7 @@ local oil_prod_loot = { output = { item = 'plastic-bar', min_rate = 0.8 / 60, - distance_factor = 1 / 25 / 60 / 512 + distance_factor = 1 / 8 / 60 / 20480 } }, weight = 0.25 @@ -169,7 +182,7 @@ local oil_prod_loot = { output = { item = 'explosives', min_rate = 0.8 / 60, - distance_factor = 1 / 25 / 60 / 512 + distance_factor = 1 / 8 / 60 / 20480 } }, weight = 0.20 @@ -181,7 +194,7 @@ local resource_loot = { stack = { recipe = 'stone-wall', tech = 'stone-walls', - output = {item = 'stone-wall', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'stone-wall', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 10 }, @@ -189,21 +202,21 @@ local resource_loot = { stack = { recipe = 'concrete', tech = 'concrete', - output = {item = 'concrete', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'concrete', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 6 }, { stack = { recipe = 'iron-gear-wheel', - output = {item = 'iron-gear-wheel', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'iron-gear-wheel', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 12 }, { stack = { recipe = 'inserter', - output = {item = 'inserter', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'inserter', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 12 }, @@ -211,14 +224,14 @@ local resource_loot = { stack = { recipe = 'fast-inserter', tech = 'fast-inserter', - output = {item = 'fast-inserter', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'fast-inserter', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 4 }, { stack = { recipe = 'electronic-circuit', - output = {item = 'electronic-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'electronic-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 2 }, @@ -226,7 +239,7 @@ local resource_loot = { stack = { recipe = 'advanced-circuit', tech = 'advanced-electronics', - output = {item = 'advanced-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'advanced-circuit', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 1 }, @@ -234,28 +247,28 @@ local resource_loot = { stack = { recipe = 'processing-unit', tech = 'advanced-electronics-2', - output = {item = 'processing-unit', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'processing-unit', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 2 }, { stack = { recipe = 'transport-belt', - output = {item = 'transport-belt', min_rate = 0.6 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'transport-belt', min_rate = 0.6 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 8 }, { stack = { recipe = 'underground-belt', - output = {item = 'underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 8 }, { stack = { recipe = 'small-electric-pole', - output = {item = 'small-electric-pole', min_rate = 1 / 4 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'small-electric-pole', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 8 }, @@ -263,7 +276,7 @@ local resource_loot = { stack = { recipe = 'fast-transport-belt', tech = 'logistics-2', - output = {item = 'fast-transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'fast-transport-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 5 }, @@ -271,7 +284,7 @@ local resource_loot = { stack = { recipe = 'fast-underground-belt', tech = 'logistics-2', - output = {item = 'fast-underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'fast-underground-belt', min_rate = 1 / 4 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 5 }, @@ -279,7 +292,7 @@ local resource_loot = { stack = { recipe = 'solar-panel', tech = 'solar-energy', - output = {item = 'solar-panel', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'solar-panel', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 3 }, @@ -287,7 +300,7 @@ local resource_loot = { stack = { recipe = 'productivity-module', tech = 'productivity-module', - output = {item = 'productivity-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'productivity-module', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.9 }, @@ -295,7 +308,7 @@ local resource_loot = { stack = { recipe = 'effectivity-module', tech = 'effectivity-module', - output = {item = 'effectivity-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'effectivity-module', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.9 }, @@ -303,7 +316,7 @@ local resource_loot = { stack = { recipe = 'speed-module', tech = 'speed-module', - output = {item = 'speed-module', min_rate = 1 / 6 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'speed-module', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.8 }, @@ -311,7 +324,7 @@ local resource_loot = { stack = { recipe = 'productivity-module-2', tech = 'productivity-module-2', - output = {item = 'productivity-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'productivity-module-2', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.5 }, @@ -319,7 +332,7 @@ local resource_loot = { stack = { recipe = 'effectivity-module-2', tech = 'effectivity-module-2', - output = {item = 'effectivity-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'effectivity-module-2', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.5 }, @@ -327,7 +340,7 @@ local resource_loot = { stack = { recipe = 'speed-module-2', tech = 'speed-module-2', - output = {item = 'speed-module-2', min_rate = 1 / 8 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'speed-module-2', min_rate = 1 / 15 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.5 }, @@ -335,7 +348,7 @@ local resource_loot = { stack = { recipe = 'productivity-module-3', tech = 'productivity-module-3', - output = {item = 'productivity-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'productivity-module-3', min_rate = 1 / 20 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.25 }, @@ -343,7 +356,7 @@ local resource_loot = { stack = { recipe = 'effectivity-module-3', tech = 'effectivity-module-3', - output = {item = 'effectivity-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'effectivity-module-3', min_rate = 1 / 20 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.25 }, @@ -351,7 +364,7 @@ local resource_loot = { stack = { recipe = 'speed-module-3', tech = 'speed-module-3', - output = {item = 'speed-module-3', min_rate = 1 / 10 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'speed-module-3', min_rate = 1 / 20 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 0.10 } @@ -361,14 +374,14 @@ local furnace_loot = { { stack = { furance_item = 'iron-plate', - output = {item = 'iron-plate', min_rate = 2.0 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'iron-plate', min_rate = 2.0 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 4 }, { stack = { furance_item = 'copper-plate', - output = {item = 'copper-plate', min_rate = 2.0 / 60, distance_factor = 1 / 6 / 60 / 512} + output = {item = 'copper-plate', min_rate = 2.0 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 4 }, @@ -376,12 +389,13 @@ local furnace_loot = { stack = { furance_item = 'steel-plate', tech = 'steel-processing', - output = {item = 'steel-plate', min_rate = 1.0 / 60, distance_factor = 1 / 8 / 60 / 512} + output = {item = 'steel-plate', min_rate = 1.0 / 60, distance_factor = 1 / 8 / 60 / 20480} }, weight = 1 } } +local testing_weights = Functions.prepare_weighted_loot(testing_loot) local science_weights = Functions.prepare_weighted_loot(science_loot) local building_weights = Functions.prepare_weighted_loot(ammo_loot) local oil_weights = Functions.prepare_weighted_loot(oil_loot) @@ -389,6 +403,15 @@ local oil_prod_weights = Functions.prepare_weighted_loot(oil_prod_loot) local resource_weights = Functions.prepare_weighted_loot(resource_loot) local furnace_weights = Functions.prepare_weighted_loot(furnace_loot) +local testing_callback = { + callback = Functions.magic_item_crafting_callback_weighted, + data = { + loot = testing_loot, + weights = testing_weights, + testing = true + } +} + local science_callback = { callback = Functions.magic_item_crafting_callback_weighted, data = { @@ -437,6 +460,12 @@ local furnace_callback = { } } +local testing_list = { + [1] = {name = 'assembling-machine-1', callback = testing_callback}, + [2] = {name = 'assembling-machine-2', callback = testing_callback}, + [3] = {name = 'assembling-machine-3', callback = testing_callback} +} + local science_list = { [1] = {name = 'assembling-machine-1', callback = science_callback}, [2] = {name = 'assembling-machine-2', callback = science_callback}, @@ -469,6 +498,19 @@ local furnace_list = { [3] = {name = 'electric-furnace', callback = furnace_callback} } +local function spawn_testing_buildings(entities, p, probability) + local callback = testing_list[probability].callback + + entities[#entities + 1] = { + name = testing_list[probability].name, + position = p, + force = 'neutral', + callback = callback, + collision = true, + e_type = types + } +end + local function spawn_science_buildings(entities, p, probability) local callback = science_list[probability].callback @@ -556,6 +598,12 @@ local buildings = { [6] = spawn_oil_prod_buildings } +if testing then + buildings = { + [1] = spawn_testing_buildings + } +end + local function spawn_random_buildings(entities, p, depth) local randomizer = random(1, #buildings) local low = random(1, 2) diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index 1e953e12..b5390c38 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -315,14 +315,8 @@ local function wall(p, data) if not alert_zone_1 then local x_min = -WPT.level_width / 2 local x_max = WPT.level_width / 2 - WPT.set( - 'zone1_beam1', - surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}}) - ) - WPT.set( - 'zone1_beam2', - surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}}) - ) + WPT.set('zone1_beam1', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})) + WPT.set('zone1_beam2', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})) WPT.set('alert_zone_1', true) WPT.set( 'zone1_text1', @@ -2574,9 +2568,7 @@ Event.add( local locomotive = WPT.get('locomotive') if locomotive and locomotive.valid then local position = locomotive.position - for _, entity in pairs( - surface.find_entities_filtered({area = {{position.x - 5, position.y - 6}, {position.x + 5, position.y + 10}}, type = 'simple-entity'}) - ) do + for _, entity in pairs(surface.find_entities_filtered({area = {{position.x - 5, position.y - 6}, {position.x + 5, position.y + 10}}, type = 'simple-entity'})) do entity.destroy() end end From 95f2e90e55a3406a63614ae94d4a99fd8089f4f8 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Apr 2022 19:28:08 +0200 Subject: [PATCH 03/24] refactor more gui --- .luacheckrc | 5 +- comfy_panel/main.lua | 285 ---------- control.lua | 16 +- maps/biter_battles/biter_battles.lua | 37 +- maps/biter_battles_v2/game_over.lua | 2 +- maps/biter_battles_v2/init.lua | 2 +- maps/biter_battles_v2/sciencelogs_tab.lua | 43 +- maps/biter_hatchery/main.lua | 6 +- maps/chronosphere/chrono.lua | 137 ++--- maps/chronosphere/config_tab.lua | 18 +- maps/crab_defender/main.lua | 4 +- maps/fish_defender/main.lua | 4 +- maps/fish_defender_v1/fish_defender.lua | 2 +- maps/fish_defender_v2/main.lua | 4 +- maps/junkyard_pvp/main.lua | 10 +- maps/labyrinth.lua | 20 +- maps/minesweeper/main.lua | 2 +- maps/mountain_fortress_v2/main.lua | 6 +- maps/mountain_fortress_v3/entities.lua | 5 +- maps/mountain_fortress_v3/functions.lua | 8 +- maps/mountain_fortress_v3/gui.lua | 10 +- maps/mountain_fortress_v3/highscore.lua | 32 +- maps/mountain_fortress_v3/ic/gui.lua | 9 +- .../locomotive/market.lua | 40 +- maps/mountain_fortress_v3/main.lua | 10 +- maps/mountain_race/main.lua | 2 +- maps/native_war/main.lua | 12 +- maps/pidgeotto/main.lua | 4 +- maps/planet_prison.lua | 10 +- maps/scrap_towny_ffa/main.lua | 44 +- modules/autostash.lua | 4 +- modules/difficulty_vote_by_amount.lua | 243 +++++---- modules/map_info.lua | 65 +-- modules/rewards.lua | 10 +- modules/rpg.lua | 4 +- modules/rpg/gui.lua | 90 ++-- modules/rpg/main.lua | 3 - modules/rpg/table.lua | 2 + utils/datastore/current_time_data.lua | 4 +- utils/datastore/server_ups_data.lua | 4 +- utils/files/arrow-down.png | Bin 0 -> 364 bytes utils/files/arrow-up.png | Bin 0 -> 373 bytes utils/files/infinity.png | Bin 0 -> 524 bytes utils/files/pin-black.png | Bin 0 -> 741 bytes utils/files/pin-white.png | Bin 0 -> 780 bytes utils/files/settings-black.png | Bin 0 -> 1237 bytes utils/files/settings-white.png | Bin 0 -> 1183 bytes utils/freeplay.lua | 2 +- utils/gui.lua | 505 ++++++++++++++++-- {comfy_panel => utils/gui}/admin.lua | 51 +- {comfy_panel => utils/gui}/bottom_frame.lua | 3 +- {comfy_panel => utils/gui}/config.lua | 212 ++------ {comfy_panel => utils/gui}/group.lua | 29 +- {comfy_panel => utils/gui}/map_score.lua | 18 +- {comfy_panel => utils/gui}/player_list.lua | 29 +- {comfy_panel => utils/gui}/poll.lua | 41 +- {comfy_panel => utils/gui}/score.lua | 32 +- {comfy_panel => utils/gui}/server_select.lua | 37 +- 58 files changed, 1083 insertions(+), 1094 deletions(-) delete mode 100644 comfy_panel/main.lua create mode 100644 utils/files/arrow-down.png create mode 100644 utils/files/arrow-up.png create mode 100644 utils/files/infinity.png create mode 100644 utils/files/pin-black.png create mode 100644 utils/files/pin-white.png create mode 100644 utils/files/settings-black.png create mode 100644 utils/files/settings-white.png rename {comfy_panel => utils/gui}/admin.lua (95%) rename {comfy_panel => utils/gui}/bottom_frame.lua (98%) rename {comfy_panel => utils/gui}/config.lua (78%) rename {comfy_panel => utils/gui}/group.lua (95%) rename {comfy_panel => utils/gui}/map_score.lua (89%) rename {comfy_panel => utils/gui}/player_list.lua (98%) rename {comfy_panel => utils/gui}/poll.lua (97%) rename {comfy_panel => utils/gui}/score.lua (95%) rename {comfy_panel => utils/gui}/server_select.lua (87%) diff --git a/.luacheckrc b/.luacheckrc index aa27f117..9a6c68c0 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -61,8 +61,7 @@ globals = { 'is_loaded', 'is_game_modded', 'is_mod_loaded', - 'require', - 'comfy_panel_tabs' + 'require' } max_line_length = LINE_LENGTH @@ -2010,7 +2009,7 @@ stds.factorio_defines = { } } } - --)) +--)) --[[ Options "ignore", "std", "globals", "unused_args", "self", "compat", "global", "unused", "redefined", diff --git a/comfy_panel/main.lua b/comfy_panel/main.lua deleted file mode 100644 index ceb04627..00000000 --- a/comfy_panel/main.lua +++ /dev/null @@ -1,285 +0,0 @@ ---[[ -Comfy Panel - -To add a tab, insert into the "main_gui_tabs" table. - -Example: main_gui_tabs["mapscores"] = {gui = draw_map_scores, admin = false} -if admin = true, then tab is visible only for admins (usable for map-specific settings) - -draw_map_scores would be a function with the player and the frame as arguments - -]] -local Event = require 'utils.event' -local Server = require 'utils.server' -local SpamProtection = require 'utils.spam_protection' -local Token = require 'utils.token' -local Global = require 'utils.global' -local Gui = require 'utils.gui' - -local main_gui_tabs = {} -local Public = {} -local screen_elements = {} -local this = { - settings = { - mod_gui_top_frame = false - } -} - -Global.register( - this, - function(tbl) - this = tbl - end -) - ---- This adds the given gui to the top gui. ----@param player ----@param frame ----@param name -function Public.add_mod_button(player, frame) - if Gui.get_button_flow(player)[frame.name] and Gui.get_button_flow(player)[frame.name].valid then - return - end - - Gui.get_button_flow(player).add(frame) -end - ----@param state ---- If we should use the new mod gui or not -function Public.set_mod_gui_top_frame(state) - this.settings.mod_gui_top_frame = state or false -end - ---- Get mod_gui_top_frame -function Public.get_mod_gui_top_frame() - return this.settings.mod_gui_top_frame -end - ---- This adds the given gui to the main gui. ----@param tbl -function Public.add_tab_to_gui(tbl) - if not tbl then - return - end - if not tbl.name then - return - end - if not tbl.id then - return - end - local admin = tbl.admin or false - local only_server_sided = tbl.only_server_sided or false - - if not main_gui_tabs[tbl.name] then - main_gui_tabs[tbl.name] = {id = tbl.id, admin = admin, only_server_sided = only_server_sided} - else - error('Given name: ' .. tbl.name .. ' already exists in table.') - end -end - -function Public.screen_to_bypass(elem) - screen_elements[elem] = true - return screen_elements -end - ---- Fetches the main gui tabs. You are forbidden to write as this is local. ----@param key -function Public.get(key) - if key then - return main_gui_tabs[key] - else - return main_gui_tabs - end -end - -function Public.comfy_panel_clear_gui(player) - for _, child in pairs(player.gui.left.children) do - child.destroy() - end - for _, child in pairs(player.gui.screen.children) do - if not screen_elements[child.name] then - child.destroy() - end - end -end - -function Public.comfy_panel_get_active_frame(player) - local main_frame = player.gui.left.comfy_panel - if not main_frame then - return false - end - - local panel = main_frame.tabbed_pane - if not panel then - return - end - local index = panel.selected_tab_index - if not index then - return panel.tabs[1].content - end - return panel.tabs[index].content -end - -function Public.comfy_panel_refresh_active_tab(player) - local frame = Public.comfy_panel_get_active_frame(player) - if not frame then - return - end - - local tab = main_gui_tabs[frame.name] - if not tab then - return - end - local id = tab.id - if not id then - return - end - local func = Token.get(id) - - local data = { - player = player, - frame = frame - } - - return func(data) -end - -local function top_button(player) - if this.settings.mod_gui_top_frame then - Public.add_mod_button(player, {type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'}, 'comfy_panel_top_button') - else - if player.gui.top['comfy_panel_top_button'] then - return - end - local button = player.gui.top.add({type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'}) - button.style.minimal_height = 38 - button.style.maximal_height = 38 - button.style.minimal_width = 40 - button.style.padding = -2 - end -end - -local function main_frame(player) - local tabs = main_gui_tabs - Public.comfy_panel_clear_gui(player) - - local frame = player.gui.left.comfy_panel - if not frame or not frame.valid then - frame = player.gui.left.add({type = 'frame', name = 'comfy_panel'}) - end - - frame.style.margin = 6 - - local tabbed_pane = frame.add({type = 'tabbed-pane', name = 'tabbed_pane'}) - - for name, func in pairs(tabs) do - if func.only_server_sided then - local secs = Server.get_current_time() - if secs then - local tab = tabbed_pane.add({type = 'tab', caption = name, name = 'tab_' .. name}) - local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'}) - name_frame.style.minimal_height = 480 - name_frame.style.maximal_height = 480 - name_frame.style.minimal_width = 800 - name_frame.style.maximal_width = 800 - tabbed_pane.add_tab(tab, name_frame) - end - elseif func.admin == true then - if player.admin then - local tab = tabbed_pane.add({type = 'tab', caption = name, name = 'tab_' .. name}) - local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'}) - name_frame.style.minimal_height = 480 - name_frame.style.maximal_height = 480 - name_frame.style.minimal_width = 800 - name_frame.style.maximal_width = 800 - tabbed_pane.add_tab(tab, name_frame) - end - else - local tab = tabbed_pane.add({type = 'tab', caption = name, name = 'tab_' .. name}) - local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'}) - name_frame.style.minimal_height = 480 - name_frame.style.maximal_height = 480 - name_frame.style.minimal_width = 800 - name_frame.style.maximal_width = 800 - tabbed_pane.add_tab(tab, name_frame) - end - end - - local tab = tabbed_pane.add({type = 'tab', name = 'comfy_panel_close', caption = 'X'}) - tab.style.maximal_width = 32 - local t_frame = tabbed_pane.add({type = 'frame', direction = 'vertical'}) - tabbed_pane.add_tab(tab, t_frame) - - for _, child in pairs(tabbed_pane.children) do - child.style.padding = 8 - child.style.left_padding = 2 - child.style.right_padding = 2 - end - - Public.comfy_panel_refresh_active_tab(player) -end - -function Public.comfy_panel_call_tab(player, name) - main_frame(player) - local tabbed_pane = player.gui.left.comfy_panel.tabbed_pane - for key, v in pairs(tabbed_pane.tabs) do - if v.tab.caption == name then - tabbed_pane.selected_tab_index = key - Public.comfy_panel_refresh_active_tab(player) - end - end -end - -local function on_player_joined_game(event) - local player = game.get_player(event.player_index) - top_button(player) -end - -local function on_gui_click(event) - local element = event.element - if not element or not element.valid then - return - end - - local player = game.get_player(event.player_index) - - local name = element.name - - if name == 'comfy_panel_top_button' then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Comfy Main GUI Click') - if is_spamming then - return - end - if player.gui.left.comfy_panel then - player.gui.left.comfy_panel.destroy() - return - else - main_frame(player) - return - end - end - - if element.caption == 'X' and name == 'comfy_panel_close' then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Comfy Main Gui Close Button') - if is_spamming then - return - end - player.gui.left.comfy_panel.destroy() - return - end - - if not element.caption then - return - end - if element.type ~= 'tab' then - return - end - - Public.comfy_panel_refresh_active_tab(player) -end - -Event.add(defines.events.on_player_joined_game, on_player_joined_game) -Event.add(defines.events.on_player_created, on_player_joined_game) -Event.add(defines.events.on_gui_click, on_gui_click) - -return Public diff --git a/control.lua b/control.lua index bfa1f3f2..49b016e5 100644 --- a/control.lua +++ b/control.lua @@ -28,14 +28,14 @@ require 'modules.show_inventory' require 'modules.inserter_drops_pickup' require 'modules.autostash' -require 'comfy_panel.main' -require 'comfy_panel.player_list' -require 'comfy_panel.admin' -require 'comfy_panel.group' -require 'comfy_panel.poll' -require 'comfy_panel.score' -require 'comfy_panel.config' -require 'comfy_panel.server_select' +require 'utils.gui' +require 'utils.gui.player_list' +require 'utils.gui.admin' +require 'utils.gui.group' +require 'utils.gui.poll' +require 'utils.gui.score' +require 'utils.gui.config' +require 'utils.gui.server_select' require 'utils.freeplay' ---------------- !ENABLE MODULES HERE ---------------- diff --git a/maps/biter_battles/biter_battles.lua b/maps/biter_battles/biter_battles.lua index 886911b6..64695cec 100644 --- a/maps/biter_battles/biter_battles.lua +++ b/maps/biter_battles/biter_battles.lua @@ -1,7 +1,7 @@ -- Biter Battles -- mewmew made this -- --luacheck:ignore local Server = require 'utils.server' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local Global = require 'utils.global' require 'modules.splice_double' require 'modules.explosive_biters' @@ -525,15 +525,9 @@ end local function reveal_team(f) local m = 32 if f == 'north' then - game.forces['south'].chart( - game.surfaces['surface'], - {{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}} - ) + game.forces['south'].chart(game.surfaces['surface'], {{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}}) else - game.forces['north'].chart( - game.surfaces['surface'], - {{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}} - ) + game.forces['north'].chart(game.surfaces['surface'], {{x = global.force_area[f].x_top - m, y = global.force_area[f].y_top - m}, {x = global.force_area[f].x_bot + m, y = global.force_area[f].y_bot + m}}) end end @@ -851,10 +845,7 @@ local function on_gui_click(event) join_team(player, global.team_chosen[player.name]) end if (name == 'biter_battle_leave_spectate') and game.tick - global.spectator_spam_protection[player.name] < 1800 then - player.print( - 'Not ready to return to your team yet. Please wait ' .. 30 - (math.round((game.tick - global.spectator_spam_protection[player.name]) / 60, 0)) .. ' seconds.', - {r = 0.98, g = 0.66, b = 0.22} - ) + player.print('Not ready to return to your team yet. Please wait ' .. 30 - (math.round((game.tick - global.spectator_spam_protection[player.name]) / 60, 0)) .. ' seconds.', {r = 0.98, g = 0.66, b = 0.22}) end if (name == 'biter_battle_hide_players') then @@ -1053,15 +1044,11 @@ local function biter_attack_silo(team, requested_amount, mode) if math_random(1, 6) == 1 then for _, biter in pairs(biters_selected_for_attack) do - biter.set_command( - {type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything} - ) + biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything}) end else for _, biter in pairs(biters_selected_for_attack) do - biter.set_command( - {type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy} - ) + biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy}) end end if global.biter_battles_debug then @@ -1279,15 +1266,11 @@ local function biter_attack_silo(team, requested_amount, mode) if t > 8 then if math_random(1, 6) ~= 1 then for _, biter in pairs(biters_selected_for_attack) do - biter.set_command( - {type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy} - ) + biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy}) end else for _, biter in pairs(biters_selected_for_attack) do - biter.set_command( - {type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything} - ) + biter.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_anything}) end end if global.biter_battles_debug then @@ -1298,9 +1281,7 @@ local function biter_attack_silo(team, requested_amount, mode) for _, biter in pairs(biters_selected_for_attack) do biter_attack_group.add_member(biter) end - biter_attack_group.set_command( - {type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy} - ) + biter_attack_group.set_command({type = defines.command.attack_area, destination = global.biter_attack_main_target[team], radius = 12, distraction = defines.distraction.by_enemy}) if global.biter_battles_debug then game.players[1].print(#valid_biters .. ' valid biters found.') game.players[1].print(#biters_selected_for_attack .. ' gathering at (x: ' .. gathering_point_x .. ' y: ' .. gathering_point_y .. ')') diff --git a/maps/biter_battles_v2/game_over.lua b/maps/biter_battles_v2/game_over.lua index 63efd7d1..87adffda 100644 --- a/maps/biter_battles_v2/game_over.lua +++ b/maps/biter_battles_v2/game_over.lua @@ -2,7 +2,7 @@ local Functions = require 'maps.biter_battles_v2.functions' local Gui = require 'maps.biter_battles_v2.gui' local Init = require 'maps.biter_battles_v2.init' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local Server = require 'utils.server' local Discord = require 'utils.discord' diff --git a/maps/biter_battles_v2/init.lua b/maps/biter_battles_v2/init.lua index b1ce087a..2c52586d 100644 --- a/maps/biter_battles_v2/init.lua +++ b/maps/biter_battles_v2/init.lua @@ -1,7 +1,7 @@ --luacheck:ignore local Terrain = require 'maps.biter_battles_v2.terrain' local Force_health_booster = require 'modules.force_health_booster' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local Public = {} diff --git a/maps/biter_battles_v2/sciencelogs_tab.lua b/maps/biter_battles_v2/sciencelogs_tab.lua index cbee5b8e..d6dafd20 100644 --- a/maps/biter_battles_v2/sciencelogs_tab.lua +++ b/maps/biter_battles_v2/sciencelogs_tab.lua @@ -1,7 +1,7 @@ --luacheck: ignore -- science logs tab -- -local Tabs = require 'comfy_panel.main' +local Tabs = require 'utils.gui' local tables = require 'maps.biter_battles_v2.tables' local event = require 'utils.event' local bb_config = require 'maps.biter_battles_v2.config' @@ -13,8 +13,7 @@ local science_list = tables.science_list local evofilter_list = tables.evofilter_list local food_value_table_version = tables.food_value_table_version local Token = require 'utils.token' - -local module_name = 'MutagenLog' +local module_name = Tabs.uid_name() local function initialize_dropdown_users_choice() global.dropdown_users_choice_force = {} @@ -27,8 +26,7 @@ local function get_science_text(food_name, food_short_name) end local function add_science_logs(player, element) - local science_scrollpanel = - element.add {type = 'scroll-pane', name = 'scroll_pane', direction = 'vertical', horizontal_scroll_policy = 'never', vertical_scroll_policy = 'auto'} + local science_scrollpanel = element.add {type = 'scroll-pane', name = 'scroll_pane', direction = 'vertical', horizontal_scroll_policy = 'never', vertical_scroll_policy = 'auto'} science_scrollpanel.style.maximal_height = 530 if global.science_logs_category_potion == nil then @@ -129,8 +127,7 @@ local function add_science_logs(player, element) local dropdown_force = t_filter.add {name = 'dropdown-force', type = 'drop-down', items = forces_list, selected_index = global.dropdown_users_choice_force[player.name]} local dropdown_science = t_filter.add {name = 'dropdown-science', type = 'drop-down', items = science_list, selected_index = global.dropdown_users_choice_science[player.name]} - local dropdown_evofilter = - t_filter.add {name = 'dropdown-evofilter', type = 'drop-down', items = evofilter_list, selected_index = global.dropdown_users_choice_evo_filter[player.name]} + local dropdown_evofilter = t_filter.add {name = 'dropdown-evofilter', type = 'drop-down', items = evofilter_list, selected_index = global.dropdown_users_choice_evo_filter[player.name]} local t = science_scrollpanel.add {type = 'table', name = 'science_logs_header_table', column_count = 4} local column_widths = {tonumber(75), tonumber(310), tonumber(165), tonumber(230)} @@ -171,13 +168,9 @@ local function add_science_logs(player, element) if dropdown_force.selected_index == 1 or real_force_name:match(dropdown_force.get_item(dropdown_force.selected_index)) then if - dropdown_science.selected_index == 1 or - (dropdown_science.selected_index == 2 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production'))) or - (dropdown_science.selected_index == 3 and - (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical'))) or - (dropdown_science.selected_index == 4 and - (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical') or - easy_food_name:match('military'))) or + dropdown_science.selected_index == 1 or (dropdown_science.selected_index == 2 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production'))) or + (dropdown_science.selected_index == 3 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical'))) or + (dropdown_science.selected_index == 4 and (easy_food_name:match('space') or easy_food_name:match('utility') or easy_food_name:match('production') or easy_food_name:match('chemical') or easy_food_name:match('military'))) or easy_food_name:match(dropdown_science.get_item(dropdown_science.selected_index)) then if @@ -221,19 +214,9 @@ local function add_science_logs(player, element) end end -local function comfy_panel_get_active_frame(player) - if not player.gui.left.comfy_panel then - return false - end - if not player.gui.left.comfy_panel.tabbed_pane.selected_tab_index then - return player.gui.left.comfy_panel.tabbed_pane.tabs[1].content - end - return player.gui.left.comfy_panel.tabbed_pane.tabs[player.gui.left.comfy_panel.tabbed_pane.selected_tab_index].content -end - local function build_config_gui(data) local player = data.player - local frame_sciencelogs = comfy_panel_get_active_frame(player) + local frame_sciencelogs = Gui.get_player_active_frame(player) if not frame_sciencelogs then return end @@ -268,4 +251,12 @@ end event.add(defines.events.on_gui_selection_state_changed, on_gui_selection_state_changed) -Tabs.add_tab_to_gui({name = module_name, id = build_config_gui_token, admin = false}) +Tabs.add_tab_to_gui({name = module_name, caption = 'MutagenLog', id = build_config_gui_token, admin = false}) + +Tabs.on_click( + module_name, + function(event) + local player = event.player + Tabs.reload_active_tab(player) + end +) diff --git a/maps/biter_hatchery/main.lua b/maps/biter_hatchery/main.lua index 41b5c6d2..5732c1e4 100644 --- a/maps/biter_hatchery/main.lua +++ b/maps/biter_hatchery/main.lua @@ -1,8 +1,8 @@ --luacheck: ignore require 'modules.no_turrets' require 'modules.no_acid_puddles' -local Tabs = require 'comfy_panel.main' -local Map_score = require 'comfy_panel.map_score' +local Gui = require 'utils.gui' +local Map_score = require 'utils.gui.map_score' local unit_raffle = require 'maps.biter_hatchery.raffle_tables' local Terrain = require 'maps.biter_hatchery.terrain' local Gui = require 'maps.biter_hatchery.gui' @@ -310,7 +310,7 @@ local function on_entity_died(event) for _, child in pairs(player.gui.left.children) do child.destroy() end - Tabs.comfy_panel_call_tab(player, 'Map Scores') + Gui.call_existing_tab(player, 'Map Scores') end for _, e in pairs(entity.surface.find_entities_filtered({type = 'unit'})) do diff --git a/maps/chronosphere/chrono.lua b/maps/chronosphere/chrono.lua index e210b95c..d62b7ce0 100644 --- a/maps/chronosphere/chrono.lua +++ b/maps/chronosphere/chrono.lua @@ -1,6 +1,6 @@ local Chrono_table = require 'maps.chronosphere.table' local Balance = require 'maps.chronosphere.balance' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local Difficulty = require 'modules.difficulty_vote' local Upgrades = require 'maps.chronosphere.upgrade_list' local List = require 'maps.chronosphere.production_list' @@ -120,48 +120,48 @@ function Public.restart_settings() global.mining_history = {} get_score.score_table = {} - game.difficulty_settings.technology_price_multiplier = Balance.Tech_price_multiplier - game.map_settings.enemy_evolution.destroy_factor = 0.005 - game.map_settings.enemy_evolution.pollution_factor = 0 - game.map_settings.enemy_evolution.time_factor = 7e-05 - game.map_settings.enemy_expansion.enabled = false - -- game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 - -- game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 - -- game.map_settings.enemy_expansion.settler_group_max_size = 30 - -- game.map_settings.enemy_expansion.settler_group_min_size = 10 - -- game.map_settings.enemy_expansion.max_expansion_distance = 9 - game.map_settings.pollution.enabled = true - game.map_settings.pollution.expected_max_per_chunk = 400 - game.map_settings.pollution.min_to_show_per_chunk = 40 - game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02 - game.map_settings.pollution.min_pollution_to_damage_trees = 1 - game.map_settings.pollution.max_pollution_to_restore_trees = 0 - game.map_settings.pollution.pollution_with_max_forest_damage = 10 - game.map_settings.pollution.pollution_per_tree_damage = 0.1 - game.map_settings.pollution.ageing = 0.1 - game.map_settings.pollution.diffusion_ratio = 0.1 - game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5 - game.map_settings.unit_group.min_group_gathering_time = 1800 - game.map_settings.unit_group.max_group_gathering_time = 18000 - game.map_settings.unit_group.max_wait_time_for_late_members = 600 - game.map_settings.path_finder.general_entity_collision_penalty = 1 - game.map_settings.path_finder.general_entity_subsequent_collision_penalty = 1 - game.map_settings.path_finder.short_cache_size = 20 - game.map_settings.path_finder.long_cache_size = 100 - game.map_settings.unit_group.max_gathering_unit_groups = 10 - game.forces.neutral.character_inventory_slots_bonus = 500 - game.forces.enemy.evolution_factor = 0.0001 - game.forces.scrapyard.set_friend('enemy', true) - game.forces.enemy.set_friend('scrapyard', true) - game.forces.enemy.set_ammo_damage_modifier("rocket", -0.5) - game.forces.player.technologies["land-mine"].enabled = false - game.forces.player.technologies["landfill"].enabled = false - game.forces.player.technologies["cliff-explosives"].enabled = false - game.forces.player.technologies["fusion-reactor-equipment"].enabled = false - game.forces.player.technologies["power-armor-mk2"].enabled = false - game.forces.player.technologies["railway"].researched = true - game.forces.player.recipes["pistol"].enabled = false - game.forces.player.ghost_time_to_live = 15 * 60 * 60 + game.difficulty_settings.technology_price_multiplier = Balance.Tech_price_multiplier + game.map_settings.enemy_evolution.destroy_factor = 0.005 + game.map_settings.enemy_evolution.pollution_factor = 0 + game.map_settings.enemy_evolution.time_factor = 7e-05 + game.map_settings.enemy_expansion.enabled = false + -- game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 + -- game.map_settings.enemy_expansion.min_expansion_cooldown = 3600 + -- game.map_settings.enemy_expansion.settler_group_max_size = 30 + -- game.map_settings.enemy_expansion.settler_group_min_size = 10 + -- game.map_settings.enemy_expansion.max_expansion_distance = 9 + game.map_settings.pollution.enabled = true + game.map_settings.pollution.expected_max_per_chunk = 400 + game.map_settings.pollution.min_to_show_per_chunk = 40 + game.map_settings.pollution.pollution_restored_per_tree_damage = 0.02 + game.map_settings.pollution.min_pollution_to_damage_trees = 1 + game.map_settings.pollution.max_pollution_to_restore_trees = 0 + game.map_settings.pollution.pollution_with_max_forest_damage = 10 + game.map_settings.pollution.pollution_per_tree_damage = 0.1 + game.map_settings.pollution.ageing = 0.1 + game.map_settings.pollution.diffusion_ratio = 0.1 + game.map_settings.pollution.enemy_attack_pollution_consumption_modifier = 5 + game.map_settings.unit_group.min_group_gathering_time = 1800 + game.map_settings.unit_group.max_group_gathering_time = 18000 + game.map_settings.unit_group.max_wait_time_for_late_members = 600 + game.map_settings.path_finder.general_entity_collision_penalty = 1 + game.map_settings.path_finder.general_entity_subsequent_collision_penalty = 1 + game.map_settings.path_finder.short_cache_size = 20 + game.map_settings.path_finder.long_cache_size = 100 + game.map_settings.unit_group.max_gathering_unit_groups = 10 + game.forces.neutral.character_inventory_slots_bonus = 500 + game.forces.enemy.evolution_factor = 0.0001 + game.forces.scrapyard.set_friend('enemy', true) + game.forces.enemy.set_friend('scrapyard', true) + game.forces.enemy.set_ammo_damage_modifier('rocket', -0.5) + game.forces.player.technologies['land-mine'].enabled = false + game.forces.player.technologies['landfill'].enabled = false + game.forces.player.technologies['cliff-explosives'].enabled = false + game.forces.player.technologies['fusion-reactor-equipment'].enabled = false + game.forces.player.technologies['power-armor-mk2'].enabled = false + game.forces.player.technologies['railway'].researched = true + game.forces.player.recipes['pistol'].enabled = false + game.forces.player.ghost_time_to_live = 15 * 60 * 60 end function Public.set_difficulty_settings() @@ -244,8 +244,7 @@ function Public.process_jump() objective.chronojumps = objective.chronojumps + 1 objective.passivetimer = 0 objective.chronochargesneeded = Balance.MJ_needed_for_full_charge(Difficulty.get().difficulty_vote_value, objective.chronojumps) - objective.passive_chronocharge_rate = - Balance.MJ_needed_for_full_charge(Difficulty.get().difficulty_vote_value, objective.chronojumps) / Balance.passive_planet_jumptime(objective.chronojumps) + objective.passive_chronocharge_rate = Balance.MJ_needed_for_full_charge(Difficulty.get().difficulty_vote_value, objective.chronojumps) / Balance.passive_planet_jumptime(objective.chronojumps) bitertable.active_biters = {} bitertable.unit_groups = {} bitertable.biter_raffle = {} @@ -274,10 +273,7 @@ function Public.process_jump() objective.computermessage = 5 game.play_sound {path = 'utility/new_objective', volume_modifier = 0.85} end - if - (objective.passivetimer - 180) * objective.passive_chronocharge_rate > objective.chronochargesneeded * 0.75 and - objective.chronojumps >= Balance.jumps_until_overstay_is_on(Difficulty.get().difficulty_vote_value) - then + if (objective.passivetimer - 180) * objective.passive_chronocharge_rate > objective.chronochargesneeded * 0.75 and objective.chronojumps >= Balance.jumps_until_overstay_is_on(Difficulty.get().difficulty_vote_value) then game.print({'chronosphere.message_overstay'}, {r = 0.98, g = 0.36, b = 0.22}) end if objective.world.id == 2 and objective.world.variant.id == 2 then @@ -407,7 +403,12 @@ local function create_chunk_list(surface) chunks[#chunks + 1] = {pos = {x, y}, generated = surface.is_chunk_generated({x, y}), distance = math.sqrt(x * x + y * y)} end end - for k, v in Rand.spairs(chunks, function(t, a, b) return t[b].distance > t[a].distance end) do + for k, v in Rand.spairs( + chunks, + function(t, a, b) + return t[b].distance > t[a].distance + end + ) do if v.generated == false then schedule.chunks_to_generate[#schedule.chunks_to_generate + 1] = v end @@ -415,24 +416,24 @@ local function create_chunk_list(surface) end function Public.setup_world(surface) - local objective = Chrono_table.get_table() - local world = objective.world - if objective.chronojumps <= 2 then - surface.min_brightness = 0.5 - else - surface.min_brightness = 0 - end - surface.brightness_visual_weights = {1, 1, 1} - objective.surface = surface - surface.daytime = world.daytime - local timer = world.dayspeed.timer - if timer == 0 then - surface.freeze_daytime = true - timer = timer + 1 - else - surface.freeze_daytime = false - end - surface.ticks_per_day = timer * 250 + local objective = Chrono_table.get_table() + local world = objective.world + if objective.chronojumps <= 2 then + surface.min_brightness = 0.5 + else + surface.min_brightness = 0 + end + surface.brightness_visual_weights = {1, 1, 1} + objective.surface = surface + surface.daytime = world.daytime + local timer = world.dayspeed.timer + if timer == 0 then + surface.freeze_daytime = true + timer = timer + 1 + else + surface.freeze_daytime = false + end + surface.ticks_per_day = timer * 250 local moisture = world.variant.moisture if moisture ~= 0 then diff --git a/maps/chronosphere/config_tab.lua b/maps/chronosphere/config_tab.lua index 6618fcb8..88ff6dfa 100644 --- a/maps/chronosphere/config_tab.lua +++ b/maps/chronosphere/config_tab.lua @@ -3,9 +3,10 @@ local Chrono_table = require 'maps.chronosphere.table' local Chrono = require 'maps.chronosphere.chrono' local Token = require 'utils.token' -local Tabs = require 'comfy_panel.main' +local Event = require 'utils.event' +local Gui = require 'utils.gui' -local module_name = 'ChronoTrain' +local module_name = Gui.uid_name() local functions = { ['comfy_panel_offline_accidents'] = function(event) @@ -230,7 +231,14 @@ local function on_gui_click(event) end end -Tabs.add_tab_to_gui({name = module_name, id = build_config_gui_token, admin = true}) +Gui.add_tab_to_gui({name = module_name, caption = 'ChronoTrain', id = build_config_gui_token, admin = true}) -local event = require 'utils.event' -event.add(defines.events.on_gui_click, on_gui_click) +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) + +Event.add(defines.events.on_gui_click, on_gui_click) diff --git a/maps/crab_defender/main.lua b/maps/crab_defender/main.lua index 7d31a9ef..1bf5da96 100644 --- a/maps/crab_defender/main.lua +++ b/maps/crab_defender/main.lua @@ -16,10 +16,10 @@ local Map = require 'modules.map_info' local Event = require 'utils.event' local Reset = require 'functions.soft_reset' local Server = require 'utils.server' -local Poll = require 'comfy_panel.poll' +local Poll = require 'utils.gui.poll' local boss_biter = require 'maps.crab_defender.boss_biters' local FDT = require 'maps.crab_defender.table' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local math_random = math.random local insert = table.insert local enable_start_grace_period = true diff --git a/maps/fish_defender/main.lua b/maps/fish_defender/main.lua index fe9cf2c7..76889fcd 100644 --- a/maps/fish_defender/main.lua +++ b/maps/fish_defender/main.lua @@ -21,10 +21,10 @@ local Map = require 'modules.map_info' local Event = require 'utils.event' local Reset = require 'functions.soft_reset' local Server = require 'utils.server' -local Poll = require 'comfy_panel.poll' +local Poll = require 'utils.gui.poll' local boss_biter = require 'maps.fish_defender.boss_biters' local FDT = require 'maps.fish_defender.table' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local math_random = math.random local insert = table.insert local enable_start_grace_period = true diff --git a/maps/fish_defender_v1/fish_defender.lua b/maps/fish_defender_v1/fish_defender.lua index 4d81aa24..9cce343d 100644 --- a/maps/fish_defender_v1/fish_defender.lua +++ b/maps/fish_defender_v1/fish_defender.lua @@ -17,7 +17,7 @@ require 'modules.biter_evasion_hp_increaser' local event = require 'utils.event' local Server = require 'utils.server' local boss_biter = require 'maps.fish_defender.boss_biters' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' require 'functions.boss_unit' local map_functions = require 'tools.map_functions' local Difficulty = require 'modules.difficulty_vote' diff --git a/maps/fish_defender_v2/main.lua b/maps/fish_defender_v2/main.lua index bcfef817..15191976 100644 --- a/maps/fish_defender_v2/main.lua +++ b/maps/fish_defender_v2/main.lua @@ -14,8 +14,8 @@ local Event = require 'utils.event' local Reset = require 'functions.soft_reset' local Server = require 'utils.server' local Session = require 'utils.datastore.session_data' -local Poll = require 'comfy_panel.poll' -local Score = require 'comfy_panel.score' +local Poll = require 'utils.gui.poll' +local Score = require 'utils.gui.score' local AntiGrief = require 'utils.antigrief' local Core = require 'utils.core' local format_number = require 'util'.format_number diff --git a/maps/junkyard_pvp/main.lua b/maps/junkyard_pvp/main.lua index 2a3ddeb4..49e4ae33 100644 --- a/maps/junkyard_pvp/main.lua +++ b/maps/junkyard_pvp/main.lua @@ -1,8 +1,8 @@ --luacheck: ignore -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' local Map_score = require 'modules.map_score' local Terrain = require 'maps.junkyard_pvp.terrain' -local Gui = require 'maps.junkyard_pvp.gui' +local MapGui = require 'maps.junkyard_pvp.gui' require 'maps.junkyard_pvp.surrounded_by_worms' require 'modules.flashlight_toggle_button' require 'modules.rocks_heal_over_time' @@ -65,7 +65,7 @@ function Public.reset_map() Team.set_player_to_spectator(player) end for _, player in pairs(game.forces.spectator.players) do - Gui.rejoin_question(player) + MapGui.rejoin_question(player) end set_player_colors() @@ -119,7 +119,7 @@ local function on_entity_died(event) for _, child in pairs(player.gui.left.children) do child.destroy() end - Tabs.comfy_panel_call_tab(player, 'Map Scores') + Gui.call_existing_tab(player, 'Map Scores') end end end @@ -129,7 +129,7 @@ local function on_player_joined_game(event) local surface = game.surfaces[global.active_surface_index] set_player_colors() - Gui.spectate_button(player) + MapGui.spectate_button(player) if player.surface.index ~= global.active_surface_index then if player.force.name == 'spectator' then diff --git a/maps/labyrinth.lua b/maps/labyrinth.lua index 7553ba35..e87ce7c7 100644 --- a/maps/labyrinth.lua +++ b/maps/labyrinth.lua @@ -10,11 +10,11 @@ local Server = require 'utils.server' local Global = require 'utils.global' local map_functions = require 'tools.map_functions' local simplex_noise = require 'utils.simplex_noise'.d2 -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local unique_rooms = require 'maps.labyrinth_unique_rooms' local SoftReset = require 'functions.soft_reset' local Autostash = require 'modules.autostash' -local BottomFrame = require 'comfy_panel.bottom_frame' +local BottomFrame = require 'utils.gui.bottom_frame' local this = { settings = { labyrinth_size = 1, @@ -517,10 +517,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore end end end - placed_enemies = - #entities_to_place.biters * 0.35 + #entities_to_place.spitters * 0.35 + #entities_to_place.enemy_buildings * 2 + #entities_to_place.worms * 3 + - #entities_to_place.gun_turrets * 3 + - #entities_to_place.allied_entities + placed_enemies = #entities_to_place.biters * 0.35 + #entities_to_place.spitters * 0.35 + #entities_to_place.enemy_buildings * 2 + #entities_to_place.worms * 3 + #entities_to_place.gun_turrets * 3 + #entities_to_place.allied_entities end for x = 0, 31, 1 do --luacheck: ignore @@ -570,10 +567,7 @@ local function grow_cell(chunk_position, surface) -- luacheck: ignore table.insert(entities_to_place.spitters, {left_top_x + e.position.x, left_top_y + e.position.y}) break end - table.insert( - entities_to_place.misc, - {name = e.name, position = {left_top_x + e.position.x, left_top_y + e.position.y}, direction = e.direction, force = e.force} - ) + table.insert(entities_to_place.misc, {name = e.name, position = {left_top_x + e.position.x, left_top_y + e.position.y}, direction = e.direction, force = e.force}) break end end @@ -1055,8 +1049,7 @@ local function on_entity_died(event) if game.forces.enemy.evolution_factor < 0.5 then local evolution_drop_modifier = (0.1 - game.forces.enemy.evolution_factor) * 10 if evolution_drop_modifier > 0 then - local amount = - math.ceil(math.random(entity_drop_amount[event.entity.name].low, entity_drop_amount[event.entity.name].high) * evolution_drop_modifier) + local amount = math.ceil(math.random(entity_drop_amount[event.entity.name].low, entity_drop_amount[event.entity.name].high) * evolution_drop_modifier) event.entity.surface.spill_item_stack(event.entity.position, {name = ore_spill_raffle[math.random(1, #ore_spill_raffle)], count = amount}, true) end end @@ -1291,8 +1284,7 @@ local function on_built_entity(event) if get_score then if get_score[player.force.name] then if get_score[player.force.name].players[player.name] then - get_score[player.force.name].players[player.name].built_entities = - get_score[player.force.name].players[player.name].built_entities - 1 + get_score[player.force.name].players[player.name].built_entities = get_score[player.force.name].players[player.name].built_entities - 1 end end end diff --git a/maps/minesweeper/main.lua b/maps/minesweeper/main.lua index 8224dc85..29ab396f 100644 --- a/maps/minesweeper/main.lua +++ b/maps/minesweeper/main.lua @@ -13,7 +13,7 @@ Cell Values: require 'modules.satellite_score' local Functions = require 'maps.minesweeper.functions' -local Map_score = require 'comfy_panel.map_score' +local Map_score = require 'utils.gui.map_score' local Map = require 'modules.map_info' local Global = require 'utils.global' diff --git a/maps/mountain_fortress_v2/main.lua b/maps/mountain_fortress_v2/main.lua index 65ae5cc7..b89df14e 100644 --- a/maps/mountain_fortress_v2/main.lua +++ b/maps/mountain_fortress_v2/main.lua @@ -7,8 +7,8 @@ local darkness = false require 'functions.soft_reset' require 'functions.basic_markets' -local ComfyPanel = require 'comfy_panel.main' -local Map_score = require 'comfy_panel.map_score' +local Gui = require 'utils.gui' +local Map_score = require 'utils.gui.map_score' local Collapse = require 'modules.collapse' local RPG = require 'modules.rpg' require 'modules.wave_defense.main' @@ -54,7 +54,7 @@ local function game_over() global.game_reset_tick = game.tick + 1800 for _, player in pairs(game.connected_players) do player.play_sound {path = 'utility/game_lost', volume_modifier = 0.80} - ComfyPanel.comfy_panel_call_tab(player, 'Map Scores') + Gui.call_existing_tab(player, 'Map Scores') end end diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index 3c0a42f2..d77584ed 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -14,7 +14,7 @@ local DefenseSystem = require 'maps.mountain_fortress_v3.locomotive.defense_syst local Collapse = require 'modules.collapse' local Alert = require 'utils.alert' local Task = require 'utils.task' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local Token = require 'utils.token' -- local HS = require 'maps.mountain_fortress_v3.highscore' local Discord = require 'utils.discord' @@ -1153,8 +1153,7 @@ local function show_mvps(player) local miners_label = t.add({type = 'label', caption = 'Miners >> '}) miners_label.style.font = 'default-listbox' miners_label.style.font_color = {r = 0.22, g = 0.77, b = 0.44} - local miners_label_text = - t.add({type = 'label', caption = mvp.mined_entities.name .. ' mined a total of ' .. mvp.mined_entities.score .. ' entities!'}) + local miners_label_text = t.add({type = 'label', caption = mvp.mined_entities.name .. ' mined a total of ' .. mvp.mined_entities.score .. ' entities!'}) miners_label_text.style.font = 'default-bold' miners_label_text.style.font_color = {r = 0.33, g = 0.66, b = 0.9} diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 2bfef1a6..2be282db 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -1281,10 +1281,10 @@ function Public.on_player_joined_game(event) end end - local top = player.gui.top - if top['mod_gui_top_frame'] then - top['mod_gui_top_frame'].destroy() - end + -- local top = player.gui.top + -- if top['mod_gui_top_frame'] then + -- top['mod_gui_top_frame'].destroy() + -- end if player.surface.index ~= active_surface_index then player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface) diff --git a/maps/mountain_fortress_v3/gui.lua b/maps/mountain_fortress_v3/gui.lua index 32f17f7d..9a159c97 100644 --- a/maps/mountain_fortress_v3/gui.lua +++ b/maps/mountain_fortress_v3/gui.lua @@ -3,6 +3,7 @@ local RPG = require 'modules.rpg.main' local WPT = require 'maps.mountain_fortress_v3.table' local IC_Gui = require 'maps.mountain_fortress_v3.ic.gui' local IC_Minimap = require 'maps.mountain_fortress_v3.ic.minimap' +local Difficulty = require 'modules.difficulty_vote_by_amount' local Gui = require 'utils.gui' local SpamProtection = require 'utils.spam_protection' @@ -195,7 +196,7 @@ local function on_gui_click(event) if player.gui.top[main_frame_name] then local info = player.gui.top[main_frame_name] local wd = player.gui.top['wave_defense'] - local diff = player.gui.top['difficulty_gui'] + local diff = player.gui.top[Difficulty.top_button_name] if info and info.visible then if wd then @@ -256,7 +257,7 @@ local function on_player_changed_surface(event) local rpg_b = player.gui.top[rpg_button] local rpg_f = player.gui.screen[rpg_frame] local rpg_s = player.gui.screen[rpg_settings] - local diff = player.gui.top['difficulty_gui'] + local diff = player.gui.top[Difficulty.top_button_name] local charging = player.gui.top['charging_station'] local frame = player.gui.top[main_frame_name] local spell_gui_frame_name = RPG.spell_gui_frame_name @@ -356,7 +357,7 @@ local function enable_guis(event) local info = player.gui.top[main_button_name] local wd = player.gui.top['wave_defense'] local rpg_b = player.gui.top[rpg_button] - local diff = player.gui.top['difficulty_gui'] + local diff = player.gui.top[Difficulty.top_button_name] local charging = player.gui.top['charging_station'] IC_Gui.remove_toolbar(player) @@ -437,8 +438,7 @@ function Public.update_gui(player) gui.landmine.caption = ' [img=entity.land-mine]: ' .. format_number(upgrades.landmine.built, true) .. ' / ' .. format_number(upgrades.landmine.limit, true) gui.landmine.tooltip = ({'gui.land_mine_placed'}) - gui.flame_turret.caption = - ' [img=entity.flamethrower-turret]: ' .. format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true) + gui.flame_turret.caption = ' [img=entity.flamethrower-turret]: ' .. format_number(upgrades.flame_turret.built, true) .. ' / ' .. format_number(upgrades.flame_turret.limit, true) gui.flame_turret.tooltip = ({'gui.flamethrowers_placed'}) gui.train_upgrades.caption = ' [img=entity.locomotive]: ' .. format_number(train_upgrades, true) diff --git a/maps/mountain_fortress_v3/highscore.lua b/maps/mountain_fortress_v3/highscore.lua index ee975add..73b68925 100644 --- a/maps/mountain_fortress_v3/highscore.lua +++ b/maps/mountain_fortress_v3/highscore.lua @@ -2,14 +2,14 @@ local Event = require 'utils.event' local Global = require 'utils.global' local Server = require 'utils.server' local Token = require 'utils.token' -local Tabs = require 'comfy_panel.main' -local Score = require 'comfy_panel.score' +local Gui = require 'utils.gui' +local Score = require 'utils.gui.score' local WPT = require 'maps.mountain_fortress_v3.table' local WD = require 'modules.wave_defense.table' local Core = require 'utils.core' local SpamProtection = require 'utils.spam_protection' -local module_name = 'Highscore' +local module_name = Gui.uid_name() local score_dataset = 'highscores' local score_key = 'mountain_fortress_v3_scores' local set_data = Server.set_data @@ -609,22 +609,18 @@ end local show_score_token = Token.register(show_score) local function on_gui_click(event) - if not event then - return - end - if not event.element then - return - end - if not event.element.valid then + local element = event.element + if not element or not element.valid then return end - local player = game.players[event.element.player_index] - local frame = Tabs.comfy_panel_get_active_frame(player) + local player = game.get_player(event.element.player_index) + + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Highscore' then return end @@ -681,7 +677,15 @@ Server.on_data_set_changed( end ) -Tabs.add_tab_to_gui({name = module_name, id = show_score_token, admin = false, only_server_sided = true}) +Gui.add_tab_to_gui({name = module_name, caption = 'Highscore', id = show_score_token, admin = false, only_server_sided = true}) + +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) Event.on_init(on_init) Event.add(defines.events.on_player_left_game, on_player_left_game) diff --git a/maps/mountain_fortress_v3/ic/gui.lua b/maps/mountain_fortress_v3/ic/gui.lua index 9c8cec1a..ccb4b8ac 100644 --- a/maps/mountain_fortress_v3/ic/gui.lua +++ b/maps/mountain_fortress_v3/ic/gui.lua @@ -2,7 +2,7 @@ local ICT = require 'maps.mountain_fortress_v3.ic.table' local Functions = require 'maps.mountain_fortress_v3.ic.functions' local Color = require 'utils.color_presets' local Gui = require 'utils.gui' -local Tabs = require 'comfy_panel.main' +local Tabs = require 'utils.gui' local Event = require 'utils.event' local Token = require 'utils.token' local Task = require 'utils.task' @@ -464,7 +464,7 @@ local function toggle(player, recreate) if main_frame then remove_main_frame(main_frame) else - Tabs.comfy_panel_clear_gui(player) + Tabs.clear_all_active_frames(player) draw_main_frame(player) end end @@ -813,10 +813,7 @@ Gui.on_click( if not misc_settings[player.index].final_warning then misc_settings[player.index].final_warning = true - player.print( - '[IC] WARNING! WARNING WARNING! Pressing the save button ONE MORE TIME will DELETE your surface. This action is irreversible!', - Color.red - ) + player.print('[IC] WARNING! WARNING WARNING! Pressing the save button ONE MORE TIME will DELETE your surface. This action is irreversible!', Color.red) Task.set_timeout_in_ticks(600, clear_misc_settings, {player_index = player.index}) return end diff --git a/maps/mountain_fortress_v3/locomotive/market.lua b/maps/mountain_fortress_v3/locomotive/market.lua index 37026bad..6b821bfa 100644 --- a/maps/mountain_fortress_v3/locomotive/market.lua +++ b/maps/mountain_fortress_v3/locomotive/market.lua @@ -19,6 +19,7 @@ local Public = {} local concat = table.concat local main_frame_name = Gui.uid_name() +local close_market_gui_name = Gui.uid_name() local random = math.random local round = math.round @@ -793,31 +794,21 @@ local function gui_opened(event) if data.frame then data.frame = nil end - local frame = - player.gui.screen.add( - { - type = 'frame', - caption = ({'locomotive.market_name'}), - direction = 'vertical', - name = main_frame_name - } - ) + local frame, inside_table = Gui.add_main_frame_with_toolbar(player, 'screen', main_frame_name, nil, close_market_gui_name, 'Market') frame.auto_center = true player.opened = frame - frame.style.minimal_width = 325 - frame.style.minimal_height = 250 - local search_table = frame.add({type = 'table', column_count = 2}) + local search_table = inside_table.add({type = 'table', column_count = 2}) search_table.add({type = 'label', caption = ({'locomotive.search_text'})}) local search_text = search_table.add({type = 'textfield'}) search_text.style.width = 140 - add_space(frame) + add_space(inside_table) local pane = - frame.add { + inside_table.add { type = 'scroll-pane', direction = 'vertical', vertical_scroll_policy = 'always', @@ -828,11 +819,11 @@ local function gui_opened(event) pane.style.minimal_height = 200 pane.style.right_padding = 0 - local flow = frame.add({type = 'flow'}) + local flow = inside_table.add({type = 'flow'}) add_space(flow) - local bottom_grid = frame.add({type = 'table', column_count = 4}) + local bottom_grid = inside_table.add({type = 'table', column_count = 4}) bottom_grid.style.vertically_stretchable = false local bg = bottom_grid.add({type = 'label', caption = ({'locomotive.quantity_text'})}) @@ -848,7 +839,7 @@ local function gui_opened(event) text_input.style.maximal_height = 28 local slider = - frame.add( + inside_table.add( { type = 'slider', minimum_value = 1, @@ -859,7 +850,7 @@ local function gui_opened(event) slider.style.width = 115 text_input.style.width = 60 - local coinsleft = frame.add({type = 'flow'}) + local coinsleft = inside_table.add({type = 'flow'}) coinsleft.add( { @@ -871,7 +862,7 @@ local function gui_opened(event) players[player.index].data.search_text = search_text players[player.index].data.text_input = text_input players[player.index].data.slider = slider - players[player.index].data.frame = frame + players[player.index].data.frame = inside_table players[player.index].data.item_frame = pane players[player.index].data.coins_left = coinsleft @@ -1480,6 +1471,17 @@ local function tick() end end +Gui.on_click( + close_market_gui_name, + function(event) + local player = event.player + if not player or not player.valid or not player.character then + return + end + close_market_gui(player) + end +) + Event.on_nth_tick(5, tick) Event.add(defines.events.on_gui_click, gui_click) Event.add(defines.events.on_gui_value_changed, slider_changed) diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index 384809ab..d3d4e768 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -13,8 +13,8 @@ local Discord = require 'utils.discord' local IC = require 'maps.mountain_fortress_v3.ic.table' local ICMinimap = require 'maps.mountain_fortress_v3.ic.minimap' local Autostash = require 'modules.autostash' -local Group = require 'comfy_panel.group' -local PL = require 'comfy_panel.player_list' +local Group = require 'utils.gui.group' +local PL = require 'utils.gui.player_list' local CS = require 'maps.mountain_fortress_v3.surface' local Server = require 'utils.server' local Explosives = require 'modules.explosives' @@ -29,14 +29,14 @@ local Event = require 'utils.event' local WPT = require 'maps.mountain_fortress_v3.table' local Locomotive = require 'maps.mountain_fortress_v3.locomotive' local SpawnLocomotive = require 'maps.mountain_fortress_v3.locomotive.spawn_locomotive' -local Score = require 'comfy_panel.score' -local Poll = require 'comfy_panel.poll' +local Score = require 'utils.gui.score' +local Poll = require 'utils.gui.poll' local Collapse = require 'modules.collapse' local Difficulty = require 'modules.difficulty_vote_by_amount' local Task = require 'utils.task' local Token = require 'utils.token' local Alert = require 'utils.alert' -local BottomFrame = require 'comfy_panel.bottom_frame' +local BottomFrame = require 'utils.gui.bottom_frame' local AntiGrief = require 'utils.antigrief' local Misc = require 'utils.commands.misc' local Modifiers = require 'utils.player_modifiers' diff --git a/maps/mountain_race/main.lua b/maps/mountain_race/main.lua index e5a9488d..3bc128a9 100644 --- a/maps/mountain_race/main.lua +++ b/maps/mountain_race/main.lua @@ -2,7 +2,7 @@ require 'modules.biters_yield_ore' require 'modules.rocks_yield_ore_veins' -local Map_score = require 'comfy_panel.map_score' +local Map_score = require 'utils.gui.map_score' local Collapse = require 'modules.collapse' local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main' local Terrain = require 'maps.mountain_race.terrain' diff --git a/maps/native_war/main.lua b/maps/native_war/main.lua index 0646f6a4..b74074c7 100644 --- a/maps/native_war/main.lua +++ b/maps/native_war/main.lua @@ -2,12 +2,12 @@ require 'modules.biter_reanimator' require 'maps.native_war.share_chat' require 'maps.native_war.mineable_wreckage_yields_scrap' +require 'maps.native_war.gui' local Global = require 'utils.global' -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' local Map_score = require 'modules.map_score' local Team = require 'maps.native_war.team' local Terrain = require 'maps.native_war.terrain' -local Gui = require 'maps.native_war.gui' local Init = require 'maps.native_war.init' local Settings = require 'maps.native_war.settings' local Reset = require 'functions.soft_reset' @@ -343,7 +343,7 @@ local function on_entity_died(event) for _, child in pairs(player.gui.left.children) do child.destroy() end - Tabs.comfy_panel_call_tab(player, 'Map Scores') + Gui.call_existing_tab(player, 'Map Scores') end end @@ -549,12 +549,10 @@ local function on_entity_damaged(event) if entity.type == 'unit' or entity.type == 'turret' then if cause.type == 'unit' then if cause.name == 'small-biter' or cause.name == 'medium-biter' or cause.name == 'big-biter' or cause.name == 'behemoth-biter' then - local modified_damage = - event.original_damage_amount * global.map_forces[cause.force.name].modifier.damage * global.map_forces[entity.force.name].modifier.resistance + local modified_damage = event.original_damage_amount * global.map_forces[cause.force.name].modifier.damage * global.map_forces[entity.force.name].modifier.resistance entity.health = entity.health - modified_damage elseif cause.name == 'small-spitter' or cause.name == 'medium-spitter' or cause.name == 'big-spitter' or cause.name == 'behemoth-spitter' then - local modified_damage = - event.original_damage_amount * global.map_forces[cause.force.name].modifier.splash * global.map_forces[entity.force.name].modifier.resistance + local modified_damage = event.original_damage_amount * global.map_forces[cause.force.name].modifier.splash * global.map_forces[entity.force.name].modifier.resistance entity.health = entity.health - modified_damage end end diff --git a/maps/pidgeotto/main.lua b/maps/pidgeotto/main.lua index b6e40382..caac57f1 100644 --- a/maps/pidgeotto/main.lua +++ b/maps/pidgeotto/main.lua @@ -15,10 +15,10 @@ local Map = require 'modules.map_info' local Event = require 'utils.event' local Reset = require 'functions.soft_reset' local Server = require 'utils.server' -local Poll = require 'comfy_panel.poll' +local Poll = require 'utils.gui.poll' local boss_biter = require 'maps.pidgeotto.boss_biters' local FDT = require 'maps.pidgeotto.table' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local AntiGrief = require 'utils.antigrief' local math_random = math.random local insert = table.insert diff --git a/maps/planet_prison.lua b/maps/planet_prison.lua index 066bf6c2..0827f82d 100644 --- a/maps/planet_prison.lua +++ b/maps/planet_prison.lua @@ -838,15 +838,7 @@ local function on_gui_click(e) return end - if elem.name == 'comfy_panel_top_button' then - if not p.admin then - if p.gui.left['comfy_panel'] and p.gui.left['comfy_panel'].valid then - p.gui.left['comfy_panel'].destroy() - end - redraw_gui(p) - return p.print('Comfy panel is disabled in this scenario.', Color.fail) - end - elseif elem.name == 'chat_toggle' then + if elem.name == 'chat_toggle' then if perks.chat_global then elem.caption = 'NAP chat' perks.chat_global = false diff --git a/maps/scrap_towny_ffa/main.lua b/maps/scrap_towny_ffa/main.lua index 095a7a2d..363bba41 100644 --- a/maps/scrap_towny_ffa/main.lua +++ b/maps/scrap_towny_ffa/main.lua @@ -20,7 +20,7 @@ require 'modules.scrap_towny_ffa.turrets_drop_ammo' require 'modules.scrap_towny_ffa.combat_balance' local Autostash = require 'modules.autostash' -local BottomFrame = require 'comfy_panel.bottom_frame' +local BottomFrame = require 'utils.gui.bottom_frame' local Table = require 'modules.scrap_towny_ffa.table' local Nauvis = require 'modules.scrap_towny_ffa.nauvis' local Biters = require 'modules.scrap_towny_ffa.biters' @@ -40,11 +40,17 @@ local max_ticks_between_spawns = 60 * 10 local min_players_for_enabling_towns = 0 local function load_buffs(player) - if player.force.name ~= 'player' and player.force.name ~= 'rogue' then return end + if player.force.name ~= 'player' and player.force.name ~= 'rogue' then + return + end local ffatable = Table.get_table() local player_index = player.index - if player.character == nil then return end - if ffatable.buffs[player_index] == nil then ffatable.buffs[player_index] = {} end + if player.character == nil then + return + end + if ffatable.buffs[player_index] == nil then + ffatable.buffs[player_index] = {} + end if ffatable.buffs[player_index].character_inventory_slots_bonus ~= nil then player.character.character_inventory_slots_bonus = ffatable.buffs[player_index].character_inventory_slots_bonus end @@ -65,14 +71,14 @@ local function on_player_joined_game(event) player.game_view_settings.show_map_view_options = false player.game_view_settings.show_entity_info = true player.map_view_settings = { - ["show-logistic-network"] = false, - ["show-electric-network"] = false, - ["show-turret-range"] = false, - ["show-pollution"] = false, - ["show-train-station-names"] = false, - ["show-player-names"] = false, - ["show-networkless-logistic-members"] = false, - ["show-non-standard-map-info"] = false + ['show-logistic-network'] = false, + ['show-electric-network'] = false, + ['show-turret-range'] = false, + ['show-pollution'] = false, + ['show-train-station-names'] = false, + ['show-player-names'] = false, + ['show-networkless-logistic-members'] = false, + ['show-non-standard-map-info'] = false } player.show_on_map = false --player.game_view_settings.show_side_menu = false @@ -89,19 +95,21 @@ local function on_player_joined_game(event) ffatable.towns_enabled = true else ffatable.players = ffatable.players + 1 - if ffatable.players >= min_players_for_enabling_towns then ffatable.towns_enabled = true end + if ffatable.players >= min_players_for_enabling_towns then + ffatable.towns_enabled = true + end end player.teleport({0, 0}, game.surfaces['limbo']) Team.set_player_to_outlander(player) Team.give_player_items(player) - player.insert{name="coin", count="100"} - player.insert{name="stone-furnace", count="1"} + player.insert {name = 'coin', count = '100'} + player.insert {name = 'stone-furnace', count = '1'} Team.give_key(player.index) if (testing_mode == true) then player.cheat_mode = true player.force.research_all_technologies() - player.insert{name="coin", count="9900"} + player.insert {name = 'coin', count = '9900'} end -- first time spawn point local spawn_point = Spawn.get_new_spawn_point(player, surface) @@ -150,7 +158,9 @@ end local function on_player_died(event) local ffatable = Table.get_table() local player = game.players[event.player_index] - if ffatable.strikes[player.name] == nil then ffatable.strikes[player.name] = 0 end + if ffatable.strikes[player.name] == nil then + ffatable.strikes[player.name] = 0 + end local ticks_elapsed = game.tick - ffatable.last_respawn[player.name] if ticks_elapsed < max_ticks_between_spawns then diff --git a/modules/autostash.lua b/modules/autostash.lua index 8fe5ccbf..a6683ffa 100644 --- a/modules/autostash.lua +++ b/modules/autostash.lua @@ -4,8 +4,8 @@ local Global = require 'utils.global' local SpamProtection = require 'utils.spam_protection' local Event = require 'utils.event' -local BottomFrame = require 'comfy_panel.bottom_frame' -local ComfyGui = require 'comfy_panel.main' +local BottomFrame = require 'utils.gui.bottom_frame' +local ComfyGui = require 'utils.gui' local floor = math.floor local print_color = {r = 120, g = 255, b = 0} diff --git a/modules/difficulty_vote_by_amount.lua b/modules/difficulty_vote_by_amount.lua index 98fe60e0..0b6714b1 100644 --- a/modules/difficulty_vote_by_amount.lua +++ b/modules/difficulty_vote_by_amount.lua @@ -1,4 +1,5 @@ local Event = require 'utils.event' +local Gui = require 'utils.gui' local Server = require 'utils.server' local Global = require 'utils.global' local SpamProtection = require 'utils.spam_protection' @@ -6,6 +7,11 @@ local SpamProtection = require 'utils.spam_protection' local max = math.max local round = math.round +local main_frame_name = Gui.uid_name() +local selection_button_name = Gui.uid_name() +local close_main_frame = Gui.uid_name() +local top_button_name = Gui.uid_name() + local this = { difficulties = { [1] = { @@ -64,21 +70,29 @@ Global.register( end ) +local function clear_main_frame(player) + local screen = player.gui.center + if screen[main_frame_name] and screen[main_frame_name].valid then + screen[main_frame_name].destroy() + end +end + function Public.difficulty_gui() local tooltip = 'Current difficulty of the map is ' .. this.difficulties[this.difficulty_vote_index].name .. '.' for _, player in pairs(game.connected_players) do - if player.gui.top['difficulty_gui'] then - player.gui.top['difficulty_gui'].caption = this.difficulties[this.difficulty_vote_index].name - player.gui.top['difficulty_gui'].tooltip = this.button_tooltip or tooltip - player.gui.top['difficulty_gui'].style.font_color = this.difficulties[this.difficulty_vote_index].print_color + local top = player.gui.top + if top[top_button_name] then + top[top_button_name].caption = this.difficulties[this.difficulty_vote_index].name + top[top_button_name].tooltip = this.button_tooltip or tooltip + top[top_button_name].style.font_color = this.difficulties[this.difficulty_vote_index].print_color else local b = - player.gui.top.add { + top.add { type = 'button', caption = this.difficulties[this.difficulty_vote_index].name, tooltip = tooltip, - name = 'difficulty_gui' + name = top_button_name } b.style.font = 'heading-2' b.style.font_color = this.difficulties[this.difficulty_vote_index].print_color @@ -130,10 +144,10 @@ local function highest_count(tbl) end local function poll_difficulty(player) - if player.gui.center['difficulty_poll'] then - player.gui.center['difficulty_poll'].destroy() - return + if player.gui.center[main_frame_name] then + clear_main_frame(player) end + if game.tick > this.difficulty_poll_closing_timeout then if player.online_time ~= 0 then local t = math.abs(math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600)) @@ -148,32 +162,49 @@ local function poll_difficulty(player) return end - local frame = - player.gui.center.add { - type = 'frame', - caption = 'Vote difficulty:', - name = 'difficulty_poll', - direction = 'vertical' - } + local _, inside_frame = Gui.add_main_frame_with_toolbar(player, 'center', main_frame_name, nil, close_main_frame, 'Difficulty') + for i = 1, #this.difficulties, 1 do - local b = frame.add({type = 'button', name = tostring(i), caption = this.difficulties[i].name}) + local button_flow = + inside_frame.add { + type = 'flow', + name = tostring(i) + } + local b = button_flow.add({type = 'button', name = selection_button_name, caption = this.difficulties[i].name}) b.style.font_color = this.difficulties[i].color b.style.font = 'heading-2' b.style.minimal_width = 160 b.tooltip = this.tooltip[i] end - frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) + + local label_flow = + inside_frame.add { + type = 'flow' + } + + label_flow.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) + + label_flow.style.horizontal_align = 'center' + label_flow.style.horizontally_stretchable = true + + local timeleft_flow = + inside_frame.add { + type = 'flow' + } + timeleft_flow.style.horizontal_align = 'center' + timeleft_flow.style.horizontally_stretchable = true + local b = - frame.add( + timeleft_flow.add( { type = 'button', - name = 'close', - caption = 'Close (' .. math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left)' + caption = math.floor((this.difficulty_poll_closing_timeout - game.tick) / 3600) .. ' minutes left.' } ) b.style.font_color = {r = 0.66, g = 0.0, b = 0.66} b.style.font = 'heading-3' b.style.minimal_width = 96 + b.enabled = false end local function set_difficulty() @@ -200,8 +231,8 @@ function Public.reset_difficulty_poll(tbl) this.difficulty_player_votes = {} this.difficulty_poll_closing_timeout = tbl.difficulty_poll_closing_timeout or game.tick + 54000 for _, p in pairs(game.connected_players) do - if p.gui.center['difficulty_poll'] then - p.gui.center['difficulty_poll'].destroy() + if p.gui.center[main_frame_name] then + clear_main_frame(p) end poll_difficulty(p) end @@ -215,8 +246,8 @@ function Public.reset_difficulty_poll(tbl) this.difficulty_player_votes = {} this.difficulty_poll_closing_timeout = game.tick + 54000 for _, p in pairs(game.connected_players) do - if p.gui.center['difficulty_poll'] then - p.gui.center['difficulty_poll'].destroy() + if p.gui.center[main_frame_name] then + clear_main_frame(p) end poll_difficulty(p) end @@ -228,15 +259,13 @@ function Public.reset_difficulty_poll(tbl) end local function on_player_joined_game(event) - local player = game.players[event.player_index] + local player = game.get_player(event.player_index) if game.tick < this.difficulty_poll_closing_timeout then if not this.difficulty_player_votes[player.name] then poll_difficulty(player) end else - if player.gui.center['difficulty_poll'] then - player.gui.center['difficulty_poll'].destroy() - end + clear_main_frame(player) end Public.difficulty_gui() end @@ -245,7 +274,7 @@ local function on_player_left_game(event) if game.tick > this.difficulty_poll_closing_timeout then return end - local player = game.players[event.player_index] + local player = game.get_player(event.player_index) if not this.difficulty_player_votes[player.name] then return end @@ -259,73 +288,6 @@ local function on_player_left_game(event) Public.difficulty_gui() end -local function on_gui_click(event) - if not event then - return - end - local player = game.players[event.player_index] - - if not event.element then - return - end - if not event.element.valid then - return - end - - if event.element.name == 'difficulty_gui' then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Difficulty Vote Gui Click') - if is_spamming then - return - end - poll_difficulty(player) - return - end - if event.element.type ~= 'button' then - return - end - if event.element.parent.name ~= 'difficulty_poll' then - return - end - if event.element.name == 'close' then - event.element.parent.destroy() - return - end - if game.tick > this.difficulty_poll_closing_timeout then - event.element.parent.destroy() - return - end - - local is_spamming = SpamProtection.is_spamming(player, nil, 'Difficulty Gui No Func') - if is_spamming then - return - end - - local i = tonumber(event.element.name) - - if this.difficulty_player_votes[player.name] and this.difficulty_player_votes[player.name].index == i then - player.print('You have already voted for ' .. this.difficulties[i].name .. '.', this.difficulties[i].print_color) - return event.element.parent.destroy() - end - - if this.difficulty_player_votes[player.name] then - local index = this.difficulty_player_votes[player.name].index - this.difficulties[index].count = this.difficulties[index].count - 1 - if this.difficulties[index].count <= 0 then - this.difficulties[index].count = 0 - end - end - - this.difficulties[i].count = this.difficulties[i].count + 1 - this.difficulty_player_votes[player.name] = {voted = true, index = i} - - set_difficulty() - Public.difficulty_gui() - event.element.parent.destroy() - local message = '*** ' .. player.name .. ' has voted for ' .. this.difficulties[i].name .. ' difficulty! ***' - game.print(message, this.difficulties[i].print_color) - Server.to_discord_embed(message) -end - function Public.set_tooltip(...) if type(...) == 'table' then this.tooltip = ... @@ -358,9 +320,94 @@ function Public.get(key) end end +Gui.on_click( + selection_button_name, + function(event) + local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Poll difficulty selection frame name') + if is_spamming then + return + end + local element = event.element + if not element or not element.valid then + return + end + + local player = event.player + if not player or not player.valid or not player.character then + return + end + + local i = tonumber(element.parent.name) + + if this.difficulty_player_votes[player.name] and this.difficulty_player_votes[player.name].index == i then + player.print('You have already voted for ' .. this.difficulties[i].name .. '.', this.difficulties[i].print_color) + clear_main_frame(player) + return + end + + if this.difficulty_player_votes[player.name] then + local index = this.difficulty_player_votes[player.name].index + this.difficulties[index].count = this.difficulties[index].count - 1 + if this.difficulties[index].count <= 0 then + this.difficulties[index].count = 0 + end + end + + this.difficulties[i].count = this.difficulties[i].count + 1 + this.difficulty_player_votes[player.name] = {voted = true, index = i} + + set_difficulty() + Public.difficulty_gui() + clear_main_frame(player) + local message = '*** ' .. player.name .. ' has voted for ' .. this.difficulties[i].name .. ' difficulty! ***' + game.print(message, this.difficulties[i].print_color) + Server.to_discord_embed(message) + end +) + +Gui.on_click( + top_button_name, + function(event) + local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Poll difficulty top button') + if is_spamming then + return + end + local player = event.player + if not player or not player.valid or not player.character then + return + end + if game.tick > this.difficulty_poll_closing_timeout then + clear_main_frame(player) + return + end + local screen = player.gui.center + if screen[main_frame_name] and screen[main_frame_name].valid then + clear_main_frame(player) + else + poll_difficulty(player) + end + end +) + +Gui.on_click( + close_main_frame, + function(event) + local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Poll difficulty close button') + if is_spamming then + return + end + local player = event.player + if not player or not player.valid or not player.character then + return + end + clear_main_frame(player) + end +) + Event.add(defines.events.on_player_created, on_player_joined_game) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_player_left_game, on_player_left_game) -Event.add(defines.events.on_gui_click, on_gui_click) + +Public.top_button_name = top_button_name return Public diff --git a/modules/map_info.lua b/modules/map_info.lua index 00d5823f..05d21730 100644 --- a/modules/map_info.lua +++ b/modules/map_info.lua @@ -1,10 +1,9 @@ local Event = require 'utils.event' local Global = require 'utils.global' -local Tabs = require 'comfy_panel.main' -local SpamProtection = require 'utils.spam_protection' +local Gui = require 'utils.gui' local Token = require 'utils.token' -local module_name = 'Map Info' +local module_name = Gui.uid_name() local map_info = { localised_category = false, @@ -85,14 +84,6 @@ local function create_map_intro(data) l_3.style.minimal_width = 780 l_3.style.horizontal_align = 'center' l_3.style.vertical_align = 'center' - - local b = frame.add {type = 'button', caption = 'CLOSE', name = 'close_map_intro'} - b.style.font = 'heading-2' - b.style.padding = 2 - b.style.top_margin = 3 - b.style.left_margin = 333 - b.style.horizontal_align = 'center' - b.style.vertical_align = 'center' end local create_map_intro_token = Token.register(create_map_intro) @@ -100,52 +91,20 @@ local create_map_intro_token = Token.register(create_map_intro) local function on_player_joined_game(event) local player = game.players[event.player_index] if player.online_time == 0 then - Tabs.comfy_panel_call_tab(player, 'Map Info') + Gui.call_existing_tab(player, 'Map Info') end end -local function on_gui_click(event) - if not event then - return - end - local player = game.get_player(event.player_index) - if not (player and player.valid) then - return - end - - if not event.element then - return - end - if not event.element.valid then - return - end - - local name = event.element.name - - if not name then - return - end - - if name == 'tab_' .. module_name then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Map Info Main Button') - if is_spamming then - return - end - end - - if name == 'close_map_intro' then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Map Info Close Button') - if is_spamming then - return - end - player.gui.left.comfy_panel.destroy() - return - end -end - -Tabs.add_tab_to_gui({name = module_name, id = create_map_intro_token, admin = false}) +Gui.add_tab_to_gui({name = module_name, caption = 'Map Info', id = create_map_intro_token, admin = false}) Event.add(defines.events.on_player_joined_game, on_player_joined_game) -Event.add(defines.events.on_gui_click, on_gui_click) + +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) return Public diff --git a/modules/rewards.lua b/modules/rewards.lua index 660cab9c..278574fc 100644 --- a/modules/rewards.lua +++ b/modules/rewards.lua @@ -5,7 +5,7 @@ local Event = require 'utils.event' local Token = require 'utils.token' local Task = require 'utils.task' -local Score = require 'comfy_panel.score' +local Score = require 'utils.gui.score' local floor = math.floor local sqrt = math.sqrt local insert = table.insert @@ -197,14 +197,10 @@ local function reward_messages(data) end local print_text = '' - player.surface.create_entity( - {name = 'flying-text', position = {player.position.x, player.position.y}, text = 'Reached Combat Level: ' .. data.next_level, color = {r = 0.2, g = 1.0, b = 0.1}} - ) + player.surface.create_entity({name = 'flying-text', position = {player.position.x, player.position.y}, text = 'Reached Combat Level: ' .. data.next_level, color = {r = 0.2, g = 1.0, b = 0.1}}) -- Loop through all of the rewards for this level and print out flying text for i = 1, #item_rewards, 1 do - player.surface.create_entity( - {name = 'flying-text', position = {player.position.x, player.position.y + (i * 0.5)}, text = item_rewards[i].text, color = {r = 1.0, g = 1.0, b = 1.0}} - ) + player.surface.create_entity({name = 'flying-text', position = {player.position.x, player.position.y + (i * 0.5)}, text = item_rewards[i].text, color = {r = 1.0, g = 1.0, b = 1.0}}) if i > 1 then print_text = item_rewards[i].text .. ' ' .. print_text else diff --git a/modules/rpg.lua b/modules/rpg.lua index d47ef18a..91cd8657 100644 --- a/modules/rpg.lua +++ b/modules/rpg.lua @@ -17,7 +17,7 @@ local math_random = math.random local math_sqrt = math.sqrt local math_floor = math.floor local Global = require 'utils.global' -local Tabs = require 'comfy_panel.main' +local Tabs = require 'utils.gui' local P = require 'utils.player_modifiers' local visuals_delay = 1800 local level_up_floating_text_color = {0, 205, 0} @@ -251,7 +251,7 @@ local function draw_gui(player, forced) end end - Tabs.comfy_panel_clear_gui(player) + Tabs.clear_all_active_frames(player) if player.gui.left.rpg then player.gui.left.rpg.destroy() diff --git a/modules/rpg/gui.lua b/modules/rpg/gui.lua index 0d54ba62..dc979c5b 100644 --- a/modules/rpg/gui.lua +++ b/modules/rpg/gui.lua @@ -1,4 +1,4 @@ -local ComfyGui = require 'comfy_panel.main' +local ComfyGui = require 'utils.gui' local Session = require 'utils.datastore.session_data' local P = require 'utils.player_modifiers' local Gui = require 'utils.gui' @@ -15,6 +15,7 @@ local experience_levels = Public.experience_levels --RPG Frames local main_frame_name = Public.main_frame_name local draw_main_frame_name = Public.draw_main_frame_name +local close_main_frame_name = Public.close_main_frame_name local settings_button_name = Public.settings_button_name local settings_frame_name = Public.settings_frame_name local discard_button_name = Public.discard_button_name @@ -102,20 +103,6 @@ local function add_gui_stat(element, value, width, tooltip, name, color) return e end -local function add_elem_stat(element, value, width, height, font, tooltip, name, color) - local e = element.add({type = 'sprite-button', name = name or nil, caption = value}) - e.tooltip = tooltip or '' - e.style.maximal_width = width - e.style.minimal_width = width - e.style.maximal_height = height - e.style.minimal_height = height - e.style.font = font or 'default-bold' - e.style.horizontal_align = 'center' - e.style.vertical_align = 'center' - e.style.font_color = color or {222, 222, 222} - return e -end - local function add_gui_increase_stat(element, name, player) local rpg_t = Public.get_value_from_player(player.index) local sprite = 'virtual-signal/signal-red' @@ -147,9 +134,9 @@ local function add_separator(element, width) return e end -local function remove_settings_frame(settings_frame) - Gui.remove_data_recursively(settings_frame) - settings_frame.destroy() +local function remove_target_frame(target_frame) + Gui.remove_data_recursively(target_frame) + target_frame.destroy() end local function remove_main_frame(main_frame, screen) @@ -158,7 +145,7 @@ local function remove_main_frame(main_frame, screen) local settings_frame = screen[settings_frame_name] if settings_frame and settings_frame.valid then - remove_settings_frame(settings_frame) + remove_target_frame(settings_frame) end end @@ -167,15 +154,8 @@ local function draw_main_frame(player, location) return end - local main_frame = - player.gui.screen.add( - { - type = 'frame', - name = main_frame_name, - caption = 'RPG', - direction = 'vertical' - } - ) + local main_frame, inside_frame = Gui.add_main_frame_with_toolbar(player, 'screen', main_frame_name, settings_button_name, close_main_frame_name, 'RPG') + if location then main_frame.location = location else @@ -186,23 +166,8 @@ local function draw_main_frame(player, location) local rpg_extra = Public.get('rpg_extra') local rpg_t = Public.get_value_from_player(player.index) - local inside_frame = - main_frame.add { - type = 'frame', - style = 'deep_frame_in_shallow_frame' - } - local inside_frame_style = inside_frame.style - inside_frame_style.padding = 0 - inside_frame_style.maximal_height = 800 - - local inside_table = - inside_frame.add { - type = 'table', - column_count = 1 - } - local scroll_pane = - inside_table.add { + inside_frame.add { type = 'scroll-pane', vertical_scroll_policy = 'never', horizontal_scroll_policy = 'never' @@ -222,8 +187,6 @@ local function draw_main_frame(player, location) local rank = add_gui_stat(main_table, get_class(player), 200, ({'rpg_gui.class_info', get_class(player)})) rank.style.font = 'default-large-bold' - add_elem_stat(main_table, ({'rpg_gui.settings_name'}), 200, 35, nil, ({'rpg_gui.settings_frame'}), settings_button_name) - add_separator(scroll_pane, 400) --!sub top table @@ -286,12 +249,7 @@ local function draw_main_frame(player, location) add_gui_description(left_bottom_table, ({'rpg_gui.life_name'}), w1, ({'rpg_gui.life_tooltip'})) local health_gui = add_gui_stat(left_bottom_table, floor(player.character.health), w2, ({'rpg_gui.life_increase'})) data.health = health_gui - add_gui_stat( - left_bottom_table, - floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus), - w2, - ({'rpg_gui.life_maximum'}) - ) + add_gui_stat(left_bottom_table, floor(player.character.prototype.max_health + player.character_health_bonus + player.force.character_health_bonus), w2, ({'rpg_gui.life_maximum'})) local shield = 0 local shield_max = 0 @@ -487,7 +445,7 @@ function Public.toggle(player, recreate) if main_frame then remove_main_frame(main_frame, screen) else - ComfyGui.comfy_panel_clear_gui(player) + ComfyGui.clear_all_active_frames(player) draw_main_frame(player) end end @@ -661,7 +619,7 @@ Gui.on_click( end end - remove_settings_frame(event.element) + remove_target_frame(event.element) if player.gui.screen[main_frame_name] then toggle(player, true) @@ -690,6 +648,30 @@ Gui.on_click( end ) +Gui.on_click( + close_main_frame_name, + function(event) + local is_spamming = SpamProtection.is_spamming(event.player, nil, 'RPG Close Button') + if is_spamming then + return + end + local player = event.player + local screen = player.gui.screen + if not player or not player.valid or not player.character then + return + end + + local main_frame = screen[main_frame_name] + if main_frame and main_frame.valid then + remove_target_frame(main_frame) + end + local settings_frame = screen[settings_frame_name] + if settings_frame and settings_frame.valid then + remove_target_frame(settings_frame) + end + end +) + Gui.on_click( settings_button_name, function(event) diff --git a/modules/rpg/main.lua b/modules/rpg/main.lua index dcf3522e..b7a9f735 100644 --- a/modules/rpg/main.lua +++ b/modules/rpg/main.lua @@ -3,7 +3,6 @@ local Public = require 'modules.rpg.core' local Gui = require 'utils.gui' local Event = require 'utils.event' local AntiGrief = require 'utils.antigrief' -local Color = require 'utils.color_presets' local SpamProtection = require 'utils.spam_protection' local BiterHealthBooster = require 'modules.biter_health_booster_v2' local Explosives = require 'modules.explosives' @@ -1154,8 +1153,6 @@ local function on_player_used_capsule(event) return end - local p = player.print - if rpg_t.last_spawned >= game.tick then return Public.cast_spell(player, true) end diff --git a/modules/rpg/table.lua b/modules/rpg/table.lua index 52686f16..57acf98c 100644 --- a/modules/rpg/table.lua +++ b/modules/rpg/table.lua @@ -15,6 +15,7 @@ local settings_frame_name = Gui.uid_name() local save_button_name = Gui.uid_name() local discard_button_name = Gui.uid_name() local draw_main_frame_name = Gui.uid_name() +local close_main_frame_name = Gui.uid_name() local main_frame_name = Gui.uid_name() local settings_button_name = Gui.uid_name() local spell_gui_button_name = Gui.uid_name() @@ -515,6 +516,7 @@ Public.settings_frame_name = settings_frame_name Public.save_button_name = save_button_name Public.discard_button_name = discard_button_name Public.draw_main_frame_name = draw_main_frame_name +Public.close_main_frame_name = close_main_frame_name Public.main_frame_name = main_frame_name Public.settings_button_name = settings_button_name Public.spell_gui_button_name = spell_gui_button_name diff --git a/utils/datastore/current_time_data.lua b/utils/datastore/current_time_data.lua index 1e5d4339..7ab8f624 100644 --- a/utils/datastore/current_time_data.lua +++ b/utils/datastore/current_time_data.lua @@ -1,6 +1,6 @@ local Server = require 'utils.server' local Event = require 'utils.event' -local ComfyGui = require 'comfy_panel.main' +local Gui = require 'utils.gui' local Color = require 'utils.color_presets' local current_time_label = 'current_time_label' @@ -111,7 +111,7 @@ commands.add_command( end ) -ComfyGui.screen_to_bypass(current_time_label) +Gui.screen_to_bypass(current_time_label) Event.add( defines.events.on_player_display_resolution_changed, diff --git a/utils/datastore/server_ups_data.lua b/utils/datastore/server_ups_data.lua index 9d582376..a05e33f7 100644 --- a/utils/datastore/server_ups_data.lua +++ b/utils/datastore/server_ups_data.lua @@ -1,6 +1,6 @@ local Server = require 'utils.server' local Event = require 'utils.event' -local ComfyGui = require 'comfy_panel.main' +local Gui = require 'utils.gui' local Color = require 'utils.color_presets' local ups_label = 'ups_label' @@ -106,7 +106,7 @@ commands.add_command( end ) -ComfyGui.screen_to_bypass(ups_label) +Gui.screen_to_bypass(ups_label) Event.add( defines.events.on_player_display_resolution_changed, diff --git a/utils/files/arrow-down.png b/utils/files/arrow-down.png new file mode 100644 index 0000000000000000000000000000000000000000..ad7f39f9fd9a0c1ae835e517819761d3ed584c49 GIT binary patch literal 364 zcmV-y0h9iTP)Px$CP_p=R5(w~lRZwuKoCaXY-n=Rm}h~!->>I zS>F5vQPnN5A%{RZRg>{4B^`BH9Ea@p`)!PIGYT?8pLK_`D&vOZ9Ch&tlFXLOS!`ee zMk|#h_4&jFqO^y2xSP-6<@M}VpvsD2bcn6@%k@w*2^tzmkO44FG}ux$bsLD# zdhgdFl1shUOhV`y%vGr>lc^8cP%vnhrC&?m@o|yNkS=KB7~e@srmo2|nMd)LO&ljN zT$LPo8Z0q(MNwX-vEP5@Z&x{la49CMNF<6po_qgrY(M_~Uw8wLNrJTaBeUE90000< KMNUMnLSTZFxtk9F literal 0 HcmV?d00001 diff --git a/utils/files/arrow-up.png b/utils/files/arrow-up.png new file mode 100644 index 0000000000000000000000000000000000000000..19f6820254c5da9ed5f842f7b7c9e07817c85762 GIT binary patch literal 373 zcmV-*0gC>KP)Px$FG)l}R5(wyk}*=lFc3xmDrvX_mPo~UQc}@+!T}5?Ai02}mWndxp>kH?76g4p zicJ&@GnvWY!X8`u-~PW|!G)JxsK=jxE_8Q>W)2vL>^IiVUVm#g0uYqYg%$=iK}g?& zK}-Sriu{Q1_QozsNCBXzh8AFb=r9}+nR2Z3*13fM*-8FP zLPF3MKrc>bk}HOLX0mrr@pg8A2uRToS_1V+o(R8>`)6DM(~s#Bh#D#W(T%s(E=09k zljd8Tv&&@VT=iHEYp1%5K$C0@j0kv9)ubshnvr+_=}wo3XomMJQ{AQ!I%T^1lU|V_j1l=>bu^@Ps|bV_J6Bf~$PJG4 z*~MO9TVW+zqj&TZ<5;<5d!zKdgpV?PVqNBtrJC3N+$kN#ZM-iuoet(=zsGAl#pk0! zbA|5Nj+l3_vDg2A*w>+Gqn&6lGf|;BXvMayiD&)?KHy{X3)Y~)KZoB(T{VEnT_Rfm O0000Px%pGibPR9HvlmcMHhK@`WoZ`M;RBC%6$W|jydDo7yqf{27@sf7e2l|)cP{8jl6 z94M#=N(zaE5X2M)Nogw~R7dL`vn*pu$DQ12e ziwNdHN7N1AexoSY(onxP4(AH{!f^U?E`Xv^LxS-r)+VB1W|&f-pSw)T<`t$(p@)Mdkf}I*4l#rTrPn4 zW2Mz79L}cPH?JCFZsqQRSfHn;$FEc>ZyD&WZ8R%O-Mj!RPxaeJHr!{iaRr@nE|xcBhI-4MC377$F2QV%0iYI zKq)l|pg(R25>yI;;6`Tv;%cP-9l#?h&20V>$Vq@|HQYtp>bO5X^L_2y0!? z0RSoG1tPi!pb|NEd@c-MZfYCiG(7c6O#qlO#$3x{p87D#YLfehPx%#z{m$R9HvVmd|SwK@`WoZ#J!Zk(MH)WM(UrASy_qUc4xXNU0vZNI`m%3W|uo zPW}S{1rR=raPM)JSe4NOVgbvo86R6E!|B5S)9wxFf;Fc z_WOS95>g(NvVZ)409xxj5lt}jX#fg96~F>B&vbWpKgwpaKblcBu>#C&Rb2O$0d4@; z1u(ElKn8vaqAOC$CrKd^1L(582ZKuy#|{kUATR{5tiv!E1Uj#jnoI(b2*545r;Nof z2@oJ!Vq-46Szdl|w6CwHTJ`P#W^BV*Ak3dNtPKsS!LM-;u>j00Dz5w10K)**gb>F8 ztQcb+f^fL@!qLGD5P^xOY-x|T4NxkT_FI-U9|ruXWm%U!&-(x%8)JM468(zQ%68{s z6>wem3^P9ujf^pK4-q{Glnx`lN&otiXy-mD_k3v!!1?ZsQ-&Vk$Cc0CqRt_@^anvuZ{L@&g}}SdJ~js1d&> zWHOn%%zPqfHw{Tqg~4>!j;^cCe2|&~s0qz1%H{GQ0HXjTGp`fTf>|-McHaJ$} za=8uzXkA380Dyu@O@W{dqyXS6z!(XBM?^uXj)%Z00u29bx(hHQUZnp30000< KMNUMnLSTX#h)qQR literal 0 HcmV?d00001 diff --git a/utils/files/settings-black.png b/utils/files/settings-black.png new file mode 100644 index 0000000000000000000000000000000000000000..80b8d27789f19982a51e144b70b493fae502804e GIT binary patch literal 1237 zcmV;`1SPx(k4Z#9R9HvtR!wMJRTTcteMuNfW+5^nnfEhElUf3bF;<#VN}+<5u8M|c;Y#R6 z1WAinHyYhESV~c_n}RDBl}J}E8l(_{wxKmHrxMd7^X{7(GJ;^NBu(Eva_@U@=1npa zClV=wcNQ~q@44rG=kGg*@R%1p=J)a61MrOJb+0jBVCH@Xo&umis1WEb5xrX~l@@p6 z)g61lahy|Nz6v6M0qw*13l^-ACAsv~zYL&o3J9+zk1)eviPwmfa@PP*Y??OEtXwYF zxhJz{Od&jLOy9aL%C)sIR4RYej+ih;gfXZ_7aD3A92{(4sjN%@c(P6L*~K8ZlXu-W z1oL??@=O3}(?N)SN1-r_P$tm(zVCl&+x7t>x(MJmna#eAV)5Z-5Dfuz+4gyh=$sK| zlVm@FF$nz}C63W&3?^#i3k_)&;1>WAMh(+vLEyjhw*Y#3y@B<0HN%V!GNwgl#r7Hu zvB^5y=VIgcF{4`}i7cw!tEDJ5I*5ku`TlGg#1;=Yj&lvb$#jY{7!+GBK+~ZL&y~yN z+W^8?nU(kQF9{aoP<+I|Fq+e`F_M!~%Ht`7_1-HK_7}qN!5qNt=_E4%^oPV1-!Hud z;8CN50?_8V?q$V%I$dZr zH$q}biXVt*)c5`Gw#@;3*x%pZvAVii0`PR~iN%9b_D$4czAcVnz`Er)KNHX$ zr7)H|v(hUT(OMbC05qAjM=$ZDl)=(?6!BtFf4mUhk(1I`oVIx)ez+K`GZ1; zPXHWF5iFDvhsxzrYe|^*hJ;WzH!;EOP>9j{rIOiiSOu=z^D?W4le!FJFQ@E}xkU~W&CEDeN+uK2#+l!!D3EO_o^ zrTBExpsHLLv2!Rw@oedr(%pt0(3_s)TnmAd5&OqQWVlm9G5@EPQjMutiE(3jR5@`3 z>*)AfDWy)#YKz~}3p}rPK&kZ^20HX%?K2?epsCLAty+%`6{X`T&HiC2qzyJenabNme2J-FA z<n#C@g)B4ireDkDI=xKhV+D*RVK#jx36#L4wLjNBsML*Q5EuqwqT0Ia zF#NNr7^n`VwS)s;(TH5yy`glox6FStmKy+3QkvPLmZ`fs6*mOnx_v#&YZn0Q2RH|Y zAR&Hb=AVe@jPLsk4KFs?+;IqYqP!K^{{j33U)bj`USYw500000NkvXXu0mjfvbIj8 literal 0 HcmV?d00001 diff --git a/utils/files/settings-white.png b/utils/files/settings-white.png new file mode 100644 index 0000000000000000000000000000000000000000..ca2315ddf5594f2af554e29e25b7ed38bfe9cdec GIT binary patch literal 1183 zcmV;Q1YrA#P)Px(SxH1eR9HvVR!wLeWf*?mZ?>Bpx;-W-GqbZ10>UCF*q`_l1igr$U?uIrlhBI@ zQbmjxtzH@|QV{G#@Z=#{J%|c==p|@UW9n@c3c7zYspi;KOg1~;TfU!}9k#pft~CUQ zU3T`HZ@%yOp7(v9=OrBQMF+e;{(k^!wc0E>&P4)FffN21MEv<*F~4?isZFMb!%y@-J2SIQ>3*rt28jU8CI)Yi-{+fi-%L`g1j+b0_V}och)=M)x z^(Z>-Ff9XeAsd};sMI_{(f5R^*))f;XsXp}Dd#vhKseMrjip&1g+KJX;)_Jo>6cK< zoC_O`%Mjvhni2LO2B`YVau5VR_XW_bHJ@Y$UlCYn0Bp}qy5Lql&wqT-=9#R|g<*IV zfMFtYF(3(e%J= zHYLk*K@fcRk2#SkZ-D?mGc)ph-A|3N#m&%D|7@!zHc_D?=JwhBvF#QYYu!0E`gb zdC8$d)Cj}N0yvx0uaRskYl7mq6W>=Vm3|qh1F00J%H9J+V3nAbT-V)5%2JhG6xENj zbe2K9pki)!O^qv&b>H`da;bp;5;Fpj*AAe(-nwAozF9X+lO&mx@sPx>ZO_n=EFKF2 z_xqtj)U4N+A;jwzK+IrAm6S24ZUd54%8WT0@ih9;0ddai$p?PXf2lXD0~?Z=nVHX| zY|5CM40^SqC?wzlq%WBHRHeEs*%&Z)V% zIjyck889bc2g*D$@v3ZZA1>^)-y!02x +---@param frame +function Public.add_mod_button(player, frame) + if Public.get_button_flow(player)[frame.name] and Public.get_button_flow(player)[frame.name].valid then + return + end + + Public.get_button_flow(player).add(frame) +end + +---@param state +--- If we should use the new mod gui or not +function Public.set_mod_gui_top_frame(state) + settings.mod_gui_top_frame = state or false +end + +--- Get mod_gui_top_frame +function Public.get_mod_gui_top_frame() + return settings.mod_gui_top_frame +end + +--- This adds the given gui to the main gui. +---@param tbl +function Public.add_tab_to_gui(tbl) + if not tbl then + return + end + + if not tbl.name then + return + end + + if not tbl.caption then + return + end + + if not tbl.id then + return + end + + local admin = tbl.admin or false + local only_server_sided = tbl.only_server_sided or false + + if not main_gui_tabs[tbl.caption] then + main_gui_tabs[tbl.caption] = {id = tbl.id, name = tbl.name, admin = admin, only_server_sided = only_server_sided} + else + error('Given name: ' .. tbl.caption .. ' already exists in table.') + end +end + +function Public.screen_to_bypass(elem) + screen_elements[elem] = true + return screen_elements +end + +--- Fetches the main gui tabs. You are forbidden to write as this is local. +---@param key +function Public.get(key) + if key then + return main_gui_tabs[key] + else + return main_gui_tabs + end +end + +function Public.clear_main_frame(player) + if not player then + return + end + local frame = Public.get_main_frame(player) + if frame then + frame.destroy() + end +end + +function Public.clear_all_active_frames(player) + for _, child in pairs(player.gui.left.children) do + child.destroy() + end + for _, child in pairs(player.gui.screen.children) do + if not screen_elements[child.name] then + child.destroy() + end + end +end + +function Public.get_player_active_frame(player) + local main_frame = Public.get_main_frame(player) + if not main_frame then + return false + end + + local panel = main_frame.tabbed_pane + if not panel then + return + end + local index = panel.selected_tab_index + if not index then + return panel.tabs[1].content + end + + return panel.tabs[index].content +end + +local function get_player_active_tab(player) + local main_frame = Public.get_main_frame(player) + if not main_frame then + return false + end + + local panel = main_frame.tabbed_pane + if not panel then + return + end + local index = panel.selected_tab_index + if not index then + return panel.tabs[1].tab, panel.tabs[1].content + end + + return panel.tabs[index].tab, panel.tabs[index].content +end + +function Public.reload_active_tab(player, forced) + local is_spamming = SpamProtection.is_spamming(player, nil, 'Reload active tab') + if is_spamming and not forced then + return + end + + local frame, main_tab = get_player_active_tab(player) + if not frame then + return + end + + local tab = main_gui_tabs[frame.caption] + if not tab then + return + end + local id = tab.id + if not id then + return + end + local func = Token.get(id) + + local d = { + player = player, + frame = main_tab + } + + return func(d) +end + +local function top_button(player) + if settings.mod_gui_top_frame then + Public.add_mod_button(player, {type = 'sprite-button', name = main_button_name, sprite = 'item/raw-fish'}) + else + if player.gui.top[main_button_name] then + return + end + local button = player.gui.top.add({type = 'sprite-button', name = main_button_name, sprite = 'item/raw-fish'}) + button.style.minimal_height = 38 + button.style.maximal_height = 38 + button.style.minimal_width = 40 + button.style.padding = -2 + end +end + +local function draw_main_frame(player) + local tabs = main_gui_tabs + Public.clear_all_active_frames(player) + + if Public.get_main_frame(player) then + Public.get_main_frame(player).destroy() + end + + local frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, _, close_button_name, 'Comfy Panel') + + local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'}) + + for name, func in pairs(tabs) do + if func.only_server_sided then + local secs = Server.get_current_time() + if secs then + local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name}) + local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'}) + name_frame.style.minimal_height = 480 + name_frame.style.maximal_height = 480 + name_frame.style.minimal_width = 800 + name_frame.style.maximal_width = 800 + tabbed_pane.add_tab(tab, name_frame) + end + elseif func.admin == true then + if player.admin then + local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name}) + local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'}) + name_frame.style.minimal_height = 480 + name_frame.style.maximal_height = 480 + name_frame.style.minimal_width = 800 + name_frame.style.maximal_width = 800 + tabbed_pane.add_tab(tab, name_frame) + end + else + local tab = tabbed_pane.add({type = 'tab', caption = name, name = func.name}) + local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'}) + name_frame.style.minimal_height = 480 + name_frame.style.maximal_height = 480 + name_frame.style.minimal_width = 800 + name_frame.style.maximal_width = 800 + tabbed_pane.add_tab(tab, name_frame) + end + end + + for _, child in pairs(tabbed_pane.children) do + child.style.padding = 8 + child.style.left_padding = 2 + child.style.right_padding = 2 + end + + Public.reload_active_tab(player, true) + return frame, inside_frame +end + +function Public.call_existing_tab(player, name) + local frame, inside_frame = draw_main_frame(player) + if not frame then + return + end + local tabbed_pane = inside_frame.tabbed_pane + for key, v in pairs(tabbed_pane.tabs) do + if v.tab.caption == name then + tabbed_pane.selected_tab_index = key + Public.reload_active_tab(player, true) + end + end +end + -- Register a handler for the on_gui_checked_state_changed event for LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_checked_state_changed = handler_factory(defines.events.on_gui_checked_state_changed) +Public.on_checked_state_changed = handler_factory(defines.events.on_gui_checked_state_changed) -- Register a handler for the on_gui_click event for LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_click = handler_factory(defines.events.on_gui_click) +Public.on_click = handler_factory(defines.events.on_gui_click) -- Register a handler for the on_gui_closed event for a custom LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_custom_close = handler_factory(defines.events.on_gui_closed) +Public.on_custom_close = handler_factory(defines.events.on_gui_closed) -- Register a handler for the on_gui_elem_changed event for LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_elem_changed = handler_factory(defines.events.on_gui_elem_changed) +Public.on_elem_changed = handler_factory(defines.events.on_gui_elem_changed) -- Register a handler for the on_gui_selection_state_changed event for LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_selection_state_changed = handler_factory(defines.events.on_gui_selection_state_changed) +Public.on_selection_state_changed = handler_factory(defines.events.on_gui_selection_state_changed) -- Register a handler for the on_gui_text_changed event for LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_text_changed = handler_factory(defines.events.on_gui_text_changed) +Public.on_text_changed = handler_factory(defines.events.on_gui_text_changed) -- Register a handler for the on_gui_value_changed event for LuaGuiElements with element_name. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_value_changed = handler_factory(defines.events.on_gui_value_changed) +Public.on_value_changed = handler_factory(defines.events.on_gui_value_changed) -- Register a handler for when the player shows the top LuaGuiElements with element_name. --- Assuming the element_name has been added with Gui.allow_player_to_toggle_top_element_visibility. +-- Assuming the element_name has been added with Public.allow_player_to_toggle_top_element_visibility. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_player_show_top = custom_handler_factory(on_visible_handlers) +Public.on_player_show_top = custom_handler_factory(on_visible_handlers) -- Register a handler for when the player hides the top LuaGuiElements with element_name. --- Assuming the element_name has been added with Gui.allow_player_to_toggle_top_element_visibility. +-- Assuming the element_name has been added with Public.allow_player_to_toggle_top_element_visibility. -- Can only have one handler per element name. -- Guarantees that the element and the player are valid when calling the handler. -- Adds a player field to the event table. -Gui.on_pre_player_hide_top = custom_handler_factory(on_pre_hidden_handlers) +Public.on_pre_player_hide_top = custom_handler_factory(on_pre_hidden_handlers) if _DEBUG then local concat = table.concat local names = {} - Gui.names = names + Public.names = names - function Gui.uid_name() + function Public.uid_name() local info = debug.getinfo(2, 'Sl') local filepath = info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5) local line = info.currentline @@ -284,7 +665,7 @@ if _DEBUG then return token end - function Gui.set_data(element, value) + function Public.set_data(element, value) local player_index = element.player_index local values = data[player_index] @@ -311,18 +692,66 @@ if _DEBUG then element_map[index] = element end end - set_data = Gui.set_data + set_data = Public.set_data - function Gui.data() + function Public.data() return data end - function Gui.element_map() + function Public.element_map() return element_map end end -Gui.get_button_flow = mod_gui.get_button_flow -Gui.mod_button = mod_gui.get_button_flow +Public.get_button_flow = mod_gui.get_button_flow +Public.mod_button = mod_gui.get_button_flow -return Gui +Public.on_click( + main_button_name, + function(event) + local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Main button') + if is_spamming then + return + end + local player = event.player + local frame = Public.get_parent_frame(player) + if frame then + frame.destroy() + else + draw_main_frame(player) + end + end +) + +Public.on_click( + close_button_name, + function(event) + local is_spamming = SpamProtection.is_spamming(event.player, nil, 'Main button') + if is_spamming then + return + end + local player = event.player + local frame = Public.get_parent_frame(player) + if frame then + frame.destroy() + end + end +) + +Event.add( + defines.events.on_player_created, + function(event) + local player = game.get_player(event.player_index) + top_button(player) + end +) + +Event.add( + defines.events.on_player_joined_game, + function(event) + local player = game.get_player(event.player_index) + top_button(player) + end +) + +return Public diff --git a/comfy_panel/admin.lua b/utils/gui/admin.lua similarity index 95% rename from comfy_panel/admin.lua rename to utils/gui/admin.lua index 6037f234..52f7d62a 100644 --- a/comfy_panel/admin.lua +++ b/utils/gui/admin.lua @@ -2,13 +2,13 @@ local Event = require 'utils.event' local Jailed = require 'utils.datastore.jail_data' -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' local AntiGrief = require 'utils.antigrief' local SpamProtection = require 'utils.spam_protection' local Token = require 'utils.token' local lower = string.lower -local module_name = 'Admin' +local module_name = Gui.uid_name() local function admin_only_message(str) for _, player in pairs(game.connected_players) do @@ -49,10 +49,7 @@ local function bring_player(player, source_player) local pos = source_player.surface.find_non_colliding_position('character', source_player.position, 50, 1) if pos then player.teleport(pos, source_player.surface) - game.print( - player.name .. ' has been teleported to ' .. source_player.name .. '. ' .. bring_player_messages[math.random(1, #bring_player_messages)], - {r = 0.98, g = 0.66, b = 0.22} - ) + game.print(player.name .. ' has been teleported to ' .. source_player.name .. '. ' .. bring_player_messages[math.random(1, #bring_player_messages)], {r = 0.98, g = 0.66, b = 0.22}) end end @@ -67,10 +64,7 @@ local function go_to_player(player, source_player) local pos = player.surface.find_non_colliding_position('character', player.position, 50, 1) if pos then source_player.teleport(pos, player.surface) - game.print( - source_player.name .. ' is visiting ' .. player.name .. '. ' .. go_to_player_messages[math.random(1, #go_to_player_messages)], - {r = 0.98, g = 0.66, b = 0.22} - ) + game.print(source_player.name .. ' is visiting ' .. player.name .. '. ' .. go_to_player_messages[math.random(1, #go_to_player_messages)], {r = 0.98, g = 0.66, b = 0.22}) end end @@ -338,11 +332,11 @@ local function text_changed(event) local antigrief = AntiGrief.get() local player = game.get_player(event.player_index) - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Admin' then return end @@ -644,15 +638,12 @@ local function on_gui_click(event) local name = event.element.name - if name == 'tab_' .. module_name then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Admin tab_Admin') - if is_spamming then - return - end + local frame = Gui.get_player_active_frame(player) + if not frame then + return end - local frame = Tabs.comfy_panel_get_active_frame(player) - if not frame then + if frame.name ~= 'Admin' then return end @@ -661,10 +652,6 @@ local function on_gui_click(event) return end - if frame.name ~= module_name then - return - end - local is_spamming = SpamProtection.is_spamming(player, nil, 'Admin Gui Click') if is_spamming then return @@ -727,11 +714,11 @@ local function on_gui_selection_state_changed(event) end global.admin_panel_selected_history_index[player.name] = event.element.selected_index - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Admin' then return end @@ -748,11 +735,11 @@ local function on_gui_selection_state_changed(event) end global.admin_panel_selected_player_index[player.name] = event.element.selected_index - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Admin' then return end @@ -766,7 +753,15 @@ local function on_gui_selection_state_changed(event) end end -Tabs.add_tab_to_gui({name = module_name, id = create_admin_panel_token, admin = true}) +Gui.add_tab_to_gui({name = module_name, caption = 'Admin', id = create_admin_panel_token, admin = true}) + +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) Event.add(defines.events.on_gui_text_changed, text_changed) Event.add(defines.events.on_gui_click, on_gui_click) diff --git a/comfy_panel/bottom_frame.lua b/utils/gui/bottom_frame.lua similarity index 98% rename from comfy_panel/bottom_frame.lua rename to utils/gui/bottom_frame.lua index 3c9da0cd..0bca097b 100644 --- a/comfy_panel/bottom_frame.lua +++ b/utils/gui/bottom_frame.lua @@ -1,7 +1,6 @@ local Misc = require 'utils.commands.misc' local Event = require 'utils.event' local Global = require 'utils.global' -local ComfyGui = require 'comfy_panel.main' local Gui = require 'utils.gui' local SpamProtection = require 'utils.spam_protection' @@ -288,6 +287,6 @@ Event.add( Public.bottom_guis_frame = bottom_guis_frame Public.set_location = set_location -ComfyGui.screen_to_bypass(bottom_guis_frame) +Gui.screen_to_bypass(bottom_guis_frame) return Public diff --git a/comfy_panel/config.lua b/utils/gui/config.lua similarity index 78% rename from comfy_panel/config.lua rename to utils/gui/config.lua index 4b580c21..638f5c55 100644 --- a/comfy_panel/config.lua +++ b/utils/gui/config.lua @@ -3,14 +3,13 @@ local Event = require 'utils.event' local Color = require 'utils.color_presets' local SessionData = require 'utils.datastore.session_data' local Utils = require 'utils.core' -local Tabs = require 'comfy_panel.main' local SpamProtection = require 'utils.spam_protection' -local BottomFrame = require 'comfy_panel.bottom_frame' +local BottomFrame = require 'utils.gui.bottom_frame' local Token = require 'utils.token' local Global = require 'utils.global' local Gui = require 'utils.gui' -local module_name = 'Config' +local module_name = Gui.uid_name() local Public = {} @@ -117,14 +116,14 @@ local function trust_connected_players() end local functions = { - ['comfy_panel_spectator_switch'] = function(event) + ['spectator_switch'] = function(event) if event.element.switch_state == 'left' then game.get_player(event.player_index).spectator = true else game.get_player(event.player_index).spectator = false end end, - ['comfy_panel_bottom_location'] = function(event) + ['bottom_location'] = function(event) local player = game.get_player(event.player_index) if event.element.switch_state == 'left' then BottomFrame.set_location(player, 'bottom_left') @@ -132,7 +131,7 @@ local functions = { BottomFrame.set_location(player, 'bottom_right') end end, - ['comfy_panel_middle_location'] = function(event) + ['middle_location'] = function(event) local player = game.get_player(event.player_index) local data = BottomFrame.get_player_data(player) if event.element.switch_state == 'left' then @@ -148,7 +147,7 @@ local functions = { BottomFrame.set_location(player, data.bottom_state) end, - ['comfy_panel_portable_button'] = function(event) + ['portable_button'] = function(event) local player = game.get_player(event.player_index) local data = BottomFrame.get_player_data(player) if event.element.switch_state == 'left' then @@ -165,14 +164,14 @@ local functions = { BottomFrame.set_location(player, data.bottom_state) end, - ['comfy_panel_auto_hotbar_switch'] = function(event) + ['auto_hotbar_switch'] = function(event) if event.element.switch_state == 'left' then global.auto_hotbar_enabled[event.player_index] = true else global.auto_hotbar_enabled[event.player_index] = false end end, - ['comfy_panel_blueprint_toggle'] = function(event) + ['blueprint_toggle'] = function(event) if event.element.switch_state == 'left' then game.permissions.get_group('Default').set_allows_action(defines.input_action.open_blueprint_library_gui, true) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, true) @@ -183,7 +182,7 @@ local functions = { get_actor(event, '[Blueprints]', 'has disabled blueprints!') end end, - ['comfy_panel_spaghett_toggle'] = function(event) + ['spaghett_toggle'] = function(event) if event.element.switch_state == 'left' then this.gui_config.spaghett.enabled = true get_actor(event, '[Spaghett]', 'has enabled spaghett mode!') @@ -222,7 +221,7 @@ local functions = { } local poll_function = { - ['comfy_panel_poll_trusted_toggle'] = function(event) + ['poll_trusted_toggle'] = function(event) if event.element.switch_state == 'left' then this.gui_config.poll_trusted = true get_actor(event, '[Poll Mode]', 'has disabled non-trusted people to do polls.') @@ -231,8 +230,8 @@ local poll_function = { get_actor(event, '[Poll Mode]', 'has allowed non-trusted people to do polls.') end end, - ['comfy_panel_poll_no_notify_toggle'] = function(event) - local poll = is_loaded('comfy_panel.poll') + ['poll_no_notify_toggle'] = function(event) + local poll = is_loaded('utils.gui.poll') local poll_table = poll.get_no_notify_players() if event.element.switch_state == 'left' then poll_table[event.player_index] = false @@ -243,7 +242,7 @@ local poll_function = { } local antigrief_functions = { - ['comfy_panel_disable_antigrief'] = function(event) + ['disable_antigrief'] = function(event) local AG = Antigrief.get() if event.element.switch_state == 'left' then AG.enabled = true @@ -257,7 +256,7 @@ local antigrief_functions = { } local fortress_functions = { - ['comfy_panel_disable_fullness'] = function(event) + ['disable_fullness'] = function(event) local Fullness = is_loaded('modules.check_fullness') local Module = Fullness.get() if event.element.switch_state == 'left' then @@ -268,7 +267,7 @@ local fortress_functions = { get_actor(event, '[Fullness]', 'has disabled the inventory fullness function.') end end, - ['comfy_panel_offline_players'] = function(event) + ['offline_players'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') local Module = WPT.get() if event.element.switch_state == 'left' then @@ -279,7 +278,7 @@ local fortress_functions = { get_actor(event, '[Offline Players]', 'has disabled the offline player function.') end end, - ['comfy_panel_collapse_grace'] = function(event) + ['collapse_grace'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') local Module = WPT.get() if event.element.switch_state == 'left' then @@ -290,7 +289,7 @@ local fortress_functions = { get_actor(event, '[Collapse]', 'has disabled the collapse function. You must breach the first zone for collapse to occur!') end end, - ['comfy_panel_spill_items_to_surface'] = function(event) + ['spill_items_to_surface'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') local Module = WPT.get() if event.element.switch_state == 'left' then @@ -301,7 +300,7 @@ local fortress_functions = { get_actor(event, '[Item Spill]', 'has disabled the item spillage function. Ores no longer drop to surface when mining.') end end, - ['comfy_panel_void_or_tile'] = function(event) + ['void_or_tile'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') local Module = WPT.get() if event.element.switch_state == 'left' then @@ -312,7 +311,7 @@ local fortress_functions = { get_actor(event, '[Void]', 'has changes the tiles of the zones to: dark-tiles (flammable tiles)') end end, - ['comfy_panel_trusted_only_car_tanks'] = function(event) + ['trusted_only_car_tanks'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') local Module = WPT.get() if event.element.switch_state == 'left' then @@ -323,7 +322,7 @@ local fortress_functions = { get_actor(event, '[Market]', 'has changed so everybody can buy car/tanks.', true) end end, - ['comfy_panel_allow_decon'] = function(event) + ['allow_decon'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') if event.element.switch_state == 'left' then local limited_group = game.permissions.get_group('limited') @@ -341,7 +340,7 @@ local fortress_functions = { get_actor(event, '[Decon]', 'has disabled decon on car/tanks/trains.', true) end end, - ['comfy_panel_christmas_mode'] = function(event) + ['christmas_mode'] = function(event) local WPT = is_loaded('maps.mountain_fortress_v3.table') if event.element.switch_state == 'left' then WPT.set('winter_mode', true) @@ -422,13 +421,7 @@ local function build_config_gui(data) if player.spectator then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_spectator_switch', - {'gui.spectator_mode'}, - {'gui-description.spectator_mode'} - ) + add_switch(scroll_pane, switch_state, 'spectator_switch', {'gui.spectator_mode'}, {'gui-description.spectator_mode'}) scroll_pane.add({type = 'line'}) @@ -437,24 +430,18 @@ local function build_config_gui(data) if global.auto_hotbar_enabled[player.index] then switch_state = 'left' end - add_switch(scroll_pane, switch_state, 'comfy_panel_auto_hotbar_switch', 'AutoHotbar', 'Automatically fills your hotbar with placeable items.') + add_switch(scroll_pane, switch_state, 'auto_hotbar_switch', 'AutoHotbar', 'Automatically fills your hotbar with placeable items.') scroll_pane.add({type = 'line'}) end - local poll = is_loaded('comfy_panel.poll') + local poll = is_loaded('utils.gui.poll') if poll then local poll_table = poll.get_no_notify_players() switch_state = 'right' if not poll_table[player.index] then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_poll_no_notify_toggle', - {'gui.notify_on_polls'}, - {'gui-description.notify_on_polls'} - ) + add_switch(scroll_pane, switch_state, 'poll_no_notify_toggle', {'gui.notify_on_polls'}, {'gui-description.notify_on_polls'}) scroll_pane.add({type = 'line'}) end @@ -475,13 +462,7 @@ local function build_config_gui(data) if bottom_frame and bottom_frame.bottom_state == 'bottom_left' then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_bottom_location', - 'Position - bottom', - 'Toggle to select if you want the bottom button on the left side or the right side.' - ) + add_switch(scroll_pane, switch_state, 'bottom_location', 'Position - bottom', 'Toggle to select if you want the bottom button on the left side or the right side.') scroll_pane.add({type = 'line'}) @@ -489,13 +470,7 @@ local function build_config_gui(data) if bottom_frame and bottom_frame.above then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_middle_location', - 'Position - middle', - 'Toggle to select if you want the bottom button above the quickbar or the side of the quickbar.' - ) + add_switch(scroll_pane, switch_state, 'middle_location', 'Position - middle', 'Toggle to select if you want the bottom button above the quickbar or the side of the quickbar.') scroll_pane.add({type = 'line'}) @@ -503,13 +478,7 @@ local function build_config_gui(data) if bottom_frame and bottom_frame.portable then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_portable_button', - 'Position - portable', - 'Toggle to select if you want the bottom button to be portable or not.' - ) + add_switch(scroll_pane, switch_state, 'portable_button', 'Position - portable', 'Toggle to select if you want the bottom button to be portable or not.') scroll_pane.add({type = 'line'}) end @@ -529,7 +498,7 @@ local function build_config_gui(data) if game.permissions.get_group('Default').allows_action(defines.input_action.open_blueprint_library_gui) then switch_state = 'left' end - add_switch(scroll_pane, switch_state, 'comfy_panel_blueprint_toggle', 'Blueprint Library', 'Toggles the usage of blueprint strings and the library.') + add_switch(scroll_pane, switch_state, 'blueprint_toggle', 'Blueprint Library', 'Toggles the usage of blueprint strings and the library.') scroll_pane.add({type = 'line'}) @@ -545,13 +514,7 @@ local function build_config_gui(data) if this.gui_config.spaghett.enabled then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_spaghett_toggle', - {'gui.spaghett_mode'}, - {'gui-description.spaghett_mode'} - ) + add_switch(scroll_pane, switch_state, 'spaghett_toggle', {'gui.spaghett_mode'}, {'gui-description.spaghett_mode'}) if poll then scroll_pane.add({type = 'line'}) @@ -559,7 +522,7 @@ local function build_config_gui(data) if this.gui_config.poll_trusted then switch_state = 'left' end - add_switch(scroll_pane, switch_state, 'comfy_panel_poll_trusted_toggle', 'Poll mode', 'Disables non-trusted plebs to create polls.') + add_switch(scroll_pane, switch_state, 'poll_trusted_toggle', 'Poll mode', 'Disables non-trusted plebs to create polls.') end scroll_pane.add({type = 'line'}) @@ -577,7 +540,7 @@ local function build_config_gui(data) if AG.enabled then switch_state = 'left' end - add_switch(scroll_pane, switch_state, 'comfy_panel_disable_antigrief', 'Antigrief', 'Toggle antigrief function.') + add_switch(scroll_pane, switch_state, 'disable_antigrief', 'Antigrief', 'Toggle antigrief function.') scroll_pane.add({type = 'line'}) if is_loaded('maps.biter_battles_v2.main') then @@ -596,14 +559,7 @@ local function build_config_gui(data) if global.bb_settings.team_balancing then team_balancing_state = 'left' end - local switch = - add_switch( - scroll_pane, - team_balancing_state, - 'bb_team_balancing_toggle', - 'Team Balancing', - 'Players can only join a team that has less or equal players than the opposing.' - ) + local switch = add_switch(scroll_pane, team_balancing_state, 'bb_team_balancing_toggle', 'Team Balancing', 'Players can only join a team that has less or equal players than the opposing.') if not admin then switch.ignored_by_interaction = true end @@ -614,14 +570,7 @@ local function build_config_gui(data) if global.bb_settings.only_admins_vote then only_admins_vote_state = 'left' end - local only_admins_vote_switch = - add_switch( - scroll_pane, - only_admins_vote_state, - 'bb_only_admins_vote', - 'Admin Vote', - 'Only admins can vote for map difficulty. Clears all currently existing votes.' - ) + local only_admins_vote_switch = add_switch(scroll_pane, only_admins_vote_state, 'bb_only_admins_vote', 'Admin Vote', 'Only admins can vote for map difficulty. Clears all currently existing votes.') if not admin then only_admins_vote_switch.ignored_by_interaction = true end @@ -645,13 +594,7 @@ local function build_config_gui(data) if full.fullness_enabled then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_disable_fullness', - 'Inventory Fullness', - 'On = Enables inventory fullness.\nOff = Disables inventory fullness.' - ) + add_switch(scroll_pane, switch_state, 'disable_fullness', 'Inventory Fullness', 'On = Enables inventory fullness.\nOff = Disables inventory fullness.') scroll_pane.add({type = 'line'}) @@ -661,13 +604,7 @@ local function build_config_gui(data) if Module.offline_players_enabled then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_offline_players', - 'Offline Players', - 'On = Enables offline player inventory drop.\nOff = Disables offline player inventory drop.' - ) + add_switch(scroll_pane, switch_state, 'offline_players', 'Offline Players', 'On = Enables offline player inventory drop.\nOff = Disables offline player inventory drop.') scroll_pane.add({type = 'line'}) @@ -675,13 +612,7 @@ local function build_config_gui(data) if Module.collapse_grace then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_collapse_grace', - 'Collapse', - 'On = Enables collapse after wave 100.\nOff = Disables collapse - you must breach the first zone for collapse to occur.' - ) + add_switch(scroll_pane, switch_state, 'collapse_grace', 'Collapse', 'On = Enables collapse after wave 100.\nOff = Disables collapse - you must breach the first zone for collapse to occur.') scroll_pane.add({type = 'line'}) @@ -689,57 +620,33 @@ local function build_config_gui(data) if Module.spill_items_to_surface then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_spill_items_to_surface', - 'Spill Ores', - 'On = Enables ore spillage to surface when mining.\nOff = Disables ore spillage to surface when mining.' - ) + add_switch(scroll_pane, switch_state, 'spill_items_to_surface', 'Spill Ores', 'On = Enables ore spillage to surface when mining.\nOff = Disables ore spillage to surface when mining.') scroll_pane.add({type = 'line'}) switch_state = 'right' if Module.void_or_tile then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_void_or_tile', - 'Void Tiles', - 'On = Changes the tiles to out-of-map.\nOff = Changes the tiles to lab-dark-2' - ) + add_switch(scroll_pane, switch_state, 'void_or_tile', 'Void Tiles', 'On = Changes the tiles to out-of-map.\nOff = Changes the tiles to lab-dark-2') scroll_pane.add({type = 'line'}) switch_state = 'right' if Module.trusted_only_car_tanks then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_trusted_only_car_tanks', - 'Market Purchase', - 'On = Allows only trusted people to buy car/tanks.\nOff = Allows everyone to buy car/tanks.' - ) + add_switch(scroll_pane, switch_state, 'trusted_only_car_tanks', 'Market Purchase', 'On = Allows only trusted people to buy car/tanks.\nOff = Allows everyone to buy car/tanks.') scroll_pane.add({type = 'line'}) switch_state = 'right' if Module.allow_decon then switch_state = 'left' end - add_switch( - scroll_pane, - switch_state, - 'comfy_panel_allow_decon', - 'Deconstruct', - 'On = Allows decon on car/tanks/trains.\nOff = Disables decon on car/tanks/trains.' - ) + add_switch(scroll_pane, switch_state, 'allow_decon', 'Deconstruct', 'On = Allows decon on car/tanks/trains.\nOff = Disables decon on car/tanks/trains.') scroll_pane.add({type = 'line'}) if Module.christmas_mode then switch_state = 'left' end - add_switch(scroll_pane, switch_state, 'comfy_panel_christmas_mode', 'Wintery Mode', 'On = Enables wintery mode.\nOff = Disables wintery mode.') + add_switch(scroll_pane, switch_state, 'christmas_mode', 'Wintery Mode', 'On = Enables wintery mode.\nOff = Disables wintery mode.') scroll_pane.add({type = 'line'}) end end @@ -787,7 +694,7 @@ local function on_gui_switch_state_changed(event) end fortress_functions[event.element.name](event) return - elseif is_loaded('comfy_panel.poll') then + elseif is_loaded('utils.gui.poll') then local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem') if is_spamming then return @@ -811,35 +718,16 @@ local function on_robot_built_entity(event) spaghett_deny_building(event) end -local function on_gui_click(event) - if not event then - return - end - local player = game.get_player(event.player_index) - if not (player and player.valid) then - return - end +Gui.add_tab_to_gui({name = module_name, caption = 'Config', id = build_config_gui_token, admin = false}) - if not event.element then - return - end - if not event.element.valid then - return +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) end +) - local name = event.element.name - - if name == 'tab_' .. module_name then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Main Button') - if is_spamming then - return - end - end -end - -Tabs.add_tab_to_gui({name = module_name, id = build_config_gui_token, admin = false}) - -Event.add(defines.events.on_gui_click, on_gui_click) Event.add(defines.events.on_gui_switch_state_changed, on_gui_switch_state_changed) Event.add(defines.events.on_force_created, on_force_created) Event.add(defines.events.on_built_entity, on_built_entity) diff --git a/comfy_panel/group.lua b/utils/gui/group.lua similarity index 95% rename from comfy_panel/group.lua rename to utils/gui/group.lua index 0b0658f4..c2fa9191 100644 --- a/comfy_panel/group.lua +++ b/utils/gui/group.lua @@ -1,12 +1,12 @@ -- this script adds a group button to create groups for your players -- -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' local Global = require 'utils.global' local SpamProtection = require 'utils.spam_protection' local Event = require 'utils.event' local Token = require 'utils.token' -local module_name = 'Groups' +local module_name = Gui.uid_name() local this = { player_group = {}, @@ -154,7 +154,7 @@ local build_group_gui_token = Token.register(build_group_gui) local function refresh_gui() for _, p in pairs(game.connected_players) do - local frame = Tabs.comfy_panel_get_active_frame(p) + local frame = Gui.get_player_active_frame(p) if frame then if frame.name == module_name then local new_group_name = frame.frame2.group_table.new_group_name.text @@ -171,7 +171,7 @@ local function refresh_gui() local data = {player = p, frame = frame} build_group_gui(data) - frame = Tabs.comfy_panel_get_active_frame(p) + frame = Gui.get_player_active_frame(p) frame.frame2.group_table.new_group_name.text = new_group_name frame.frame2.group_table.new_group_description.text = new_group_description end @@ -235,18 +235,11 @@ local function on_gui_click(event) local name = element.name - if name and name == 'tab_' .. module_name then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Groups tab_Groups') - if is_spamming then - return - end - end - - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Groups' then return end @@ -380,7 +373,15 @@ function Public.reset_groups() this.tag_groups = {} end -Tabs.add_tab_to_gui({name = module_name, id = build_group_gui_token, admin = false}) +Gui.add_tab_to_gui({name = module_name, caption = 'Groups', id = build_group_gui_token, admin = false}) + +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) Event.add(defines.events.on_gui_click, on_gui_click) Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/comfy_panel/map_score.lua b/utils/gui/map_score.lua similarity index 89% rename from comfy_panel/map_score.lua rename to utils/gui/map_score.lua index e846d630..eff5d8c7 100644 --- a/comfy_panel/map_score.lua +++ b/utils/gui/map_score.lua @@ -1,7 +1,8 @@ -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' +local Event = require 'utils.event' local Token = require 'utils.token' -local module_name = 'Map Scores' +local module_name = Gui.uid_name() local Public = {} @@ -100,9 +101,16 @@ local function on_init() } end -Tabs.add_tab_to_gui({name = module_name, id = score_list_token, admin = false}) +Gui.add_tab_to_gui({name = module_name, caption = 'Map Scores', id = score_list_token, admin = false}) -local event = require 'utils.event' -event.on_init(on_init) +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) + +Event.on_init(on_init) return Public diff --git a/comfy_panel/player_list.lua b/utils/gui/player_list.lua similarity index 98% rename from comfy_panel/player_list.lua rename to utils/gui/player_list.lua index 08c0b645..52cb1df7 100644 --- a/comfy_panel/player_list.lua +++ b/utils/gui/player_list.lua @@ -17,7 +17,7 @@ local Where = require 'utils.commands.where' local Session = require 'utils.datastore.session_data' local Jailed = require 'utils.datastore.jail_data' local Supporters = require 'utils.datastore.supporters' -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' local Global = require 'utils.global' local SpamProtection = require 'utils.spam_protection' local RPG = require 'modules.rpg.table' @@ -25,7 +25,7 @@ local Token = require 'utils.token' local Public = {} -local module_name = 'Players' +local module_name = Gui.uid_name() local this = { player_list = { @@ -740,18 +740,11 @@ local function on_gui_click(event) local name = element.name local player = game.get_player(event.player_index) - if name == 'tab_' .. module_name then - local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList tab_Players') - if is_spamming then - return - end - end - - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Players' then return end @@ -900,9 +893,9 @@ end local function refresh() for _, player in pairs(game.connected_players) do - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if frame then - if frame.name ~= module_name then + if frame.name ~= 'Players' then return end local data = {player = player, frame = frame, sort_by = this.player_list.sorting_method[player.index]} @@ -938,7 +931,15 @@ function Public.rpg_enabled(value) return this.rpg_enabled end -Tabs.add_tab_to_gui({name = module_name, id = player_list_show_token, admin = false}) +Gui.add_tab_to_gui({name = module_name, caption = 'Players', id = player_list_show_token, admin = false}) + +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_player_left_game, on_player_left_game) diff --git a/comfy_panel/poll.lua b/utils/gui/poll.lua similarity index 97% rename from comfy_panel/poll.lua rename to utils/gui/poll.lua index c45881a0..704a0158 100644 --- a/comfy_panel/poll.lua +++ b/utils/gui/poll.lua @@ -3,9 +3,8 @@ local Global = require 'utils.global' local Event = require 'utils.event' local Game = require 'utils.game' local Server = require 'utils.server' -local ComfyGui = require 'comfy_panel.main' local session = require 'utils.datastore.session_data' -local Config = require 'comfy_panel.config' +local Config = require 'utils.gui.config' local SpamProtection = require 'utils.spam_protection' local Class = {} @@ -293,11 +292,11 @@ local function update_poll_viewer(data) redraw_poll_viewer_content(data) end -local function draw_main_frame(left, player) +local function draw_main_frame(_, player) local trusted = session.get_trusted_table() - local frame = left.add {type = 'frame', name = main_frame_name, caption = 'Polls', direction = 'vertical'} + local main_frame, inside_frame = Gui.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, main_button_name, 'Polls') - local poll_viewer_top_flow = frame.add {type = 'table', column_count = 5} + local poll_viewer_top_flow = inside_frame.add {type = 'table', column_count = 5} poll_viewer_top_flow.style.horizontal_spacing = 0 local back_button = poll_viewer_top_flow.add {type = 'button', name = poll_view_back_name, caption = '◀'} @@ -314,9 +313,9 @@ local function draw_main_frame(left, player) local remaining_time_label = poll_viewer_top_flow.add {type = 'label'} - local poll_viewer_content = frame.add {type = 'scroll-pane'} + local poll_viewer_content = inside_frame.add {type = 'scroll-pane'} poll_viewer_content.style.maximal_height = 480 - poll_viewer_content.style.width = 295 + poll_viewer_content.style.width = 274 local poll_index = player_poll_index[player.index] or #polls @@ -329,27 +328,24 @@ local function draw_main_frame(left, player) poll_index = poll_index } - Gui.set_data(frame, data) + Gui.set_data(main_frame, data) Gui.set_data(back_button, data) Gui.set_data(forward_button, data) update_poll_viewer(data) - local bottom_flow = frame.add {type = 'flow', direction = 'horizontal'} + local bottom_flow = inside_frame.add {type = 'flow', direction = 'horizontal'} local left_flow = bottom_flow.add {type = 'flow'} left_flow.style.horizontal_align = 'left' left_flow.style.horizontally_stretchable = true - local close_button = left_flow.add {type = 'button', name = main_button_name, caption = 'Close'} - apply_button_style(close_button) - local right_flow = bottom_flow.add {type = 'flow'} right_flow.style.horizontal_align = 'right' - local comfy_panel_config = Config.get('gui_config') + local config = Config.get('gui_config') - if (trusted[player.name] or player.admin) or comfy_panel_config.poll_trusted == false then + if (trusted[player.name] or player.admin) or config.poll_trusted == false then local create_poll_button = right_flow.add {type = 'button', name = create_poll_button_name, caption = 'Create Poll'} apply_button_style(create_poll_button) else @@ -403,7 +399,7 @@ local function toggle(event) if main_frame then remove_main_frame(main_frame, left, event.player) else - ComfyGui.comfy_panel_clear_gui(event.player) + Gui.clear_all_active_frames(event.player) draw_main_frame(left, event.player) end end @@ -420,7 +416,7 @@ local function update_duration(slider) if value == 0 then label.caption = 'Endless Poll.' else - label.caption = value * duration_step .. ' seconds.' + label.caption = value * duration_step .. ' sec.' end end @@ -551,6 +547,7 @@ local function draw_create_poll_frame(parent, player, previous_data) local scroll_pane = frame.add {type = 'scroll-pane', vertical_scroll_policy = 'always'} scroll_pane.style.maximal_height = 250 scroll_pane.style.maximal_width = 300 + scroll_pane.style.padding = 3 local grid = scroll_pane.add {type = 'table', column_count = 3} @@ -766,8 +763,8 @@ local function player_joined(event) return end - if ComfyGui.get_mod_gui_top_frame() then - ComfyGui.add_mod_button( + if Gui.get_mod_gui_top_frame() then + Gui.add_mod_button( player, { type = 'sprite-button', @@ -936,6 +933,10 @@ Gui.on_text_changed( end if textfield and textfield.valid then + if string.len(textfield.text) >= 50 then + textfield.text = '' + return + end data.question = textfield.text end end @@ -952,6 +953,10 @@ Gui.on_text_changed( end if textfield and textfield.valid then + if string.len(textfield.text) >= 50 then + textfield.text = '' + return + end data.answers[data.count].text = textfield.text end end diff --git a/comfy_panel/score.lua b/utils/gui/score.lua similarity index 95% rename from comfy_panel/score.lua rename to utils/gui/score.lua index 0dd97163..baee7819 100644 --- a/comfy_panel/score.lua +++ b/utils/gui/score.lua @@ -3,7 +3,7 @@ local Event = require 'utils.event' local Global = require 'utils.global' -local Tabs = require 'comfy_panel.main' +local Gui = require 'utils.gui' local SpamProtection = require 'utils.spam_protection' local Token = require 'utils.token' local format_number = require 'util'.format_number @@ -14,7 +14,7 @@ local this = { sort_by = {} } -local module_name = 'Scoreboard' +local module_name = Gui.uid_name() Global.register( this, @@ -255,11 +255,12 @@ local show_score_token = Token.register(show_score) local function refresh_score_full() for _, player in pairs(game.connected_players) do - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if frame then - if frame.name == module_name then - show_score({player = player, frame = frame}) + if frame.name ~= 'Scoreboard' then + return end + show_score({player = player, frame = frame}) end end end @@ -280,18 +281,11 @@ local function on_gui_click(event) local player = game.get_player(event.player_index) local name = event.element.name - if name == 'tab_' .. module_name then - local is_spamming = SpamProtection.is_spamming(player, nil, 'Scoreboard tab_Scoreboard') - if is_spamming then - return - end - end - - local frame = Tabs.comfy_panel_get_active_frame(player) + local frame = Gui.get_player_active_frame(player) if not frame then return end - if frame.name ~= module_name then + if frame.name ~= 'Scoreboard' then return end @@ -462,7 +456,15 @@ local function on_built_entity(event) score.built_entities = 1 + (score.built_entities or 0) end -Tabs.add_tab_to_gui({name = module_name, id = show_score_token, admin = false}) +Gui.add_tab_to_gui({name = module_name, caption = 'Scoreboard', id = show_score_token, admin = false}) + +Gui.on_click( + module_name, + function(event) + local player = event.player + Gui.reload_active_tab(player) + end +) Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) Event.add(defines.events.on_player_died, on_player_died) diff --git a/comfy_panel/server_select.lua b/utils/gui/server_select.lua similarity index 87% rename from comfy_panel/server_select.lua rename to utils/gui/server_select.lua index 5f88c2b0..997708ed 100644 --- a/comfy_panel/server_select.lua +++ b/utils/gui/server_select.lua @@ -1,7 +1,6 @@ local Event = require 'utils.event' local Gui = require 'utils.gui' local Server = require 'utils.server' -local ComfyGui = require 'comfy_panel.main' local SpamProtection = require 'utils.spam_protection' local main_frame_name = Gui.uid_name() @@ -33,21 +32,16 @@ local function apply_button_style(button) end local function draw_main_frame(player) + Gui.clear_all_active_frames(player) local instance = get_instance() - local left = player.gui.left - local frame = left.add {type = 'frame', name = main_frame_name, caption = 'Comfy Servers', direction = 'vertical'} + local main_frame, inside_frame = Gui.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, discard_button_name, 'Comfy Servers') - local inside_frame = - frame.add { - type = 'frame', - style = 'deep_frame_in_shallow_frame' - } local inside_frame_style = inside_frame.style inside_frame_style.padding = 0 inside_frame_style.maximal_height = 800 - player.opened = frame + player.opened = main_frame local instances = {} local server_instances = Server.get_instances() @@ -74,7 +68,7 @@ local function draw_main_frame(player) for _, i in ipairs(instances) do viewer_table.add { type = 'label', - caption = 'Name: ' .. i.name, + caption = i.name, tooltip = i.connected .. '\nVersion: ' .. i.version, style = 'caption_label' } @@ -111,26 +105,16 @@ local function draw_main_frame(player) end end end - - local bottom_flow = frame.add {type = 'flow', direction = 'horizontal'} - - local left_flow = bottom_flow.add {type = 'flow'} - left_flow.style.horizontal_align = 'left' - left_flow.style.horizontally_stretchable = true - - local close_button = left_flow.add {type = 'button', name = discard_button_name, caption = 'Close'} - apply_button_style(close_button) - - local right_flow = bottom_flow.add {type = 'flow'} - right_flow.style.horizontal_align = 'right' end local function toggle(player) local left = player.gui.left local frame = left[main_frame_name] + if not player or not player.valid or not player.character then return end + if frame and frame.valid then Gui.remove_data_recursively(frame) frame.destroy() @@ -140,9 +124,14 @@ local function toggle(player) end local function create_main_button(event) + local multiplayer = game.is_multiplayer() + if not multiplayer then + return + end + local player = game.get_player(event.player_index) - if ComfyGui.get_mod_gui_top_frame() then - ComfyGui.add_mod_button( + if Gui.get_mod_gui_top_frame() then + Gui.add_mod_button( player, { type = 'sprite-button', From dbe79dcdfd9e671de19de290bf00392faa44a089 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Apr 2022 19:39:01 +0200 Subject: [PATCH 04/24] minor change --- locale/en/mtn_fortress_v3.cfg | 2 +- maps/mountain_fortress_v3/locomotive/friendly_pet.lua | 2 +- maps/mountain_fortress_v3/locomotive/market.lua | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/locale/en/mtn_fortress_v3.cfg b/locale/en/mtn_fortress_v3.cfg index 662e2985..07a960cf 100644 --- a/locale/en/mtn_fortress_v3.cfg +++ b/locale/en/mtn_fortress_v3.cfg @@ -51,7 +51,7 @@ map_off=OFF [locomotive] upgrades=Upgrades: items=Items: -shoo=^-^ Please don't shoo at me ^-^ +shoo=[Desync Bro] not_trusted=You need to be trusted to purchase this. coins_left=Coins left: __1__ market_name=Market diff --git a/maps/mountain_fortress_v3/locomotive/friendly_pet.lua b/maps/mountain_fortress_v3/locomotive/friendly_pet.lua index 4fb81377..e086f753 100644 --- a/maps/mountain_fortress_v3/locomotive/friendly_pet.lua +++ b/maps/mountain_fortress_v3/locomotive/friendly_pet.lua @@ -104,7 +104,7 @@ function Public.spawn_biter() target = this.locomotive_biter, target_offset = {0, -3.5}, scale = 1.05, - font = 'default-large-semibold', + font = 'heading-2', color = {r = 175, g = 75, b = 255}, alignment = 'center', scale_with_zoom = false diff --git a/maps/mountain_fortress_v3/locomotive/market.lua b/maps/mountain_fortress_v3/locomotive/market.lua index 6b821bfa..3fcecdd1 100644 --- a/maps/mountain_fortress_v3/locomotive/market.lua +++ b/maps/mountain_fortress_v3/locomotive/market.lua @@ -519,12 +519,14 @@ local function redraw_market_items(gui, player, search_text) return end - gui.add( + local upgrades_label = + gui.add( { type = 'label', caption = ({'locomotive.upgrades'}) } ) + upgrades_label.style.font = 'heading-2' local upgrade_table = gui.add({type = 'table', column_count = 6}) @@ -574,12 +576,14 @@ local function redraw_market_items(gui, player, search_text) ::continue:: end end - gui.add( + local items_label = + gui.add( { type = 'label', caption = ({'locomotive.items'}) } ) + items_label.style.font = 'heading-2' local slider_value = ceil(players[player.index].data.slider.slider_value) local items_table = gui.add({type = 'table', column_count = 6}) @@ -801,7 +805,8 @@ local function gui_opened(event) player.opened = frame local search_table = inside_table.add({type = 'table', column_count = 2}) - search_table.add({type = 'label', caption = ({'locomotive.search_text'})}) + local search_name = search_table.add({type = 'label', caption = ({'locomotive.search_text'})}) + search_name.style.font = 'heading-2' local search_text = search_table.add({type = 'textfield'}) search_text.style.width = 140 From 82affb25ddc17c2484cede1bc7e0b3e8748a29c5 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Apr 2022 19:41:44 +0200 Subject: [PATCH 05/24] minor fix --- utils/gui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/gui.lua b/utils/gui.lua index aa0aa174..5a90aa1c 100644 --- a/utils/gui.lua +++ b/utils/gui.lua @@ -529,7 +529,7 @@ local function draw_main_frame(player) Public.get_main_frame(player).destroy() end - local frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, _, close_button_name, 'Comfy Panel') + local frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, close_button_name, 'Comfy Panel') local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'}) From 29b865fe3ba541df8ba0f8ff287eec06a80a5a44 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Tue, 5 Apr 2022 20:02:13 +0200 Subject: [PATCH 06/24] rename one punch to aoe punch --- locale/en/rpg.cfg | 12 +++--- locale/ru/rpg.cfg | 6 --- locale/zh-CN/rpg.cfg | 7 +--- maps/dungeons/boss_arena.lua | 4 +- maps/mountain_fortress_v3/commands.lua | 2 +- maps/mountain_fortress_v3/main.lua | 4 +- modules/rpg/commands.lua | 6 +-- modules/rpg/functions.lua | 20 ++++----- modules/rpg/gui.lua | 20 ++++----- modules/rpg/main.lua | 20 ++++----- modules/rpg/settings.lua | 58 +++++++++++++------------- modules/rpg/table.lua | 32 +++++++------- 12 files changed, 90 insertions(+), 101 deletions(-) diff --git a/locale/en/rpg.cfg b/locale/en/rpg.cfg index cc6be772..8cff61a4 100644 --- a/locale/en/rpg.cfg +++ b/locale/en/rpg.cfg @@ -2,7 +2,7 @@ no_valid_surface=No surface name given flame_boots_worn_out=Your flame boots have worn out. flame_mana_remaining=Mana remaining: __1__ -one_punch_text=ONE PUNCH +aoe_punch_text=AOE PUNCH mana_casting_too_fast=There was a lot more to magic, as __1__ quickly found out, than waving their wand and saying a few funny words. low_level=You lack the level to cast this spell. not_inside_pos=You wave your wand but realize that it´s out of reach. @@ -59,8 +59,8 @@ mana_max=This is your max mana. You can increase the regen by increasing your ma mining_name=MINING\nSPEED slot_name=SLOT\nBONUS melee_name=MELEE\nDAMAGE -one_punch_chance=Life on-hit: __1__\nOne punch chance: __2__ % \n+__3__ [img=recipe.defender-capsule] -one_punch_disabled=One Punch is disabled. +aoe_punch_chance=Life on-hit: __1__\nAOE punch chance: __2__ % \n+__3__ [img=recipe.defender-capsule] +aoe_punch_disabled=AOE punch is disabled. bonus_tooltip=Reach distance bonus: __1__\nBuild distance bonus: __2__\nItem drop distance bonus: __3__\nLoot pickup distance bonus: __4__\nItem pickup distance bonus: __5__\nResource reach distance bonus: __6__\nRepair speed: __7__ reach_distance=REACH\nDISTANCE crafting_speed=CRAFTING\nSPEED @@ -96,9 +96,9 @@ movement_text_label=Enable movement speed bonus? movement_text_tooltip=Don´t feeling like running like the flash?\nYou can toggle it here. stone_path_label=Enable stone-path when mining? stone_path_tooltip=Enabling this will automatically create stone-path when you mine. -one_punch_label=Enable one-punch? -one_punch_tooltip=Enabling this will have a chance of one-punching biters.\nOne-Punch only works if both ammo AND gun is unequipped. -one_punch_globally=Enabled globally.\nOne-Punch only works if both ammo AND gun is unequipped. +aoe_punch_label=Enable AOE punch? +aoe_punch_tooltip=Enabling this will have a chance of creating a AOE punch against biters.\nAOE-Punch only works if both ammo AND gun is unequipped. +aoe_punch_globally=Enabled globally.\nAOE-Punch only works if both ammo AND gun is unequipped. flameboots_label=Enable flame boots? flameboots_tooltip=When the bullets simply don´t bite. explosive_bullets_label=Enable explosive bullets? diff --git a/locale/ru/rpg.cfg b/locale/ru/rpg.cfg index c38018ad..a14ae7a9 100644 --- a/locale/ru/rpg.cfg +++ b/locale/ru/rpg.cfg @@ -2,7 +2,6 @@ no_valid_surface=Название поверхности не указано flame_boots_worn_out=Ваши огненные сапоги износились. flame_mana_remaining=Маны осталось: __1__ -one_punch_text=ОДИН УДАР mana_casting_too_fast=Как быстро выяснил __1__, в магии было гораздо больше, чем просто взмахнуть палочкой и произнести несколько забавных слов. low_level=Вам не хватает уровня для произнесения этого заклинания. not_inside_pos=Вы машете палочкой, но понимаете, что это вне досягаемости. @@ -59,8 +58,6 @@ mana_max=Это ваша максимальная мана. Вы можете у mining_name=СКОРОСТЬ\nДОБЫЧИ slot_name=БОНУС\nЯЧЕЕК melee_name=УРОН\nРУКАМИ -one_punch_chance=Жизни за удар: __1__\nШанс "с одного удара": __2__%\n+__3__ [img=recipe.defender-capsule] -one_punch_disabled="С одного удара" отключено. bonus_tooltip=Бонус дальности досягаемости: __1__\nБонус дистанции строительства: __2__\nБонус дальности выпадения предметов: __3__\nБонус дальности подбора добычи: __4__\nБонус дальности подбора предметов: __5__\nБонус дальности досягаемости ресурсов: __6__\nСкорость ремонта: __7__ reach_distance=РАДИУС\nДЕЙСТВИЙ crafting_speed=СКОРОСТЬ\nКРАФТА @@ -95,9 +92,6 @@ movement_text_label=Включить бонус скорости передви movement_text_tooltip=Хотите бегать, как Флэш?\nВы можете переключить это здесь. stone_path_label=Включить каменную тропу при добыче? stone_path_tooltip=Включение этого автоматически создаст тропу из камня при добыче. -one_punch_label=Включить "С одного удара"? -one_punch_tooltip=Включив это, вы будете иметь шанс убить кусаку с одного удара.\n"С одного удара" работает только в том случае, если не экипированы и боеприпасы, и оружие. -one_punch_globally=Включить глобально.\n"С одного удара" работает только в том случае, если не экипированы и боеприпасы, и оружие. flameboots_label=Включить огненные сапоги? flameboots_tooltip=Когда пуль просто недостаточно. explosive_bullets_label=Включить разрывные пули? diff --git a/locale/zh-CN/rpg.cfg b/locale/zh-CN/rpg.cfg index 60611211..19ef7a23 100644 --- a/locale/zh-CN/rpg.cfg +++ b/locale/zh-CN/rpg.cfg @@ -2,7 +2,7 @@ no_valid_surface=无效图层! flame_boots_worn_out=你的火焰鞋穿坏了. flame_mana_remaining=剩余魔法:__1__ -one_punch_text=暴击 + mana_casting_too_fast= __1__ 魔法还有很多, 像 __2__ 迅速创建出, 然后挥舞着他们的魔杖,说一些难以理解的词. low_level=等级不够. not_inside_pos=你挥动你的魔杖, 但意识到它不能达到. @@ -60,8 +60,6 @@ mana_max=这是你的最大魔力值。你可以通过增加你的魔法技能 mining_name=挖掘\n速度 slot_name=背包\n加成 melee_name=近战\n伤害 -one_punch_chance=命中生命: __1__\n暴击几率: __2__ %\n +__3__ [img=recipe.defender-capsule] -one_punch_disabled=暴击被禁用 bonus_tooltip=到达距离加成: __1__\n建筑距离加成: __2__\n物品投掷距离加成: __3__\n拾取战利品距离加成: __4__\n物品拾取距离加成: __5__\n资源到达距离加成: __6__\n修理速度: __7__ reach_distance=到达\n距离 crafting_speed=制作\n速度 @@ -95,9 +93,6 @@ movement_text_label=启用移动速度加成? movement_text_tooltip=不想像闪电一样奔跑吗?\n你可以在这里切换。 stone_path_label=采矿时启用石路? stone_path_tooltip=启用此选项将在您挖掘时,自动铺石砖 -one_punch_label=启用暴击? -one_punch_tooltip=启用此选项将有一次击打敌人的机会,不能装备枪和子弹! -one_punch_globally=启用全局。 flameboots_label=启用火焰靴? flameboots_tooltip=当子弹未击中。 magic_label=启用魔法(通过吃鱼施法) diff --git a/maps/dungeons/boss_arena.lua b/maps/dungeons/boss_arena.lua index ca85c51b..10b10c99 100644 --- a/maps/dungeons/boss_arena.lua +++ b/maps/dungeons/boss_arena.lua @@ -195,7 +195,7 @@ local function teleport_player_out(arena, player) local surface = arenatable.previous_position[arena].surface local position = arenatable.previous_position[arena].position local rpg = RPG.get('rpg_t') - rpg[player.index].one_punch = true + rpg[player.index].aoe_punch = true hide_rpg(player, true) player.teleport(surface.find_non_colliding_position('character', position, 20, 0.5), surface) arenatable.previous_position[arena].position = nil @@ -212,7 +212,7 @@ local function teleport_player_in(arena, player) arenatable.previous_position[arena].surface = player.surface arenatable.timer[arena] = game.tick local rpg = RPG.get('rpg_t') - rpg[player.index].one_punch = false + rpg[player.index].aoe_punch = false rpg[player.index].enable_entity_spawn = false hide_rpg(player, false) diff --git a/maps/mountain_fortress_v3/commands.lua b/maps/mountain_fortress_v3/commands.lua index 335e904a..1858b9a1 100644 --- a/maps/mountain_fortress_v3/commands.lua +++ b/maps/mountain_fortress_v3/commands.lua @@ -123,7 +123,7 @@ commands.add_command( commands.add_command( 'disable_biters', - 'Usable only for admins - sets the queue speed of this map!', + 'Usable only for admins - disables wave defense!', function() local player = game.player diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index d3d4e768..d4dd60f1 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -174,8 +174,8 @@ function Public.reset_map() RPG.enable_flame_boots(true) RPG.personal_tax_rate(0.4) RPG.enable_stone_path(true) - RPG.enable_one_punch(true) - RPG.enable_one_punch_globally(false) + RPG.enable_aoe_punch(true) + RPG.enable_aoe_punch_globally(false) RPG.enable_range_buffs(true) RPG.enable_auto_allocate(true) RPG.disable_cooldowns_on_spells() diff --git a/modules/rpg/commands.lua b/modules/rpg/commands.lua index 1e75951d..f8f22599 100644 --- a/modules/rpg/commands.lua +++ b/modules/rpg/commands.lua @@ -171,7 +171,7 @@ if _DEBUG then ) commands.add_command( - 'rpg_debug_one_punch', + 'rpg_debug_aoe_punch', '', function() local player = game.player @@ -184,7 +184,7 @@ if _DEBUG then return end - Public.toggle_debug_one_punch() + Public.toggle_debug_aoe_punch() end ) @@ -212,7 +212,7 @@ if _DEBUG then data[k].mana = 50000 data[k].mana_max = 50000 data[k].debug_mode = true - data[k].one_punch = true + data[k].aoe_punch = true data[k].stone_path = true data[k].strength = 3000 data[k].vitality = 3000 diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index 84c07c63..6d98a923 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -119,12 +119,12 @@ local function level_up(player) return end - -- automatically enable one_punch and stone_path, + -- automatically enable aoe_punch and stone_path, -- but do so only once. - if rpg_t.level >= settings_level['one_punch_label'] then - if not rpg_t.auto_toggle_features.one_punch then - rpg_t.auto_toggle_features.one_punch = true - rpg_t.one_punch = true + if rpg_t.level >= settings_level['aoe_punch_label'] then + if not rpg_t.auto_toggle_features.aoe_punch then + rpg_t.auto_toggle_features.aoe_punch = true + rpg_t.aoe_punch = true end end if rpg_t.level >= settings_level['stone_path_label'] then @@ -694,7 +694,7 @@ function Public.get_life_on_hit(player) return (rpg_t.vitality - 10) * 0.4 end -function Public.get_one_punch_chance(player) +function Public.get_aoe_punch_chance(player) local rpg_t = Public.get_value_from_player(player.index) if rpg_t.strength < 100 then return 0 @@ -782,10 +782,10 @@ function Public.rpg_reset_player(player, one_time_reset) last_mined_entity_position = {x = 0, y = 0}, show_bars = false, stone_path = false, - one_punch = false, + aoe_punch = false, auto_toggle_features = { stone_path = false, - one_punch = false + aoe_punch = false } } ) @@ -824,10 +824,10 @@ function Public.rpg_reset_player(player, one_time_reset) last_mined_entity_position = {x = 0, y = 0}, show_bars = false, stone_path = false, - one_punch = false, + aoe_punch = false, auto_toggle_features = { stone_path = false, - one_punch = false + aoe_punch = false } } ) diff --git a/modules/rpg/gui.lua b/modules/rpg/gui.lua index dc979c5b..b28b4f96 100644 --- a/modules/rpg/gui.lua +++ b/modules/rpg/gui.lua @@ -314,15 +314,15 @@ local function draw_main_frame(player, location) add_gui_description(right_bottom_table, ({'rpg_gui.melee_name'}), w1) local melee_damage_value = round(100 * (1 + Public.get_melee_modifier(player))) .. '%' local melee_damage_tooltip - if rpg_extra.enable_one_punch then + if rpg_extra.enable_aoe_punch then melee_damage_tooltip = ({ - 'rpg_gui.one_punch_chance', + 'rpg_gui.aoe_punch_chance', Public.get_life_on_hit(player), - Public.get_one_punch_chance(player), + Public.get_aoe_punch_chance(player), Public.get_extra_following_robots(player) }) else - melee_damage_tooltip = ({'rpg_gui.one_punch_disabled'}) + melee_damage_tooltip = ({'rpg_gui.aoe_punch_disabled'}) end add_gui_stat(right_bottom_table, melee_damage_value, w2, melee_damage_tooltip) @@ -505,7 +505,7 @@ Gui.on_click( local explosive_bullets_gui_input = data.explosive_bullets_gui_input local enable_entity_gui_input = data.enable_entity_gui_input local stone_path_gui_input = data.stone_path_gui_input - local one_punch_gui_input = data.one_punch_gui_input + local aoe_punch_gui_input = data.aoe_punch_gui_input local auto_allocate_gui_input = data.auto_allocate_gui_input local rpg_t = Public.get_value_from_player(player.index) @@ -515,11 +515,11 @@ Gui.on_click( rpg_t.allocate_index = auto_allocate_gui_input.selected_index end - if one_punch_gui_input and one_punch_gui_input.valid then - if not one_punch_gui_input.state then - rpg_t.one_punch = false - elseif one_punch_gui_input.state then - rpg_t.one_punch = true + if aoe_punch_gui_input and aoe_punch_gui_input.valid then + if not aoe_punch_gui_input.state then + rpg_t.aoe_punch = false + elseif aoe_punch_gui_input.state then + rpg_t.aoe_punch = true end end diff --git a/modules/rpg/main.lua b/modules/rpg/main.lua index b7a9f735..feb8d596 100644 --- a/modules/rpg/main.lua +++ b/modules/rpg/main.lua @@ -26,8 +26,8 @@ local random = math.random local sqrt = math.sqrt local abs = math.abs -local function log_one_punch(callback) - local debug = Public.get('rpg_extra').debug_one_punch +local function log_aoe_punch(callback) + local debug = Public.get('rpg_extra').debug_aoe_punch if not debug then return end @@ -541,7 +541,7 @@ local function set_health_boost(entity, damage, cause) end --Melee damage modifier -local function one_punch(character, target, damage, get_health_pool) +local function aoe_punch(character, target, damage, get_health_pool) if not (target and target.valid) then return end @@ -556,7 +556,7 @@ local function one_punch(character, target, damage, get_health_pool) { name = 'flying-text', position = {character.position.x + base_vector[1] * 0.5, character.position.y + base_vector[2] * 0.5}, - text = ({'rpg_main.one_punch_text'}), + text = ({'rpg_main.aoe_punch_text'}), color = {255, 0, 0} } ) @@ -727,7 +727,7 @@ local function on_entity_damaged(event) --Calculate modified damage. local damage = Public.get_final_damage(cause.player, entity, original_damage_amount) - local enable_one_punch = Public.get('rpg_extra').enable_one_punch + local enable_aoe_punch = Public.get('rpg_extra').enable_aoe_punch local rpg_t = Public.get_value_from_player(cause.player.index) --Floating messages and particle effects. @@ -758,12 +758,12 @@ local function on_entity_damaged(event) local get_health_pool = has_health_boost(entity, damage, final_damage_amount, cause) --Cause a one punch. - if enable_one_punch then - if rpg_t.one_punch then - local chance = Public.get_one_punch_chance(cause.player) * 10 + if enable_aoe_punch then + if rpg_t.aoe_punch then + local chance = Public.get_aoe_punch_chance(cause.player) * 10 local chance_to_hit = random(0, 999) local success = chance_to_hit < chance - log_one_punch( + log_aoe_punch( function() if success then print('[OnePunch]: Chance: ' .. chance .. ' Chance to hit: ' .. chance_to_hit .. ' Success: true' .. ' Damage: ' .. damage) @@ -773,7 +773,7 @@ local function on_entity_damaged(event) end ) if success then - one_punch(cause, entity, damage, get_health_pool) -- only kill the biters if their health is below or equal to zero + aoe_punch(cause, entity, damage, get_health_pool) -- only kill the biters if their health is below or equal to zero return end end diff --git a/modules/rpg/settings.lua b/modules/rpg/settings.lua index c9539be5..483e9150 100644 --- a/modules/rpg/settings.lua +++ b/modules/rpg/settings.lua @@ -330,7 +330,7 @@ function Public.extra_settings(player) local flame_boots_gui_input local explosive_bullets_gui_input local stone_path_gui_input - local one_punch_gui_input + local aoe_punch_gui_input local auto_allocate_gui_input if rpg_extra.enable_stone_path then @@ -370,44 +370,44 @@ function Public.extra_settings(player) end end - if rpg_extra.enable_one_punch then - local one_punch_label = + if rpg_extra.enable_aoe_punch then + local aoe_punch_label = setting_grid.add( { type = 'label', - caption = ({'rpg_settings.one_punch_label'}), - tooltip = ({'rpg_settings.one_punch_tooltip'}) + caption = ({'rpg_settings.aoe_punch_label'}), + tooltip = ({'rpg_settings.aoe_punch_tooltip'}) } ) - local one_punch_label_style = one_punch_label.style - one_punch_label_style.horizontally_stretchable = true - one_punch_label_style.height = 35 - one_punch_label_style.vertical_align = 'center' + local aoe_punch_label_style = aoe_punch_label.style + aoe_punch_label_style.horizontally_stretchable = true + aoe_punch_label_style.height = 35 + aoe_punch_label_style.vertical_align = 'center' - local one_punch_input = setting_grid.add({type = 'flow'}) - local one_punch_input_style = one_punch_input.style - one_punch_input_style.height = 35 - one_punch_input_style.vertical_align = 'center' - local one_punch - if rpg_t.one_punch then - one_punch = rpg_t.one_punch + local aoe_punch_input = setting_grid.add({type = 'flow'}) + local aoe_punch_input_style = aoe_punch_input.style + aoe_punch_input_style.height = 35 + aoe_punch_input_style.vertical_align = 'center' + local aoe_punch + if rpg_t.aoe_punch then + aoe_punch = rpg_t.aoe_punch else - one_punch = false + aoe_punch = false end - one_punch_gui_input = create_input_element(one_punch_input, 'boolean', one_punch) + aoe_punch_gui_input = create_input_element(aoe_punch_input, 'boolean', aoe_punch) - if rpg_extra.enable_one_punch_globally then - one_punch_gui_input.state = true - one_punch_gui_input.enabled = false - one_punch_gui_input.tooltip = ({'rpg_settings.one_punch_globally'}) + if rpg_extra.enable_aoe_punch_globally then + aoe_punch_gui_input.state = true + aoe_punch_gui_input.enabled = false + aoe_punch_gui_input.tooltip = ({'rpg_settings.aoe_punch_globally'}) else - if rpg_t.level < settings_level['one_punch_label'] then - one_punch_gui_input.enabled = false - one_punch_gui_input.tooltip = ({'rpg_settings.low_level', 30}) + if rpg_t.level < settings_level['aoe_punch_label'] then + aoe_punch_gui_input.enabled = false + aoe_punch_gui_input.tooltip = ({'rpg_settings.low_level', 30}) else - one_punch_gui_input.enabled = true - one_punch_gui_input.tooltip = ({'rpg_settings.tooltip_check'}) + aoe_punch_gui_input.enabled = true + aoe_punch_gui_input.tooltip = ({'rpg_settings.tooltip_check'}) end end end @@ -698,8 +698,8 @@ function Public.extra_settings(player) data.stone_path_gui_input = stone_path_gui_input end - if rpg_extra.enable_one_punch then - data.one_punch_gui_input = one_punch_gui_input + if rpg_extra.enable_aoe_punch then + data.aoe_punch_gui_input = aoe_punch_gui_input end if rpg_extra.enable_auto_allocate then diff --git a/modules/rpg/table.lua b/modules/rpg/table.lua index 57acf98c..48170b58 100644 --- a/modules/rpg/table.lua +++ b/modules/rpg/table.lua @@ -44,7 +44,7 @@ end Public.gui_settings_levels = { ['reset_text_label'] = 50, ['stone_path_label'] = 20, - ['one_punch_label'] = 30, + ['aoe_punch_label'] = 30, ['flameboots_label'] = 100, ['explosive_bullets_label'] = 50 } @@ -114,8 +114,8 @@ function Public.reset_table() this.rpg_extra.force_mana_per_tick = false this.rpg_extra.enable_stone_path = false this.rpg_extra.enable_auto_allocate = false - this.rpg_extra.enable_one_punch = true - this.rpg_extra.enable_one_punch_globally = false + this.rpg_extra.enable_aoe_punch = true + this.rpg_extra.enable_aoe_punch_globally = false this.rpg_extra.disable_get_heal_modifier_from_using_fish = false this.rpg_extra.tweaked_crafting_items = { ['red-wire'] = true, @@ -239,14 +239,14 @@ function Public.toggle_debug() end --- Toggle debug - when you need to troubleshoot. -function Public.toggle_debug_one_punch() - if this.rpg_extra.debug_one_punch then - this.rpg_extra.debug_one_punch = false +function Public.toggle_debug_aoe_punch() + if this.rpg_extra.debug_aoe_punch then + this.rpg_extra.debug_aoe_punch = false else - this.rpg_extra.debug_one_punch = true + this.rpg_extra.debug_aoe_punch = true end - return this.rpg_extra.debug_one_punch + return this.rpg_extra.debug_aoe_punch end --- Debug only - when you need to troubleshoot. @@ -367,20 +367,20 @@ function Public.enable_auto_allocate(value) return this.rpg_extra.enable_auto_allocate end ---- Enables/disabled stone-path-tile creation on mined. +--- Enables/disabled aoe_punch. ---@param value -function Public.enable_one_punch(value) - this.rpg_extra.enable_one_punch = value or false +function Public.enable_aoe_punch(value) + this.rpg_extra.enable_aoe_punch = value or false - return this.rpg_extra.enable_one_punch + return this.rpg_extra.enable_aoe_punch end ---- Enables/disabled stone-path-tile creation on mined. +--- Enables/disabled aoe_punch. ---@param value -function Public.enable_one_punch_globally(value) - this.rpg_extra.enable_one_punch_globally = value or false +function Public.enable_aoe_punch_globally(value) + this.rpg_extra.enable_aoe_punch_globally = value or false - return this.rpg_extra.enable_one_punch_globally + return this.rpg_extra.enable_aoe_punch_globally end --- Retrieves the spells table or a given spell. From 8cb713af67d5d5d3b21af82c0018d153412a5df7 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 00:10:58 +0200 Subject: [PATCH 07/24] fix laggy module --- functions/loot_raffle.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/loot_raffle.lua b/functions/loot_raffle.lua index bd3242d9..678ace9b 100644 --- a/functions/loot_raffle.lua +++ b/functions/loot_raffle.lua @@ -407,6 +407,15 @@ local tech_tier_list = { 'rocket-silo' } +local function shuffle(tbl) + local size = #tbl + for i = size, 1, -1 do + local rand = math_random(size) + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + return tbl +end + local item_names = {} for k, _ in pairs(item_worths) do table_insert(item_names, k) @@ -418,7 +427,7 @@ local function get_raffle_keys() for i = 1, size_of_item_names, 1 do raffle_keys[i] = i end - table_shuffle_table(raffle_keys) + shuffle(raffle_keys) return raffle_keys end From 73c0c7f2be03cf37d7e2fca8800f4ecbcf1135da Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 00:16:16 +0200 Subject: [PATCH 08/24] remove unused module --- functions/loot_raffle.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/loot_raffle.lua b/functions/loot_raffle.lua index 678ace9b..f1b6c6aa 100644 --- a/functions/loot_raffle.lua +++ b/functions/loot_raffle.lua @@ -6,7 +6,6 @@ blacklist - optional list of item names that can not be rolled. example: {["sub ]] local Public = {} -local table_shuffle_table = table.shuffle_table local table_insert = table.insert local math_random = math.random local math_floor = math.floor From 03d681e29c2701475128b889f4752699a6657ecb Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 00:17:41 +0200 Subject: [PATCH 09/24] mtn v3 -make terrain randomized --- maps/mountain_fortress_v3/breached_wall.lua | 39 +- maps/mountain_fortress_v3/entities.lua | 4 +- maps/mountain_fortress_v3/functions.lua | 5 +- maps/mountain_fortress_v3/generate.lua | 2 +- maps/mountain_fortress_v3/get_perlin.lua | 6 + maps/mountain_fortress_v3/main.lua | 2 +- maps/mountain_fortress_v3/surface.lua | 3 +- maps/mountain_fortress_v3/table.lua | 16 +- maps/mountain_fortress_v3/terrain.lua | 405 ++++++++++++++++---- 9 files changed, 358 insertions(+), 124 deletions(-) diff --git a/maps/mountain_fortress_v3/breached_wall.lua b/maps/mountain_fortress_v3/breached_wall.lua index 5df020bc..27472fb1 100644 --- a/maps/mountain_fortress_v3/breached_wall.lua +++ b/maps/mountain_fortress_v3/breached_wall.lua @@ -1,5 +1,4 @@ local Collapse = require 'modules.collapse' -local Terrain = require 'maps.mountain_fortress_v3.terrain' local Balance = require 'maps.mountain_fortress_v3.balance' local RPG = require 'modules.rpg.main' local WPT = require 'maps.mountain_fortress_v3.table' @@ -15,21 +14,7 @@ local abs = math.abs local random = math.random local sub = string.sub local sqrt = math.sqrt -local level_depth = WPT.level_depth - -local forest = { - [2] = true, - [10] = true, - [13] = true, - [17] = true, - [19] = true, - [21] = true -} - -local scrap = { - [5] = true, - [15] = true -} +local zone_settings = WPT.zone_settings local clear_breach_text_and_render = function() local beam1 = WPT.get('zone1_beam1') @@ -140,8 +125,10 @@ end local compare_player_pos = function(player) local p = player.position local index = player.index - local zone = floor((abs(p.y / level_depth)) % 22) - if scrap[zone] then + local zone = floor((abs(p.y / zone_settings.zone_depth)) % zone_settings.size) + 1 + local adjusted_zones = WPT.get('adjusted_zones') + + if adjusted_zones.scrap[zone] then RPG.set_value_to_player(index, 'scrap_zone', true) else local has_scrap = RPG.get_value_from_player(index, 'scrap_zone') @@ -150,7 +137,7 @@ local compare_player_pos = function(player) end end - if forest[zone] then + if adjusted_zones.forest[zone] then RPG.set_value_to_player(index, 'forest_zone', true) else local is_in_forest = RPG.get_value_from_player(index, 'forest_zone') @@ -189,7 +176,7 @@ local compare_player_and_train = function(player, entity) { name = 'flying-text', position = position, - text = 'Warning!!! You are too far from the train!!!', + text = 'Warning! You are too far away from the main locomotive!', color = {r = 0.9, g = 0.0, b = 0.0} } ) @@ -228,14 +215,14 @@ local function distance(player) compare_player_pos(player) - local distance_to_center = floor(sqrt(p.x ^ 2 + p.y ^ 2)) + local distance_to_center = floor(sqrt(p.y ^ 2)) local location = distance_to_center - if location < Terrain.level_depth * bonus - 10 then + if location < zone_settings.zone_depth * bonus - 10 then return end - local max = Terrain.level_depth * bonus - local breach_max = Terrain.level_depth * breached_wall + local max = zone_settings.zone_depth * bonus + local breach_max = zone_settings.zone_depth * breached_wall local breach_max_times = location >= breach_max local max_times = location >= max if max_times then @@ -245,10 +232,8 @@ local function distance(player) rpg_extra.breached_walls = rpg_extra.breached_walls + 1 rpg_extra.reward_new_players = bonus_xp_on_join * rpg_extra.breached_walls WPT.set('breached_wall', breached_wall + 1) - placed_trains_in_zone.placed = 0 biters.amount = 0 placed_trains_in_zone.randomized = false - placed_trains_in_zone.positions = {} raise_event(Balance.events.breached_wall, {}) if WPT.get('breached_wall') == WPT.get('spidertron_unlocked_at_zone') then local main_market_items = WPT.get('main_market_items') @@ -258,7 +243,7 @@ local function distance(player) stack = 1, value = 'coin', price = rng, - tooltip = 'Chonk Spidertron', + tooltip = 'BiterStunner 9000', upgrade = false, static = true } diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index d77584ed..e44c830a 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -7,7 +7,6 @@ local Loot = require 'maps.mountain_fortress_v3.loot' local RPG = require 'modules.rpg.main' local Callbacks = require 'maps.mountain_fortress_v3.functions' local Mining = require 'maps.mountain_fortress_v3.mining' -local Terrain = require 'maps.mountain_fortress_v3.terrain' local Traps = require 'maps.mountain_fortress_v3.traps' local Locomotive = require 'maps.mountain_fortress_v3.locomotive' local DefenseSystem = require 'maps.mountain_fortress_v3.locomotive.defense_system' @@ -26,6 +25,7 @@ local RPG_Progression = require 'utils.datastore.rpg_data' -- tables local WPT = require 'maps.mountain_fortress_v3.table' local WD = require 'modules.wave_defense.table' +local zone_settings = WPT.zone_settings -- module local Public = {} @@ -394,7 +394,7 @@ local function angry_tree(entity, cause, player) return end - if abs(entity.position.y) < Terrain.level_depth then + if abs(entity.position.y) < zone_settings.zone_depth then return end if random(1, 6) == 1 then diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index 2be282db..e75e1283 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -13,6 +13,7 @@ local Difficulty = require 'modules.difficulty_vote_by_amount' local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions' local math2d = require 'math2d' local Misc = require 'utils.commands.misc' +local zone_settings = WPT.zone_settings local this = { power_sources = {index = 1}, @@ -1094,8 +1095,8 @@ function Public.render_direction(surface) scale_with_zoom = false } - local x_min = -WPT.level_width / 2 - local x_max = WPT.level_width / 2 + local x_min = -zone_settings.zone_width / 2 + local x_max = zone_settings.zone_width / 2 surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}}) surface.create_entity({name = 'electric-beam', position = {x_min, 74}, source = {x_min, 74}, target = {x_max, 74}}) diff --git a/maps/mountain_fortress_v3/generate.lua b/maps/mountain_fortress_v3/generate.lua index 7210bfcf..a2ff5304 100644 --- a/maps/mountain_fortress_v3/generate.lua +++ b/maps/mountain_fortress_v3/generate.lua @@ -19,6 +19,7 @@ local tiles_per_call = 8 local total_calls = ceil(1024 / tiles_per_call) local regen_decoratives = false local generate_map = Terrain.heavy_functions +local winter_mode = false local wintery_type = { ['simple-entity'] = true, ['tree'] = true, @@ -299,7 +300,6 @@ local function do_place_buildings(data) end local function wintery(ent, extra_lights) - local winter_mode = WPT.get('winter_mode') if not winter_mode then return false end diff --git a/maps/mountain_fortress_v3/get_perlin.lua b/maps/mountain_fortress_v3/get_perlin.lua index 88f49e3c..cb6336ba 100644 --- a/maps/mountain_fortress_v3/get_perlin.lua +++ b/maps/mountain_fortress_v3/get_perlin.lua @@ -73,6 +73,12 @@ local noises = { {modifier = 0.05, weight = 0.23}, {modifier = 0.1, weight = 0.11} }, + ['scrapyard_modified'] = { + {modifier = 0.006, weight = 1}, + {modifier = 0.04, weight = 0.15}, + {modifier = 0.22, weight = 0.05}, + {modifier = 0.05, weight = 0.32} + }, ['big_cave'] = { {modifier = 0.003, weight = 1}, {modifier = 0.02, weight = 0.05}, diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index d4dd60f1..a2db0647 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -252,7 +252,7 @@ function Public.reset_map() Collapse.set_kill_specific_entities(collapse_kill) Collapse.set_speed(8) Collapse.set_amount(1) - -- Collapse.set_max_line_size(WPT.level_width) + -- Collapse.set_max_line_size(zone_settings.zone_width) Collapse.set_max_line_size(540) Collapse.set_surface(surface) Collapse.set_position({0, 130}) diff --git a/maps/mountain_fortress_v3/surface.lua b/maps/mountain_fortress_v3/surface.lua index 801187c9..95287961 100644 --- a/maps/mountain_fortress_v3/surface.lua +++ b/maps/mountain_fortress_v3/surface.lua @@ -2,6 +2,7 @@ local Global = require 'utils.global' local surface_name = 'mountain_fortress_v3' local WPT = require 'maps.mountain_fortress_v3.table' local Reset = require 'maps.mountain_fortress_v3.soft_reset' +local zone_settings = WPT.zone_settings local Public = {} @@ -22,7 +23,7 @@ local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 16, ['rail'] = 16 function Public.create_surface() local map_gen_settings = { ['seed'] = math.random(10000, 99999), - ['width'] = WPT.level_width, + ['width'] = zone_settings.zone_width, ['water'] = 0.001, ['starting_area'] = 1, ['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}, diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index a26e86b1..5a01fd81 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -17,8 +17,11 @@ Global.register( end ) -Public.level_depth = 704 -Public.level_width = 510 +Public.zone_settings = { + zone_depth = 704, + zone_width = 510, + size = nil +} Public.pickaxe_upgrades = { 'Wood', @@ -167,10 +170,9 @@ function Public.reset_table() this.chests_linked_to = {} this.chest_limit_outside_upgrades = 1 this.placed_trains_in_zone = { - placed = 0, - positions = {}, limit = 2, - randomized = false + randomized = false, + zones = {} } this.marked_fixed_prices = { chest_limit_cost = 3000, @@ -226,6 +228,10 @@ function Public.reset_table() current = {}, temp_boosts = {} } + this.adjusted_zones = { + scrap = {}, + forest = {} + } this.alert_zone_1 = false -- alert the players for k, _ in pairs(this.players) do diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index b5390c38..a810c496 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -11,17 +11,9 @@ local abs = math.abs local floor = math.floor local ceil = math.ceil -Public.level_depth = WPT.level_depth -Public.level_width = WPT.level_width +local zone_settings = WPT.zone_settings local worm_level_modifier = 0.19 --- local start_ground_tiles = { --- 'dirt-1', --- 'grass-1', --- 'grass-2', --- 'dirt-2' --- } - local wagon_raffle = { 'cargo-wagon', 'cargo-wagon', @@ -133,6 +125,15 @@ local function get_scrap_mineable_entities() return scrap_mineable_entities, scrap_mineable_entities_index end +local function shuffle(tbl) + local size = #tbl + for i = size, 1, -1 do + local rand = random(size) + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + return tbl +end + local function is_position_near(area, table_to_check) local status = false local function inside(pos) @@ -159,7 +160,33 @@ local function place_wagon(data) placed_trains_in_zone = WPT.get('placed_trains_in_zone') end - if placed_trains_in_zone.placed >= placed_trains_in_zone.limit then + if not data.new_zone then + data.new_zone = 1 + end + + if data.new_zone == zone_settings.size then + data.new_zone = 1 + end + + if data.current_zone == zone_settings.size then + local new_zone = placed_trains_in_zone.zones[data.new_zone] + if new_zone then + new_zone.placed = 0 + new_zone.positions = {} + data.new_zone = data.new_zone + 1 + end + end + + local zone = placed_trains_in_zone.zones[data.current_zone] + if not zone then + placed_trains_in_zone.zones[data.current_zone] = { + placed = 0, + positions = {} + } + zone = placed_trains_in_zone.zones[data.current_zone] + end + + if zone.placed >= placed_trains_in_zone.limit then return end @@ -182,7 +209,7 @@ local function place_wagon(data) right_bottom = {x = position.x + radius, y = position.y + radius} } - if is_position_near(area, placed_trains_in_zone.positions) then + if is_position_near(area, zone.positions) then return end @@ -217,8 +244,9 @@ local function place_wagon(data) force = 'player', callback = wagon_mineable } - placed_trains_in_zone.placed = placed_trains_in_zone.placed + 1 - placed_trains_in_zone.positions[#placed_trains_in_zone.positions + 1] = position + + zone.placed = zone.placed + 1 + zone.positions[#zone.positions + 1] = position return true end @@ -313,8 +341,8 @@ local function wall(p, data) callback = stone_wall } if not alert_zone_1 then - local x_min = -WPT.level_width / 2 - local x_max = WPT.level_width / 2 + local x_min = -zone_settings.zone_width / 2 + local x_max = zone_settings.zone_width / 2 WPT.set('zone1_beam1', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})) WPT.set('zone1_beam2', surface.create_entity({name = 'electric-beam', position = {x_min, p.y}, source = {x_min, p.y}, target = {x_max, p.y}})) WPT.set('alert_zone_1', true) @@ -393,36 +421,36 @@ local function wall(p, data) end if random(1, 25) == 1 then - if abs(p.y) < Public.level_depth * 1.5 then + if abs(p.y) < zone_settings.zone_depth * 1.5 then if random(1, 16) == 1 then spawn_turret(entities, p, 1) else spawn_turret(entities, p, 2) end - elseif abs(p.y) < Public.level_depth * 2.5 then + elseif abs(p.y) < zone_settings.zone_depth * 2.5 then if random(1, 8) == 1 then spawn_turret(entities, p, 3) end - elseif abs(p.y) < Public.level_depth * 3.5 then + elseif abs(p.y) < zone_settings.zone_depth * 3.5 then if random(1, 4) == 1 then spawn_turret(entities, p, 4) else spawn_turret(entities, p, 3) end - elseif abs(p.y) < Public.level_depth * 4.5 then + elseif abs(p.y) < zone_settings.zone_depth * 4.5 then if random(1, 4) == 1 then spawn_turret(entities, p, 4) else spawn_turret(entities, p, 5) end - elseif abs(p.y) < Public.level_depth * 5.5 then + elseif abs(p.y) < zone_settings.zone_depth * 5.5 then if random(1, 4) == 1 then spawn_turret(entities, p, 4) elseif random(1, 2) == 1 then spawn_turret(entities, p, 5) end end - elseif abs(p.y) > Public.level_depth * 5.5 then + elseif abs(p.y) > zone_settings.zone_depth * 5.5 then if random(1, 15) == 1 then spawn_turret(entities, p, random(3, enable_arties)) end @@ -430,7 +458,7 @@ local function wall(p, data) end end -local function process_level_14_position(x, y, data) +local function generate_zone_14(x, y, data) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -445,7 +473,7 @@ local function process_level_14_position(x, y, data) --Resource Spots if smol_areas < -0.71 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -510,7 +538,7 @@ local function process_level_14_position(x, y, data) tiles[#tiles + 1] = {name = 'water-shallow', position = p} end -local function process_level_13_position(x, y, data) +local function generate_zone_13(x, y, data) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -525,7 +553,7 @@ local function process_level_13_position(x, y, data) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -590,7 +618,7 @@ local function process_level_13_position(x, y, data) tiles[#tiles + 1] = {name = 'water-shallow', position = p} end -local function process_level_12_position(x, y, data, void_or_lab) +local function generate_zone_12(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -606,7 +634,7 @@ local function process_level_12_position(x, y, data, void_or_lab) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -676,7 +704,7 @@ local function process_level_12_position(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = 'tutorial-grid', position = p} end -local function process_level_11_position(x, y, data) +local function generate_zone_11(x, y, data) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -700,7 +728,7 @@ local function process_level_11_position(x, y, data) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -772,7 +800,7 @@ local function process_level_11_position(x, y, data) end end -local function process_level_10_position(x, y, data) +local function generate_zone_10(x, y, data) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -798,7 +826,7 @@ local function process_level_10_position(x, y, data) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -886,7 +914,7 @@ local function process_level_10_position(x, y, data) tiles[#tiles + 1] = {name = 'grass-2', position = p} end -local function process_level_9_position(x, y, data) +local function generate_zone_9(x, y, data) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -940,7 +968,7 @@ local function process_level_9_position(x, y, data) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -959,13 +987,143 @@ local function process_level_9_position(x, y, data) end --SCRAPYARD -local function process_scrap_zone_1(x, y, data, void_or_lab) +local function process_zone_scrap_2(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles local entities = data.entities local buildings = data.buildings local treasure = data.treasure + data.scrap_zone = true + + local scrapyard_modified = get_perlin('scrapyard_modified', p, seed) + local cave_rivers = get_perlin('cave_rivers', p, seed + 65030) + + --Chasms + local noise_cave_ponds = get_perlin('cave_ponds', p, seed) + local small_caves = get_perlin('small_caves', p, seed) + if noise_cave_ponds < 0.15 and noise_cave_ponds > -0.15 then + if small_caves > 0.35 then + tiles[#tiles + 1] = {name = void_or_lab, position = p} + return + end + + if small_caves < -0.35 then + tiles[#tiles + 1] = {name = void_or_lab, position = p} + return + end + end + + if scrapyard_modified < -0.25 or scrapyard_modified > 0.25 then + if random(1, 256) == 1 then + if random(1, 8) == 1 then + spawn_turret(entities, p, 3) + else + spawn_turret(entities, p, 4) + end + if random(1, 2048) == 1 then + treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'} + end + end + tiles[#tiles + 1] = {name = 'dirt-7', position = p} + if scrapyard_modified < -0.55 or scrapyard_modified > 0.55 then + if random(1, 2) == 1 then + entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p} + end + return + end + if scrapyard_modified < -0.28 or scrapyard_modified > 0.28 then + local success = place_wagon(data) + if success then + return + end + if random(1, 128) == 1 then + Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) + entities[#entities + 1] = { + name = Biters.wave_defense_roll_worm_name(), + position = p, + force = 'enemy', + note = true + } + end + if random(1, 96) == 1 then + entities[#entities + 1] = { + name = scrap_entities[random(1, scrap_entities_index)], + position = p, + force = 'enemy' + } + end + if random(1, 96) == 1 then + entities[#entities + 1] = { + name = scrap_entities_friendly[random(1, scrap_entities_friendly_index)], + position = p, + force = 'neutral' + } + end + + local scrap_mineable_entities, scrap_mineable_entities_index = get_scrap_mineable_entities() + + if random(1, 5) > 1 then + entities[#entities + 1] = {name = scrap_mineable_entities[random(1, scrap_mineable_entities_index)], position = p, force = 'neutral'} + end + + if random(1, 256) == 1 then + entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'} + end + return + end + return + end + + local cave_ponds = get_perlin('cave_ponds', p, seed) + if cave_ponds < -0.6 and scrapyard_modified > -0.2 and scrapyard_modified < 0.2 then + tiles[#tiles + 1] = {name = 'deepwater-green', position = p} + if random(1, 128) == 1 then + entities[#entities + 1] = {name = 'fish', position = p} + end + return + end + + --Resource Spots + if cave_rivers < -0.72 then + if random(1, 32) == 1 then + Generate_resources(buildings, p, zone_settings.zone_depth) + end + end + + local large_caves = get_perlin('large_caves', p, seed) + if scrapyard_modified > -0.15 and scrapyard_modified < 0.15 then + if floor(large_caves * 10) % 4 < 3 then + tiles[#tiles + 1] = {name = 'dirt-7', position = p} + if random(1, 2) == 1 then + entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p} + end + if random(1, 2048) == 1 then + treasure[#treasure + 1] = {position = p, chest = 'wooden-chest'} + end + return + end + end + + if random(1, 64) == 1 and cave_ponds > 0.6 then + entities[#entities + 1] = {name = 'crude-oil', position = p, amount = get_oil_amount(p)} + end + + tiles[#tiles + 1] = {name = 'nuclear-ground', position = p} + if random(1, 256) == 1 then + entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'} + end +end + +--SCRAPYARD +local function process_zone_scrap_1(x, y, data, void_or_lab) + local p = {x = x, y = y} + local seed = data.seed + local tiles = data.tiles + local entities = data.entities + local buildings = data.buildings + local treasure = data.treasure + data.scrap_zone = true local scrapyard = get_perlin('scrapyard', p, seed) local smol_areas = get_perlin('smol_areas', p, seed + 35000) @@ -1028,7 +1186,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab) entities[#entities + 1] = { name = scrap_entities_friendly[random(1, scrap_entities_friendly_index)], position = p, - force = 'player' + force = 'neutral' } end @@ -1058,7 +1216,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -1086,7 +1244,7 @@ local function process_scrap_zone_1(x, y, data, void_or_lab) end end -local function process_level_7_position(x, y, data, void_or_lab) +local function generate_zone_7(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1190,7 +1348,7 @@ local function process_level_7_position(x, y, data, void_or_lab) --Resource Spots if smol_areas < -0.72 then if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end end @@ -1203,7 +1361,7 @@ local function process_level_7_position(x, y, data, void_or_lab) end end -local function process_forest_zone_2(x, y, data, void_or_lab) +local function generate_zone_forest_2(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1211,6 +1369,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab) local buildings = data.buildings local markets = data.markets local treasure = data.treasure + data.forest_zone = true local large_caves = get_perlin('large_caves', p, seed) local cave_rivers = get_perlin('cave_rivers', p, seed) @@ -1243,7 +1402,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -1338,7 +1497,7 @@ local function process_forest_zone_2(x, y, data, void_or_lab) end end -local function process_level_5_position(x, y, data, void_or_lab) +local function generate_zone_5(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1385,7 +1544,7 @@ local function process_level_5_position(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -1430,7 +1589,7 @@ local function process_level_5_position(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = void_or_lab, position = p} end -local function process_level_4_position(x, y, data, void_or_lab) +local function generate_zone_4(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1521,7 +1680,7 @@ local function process_level_4_position(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -1561,7 +1720,7 @@ local function process_level_4_position(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = void_or_lab, position = p} end -local function process_level_3_position(x, y, data, void_or_lab) +local function generate_zone_3(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1581,7 +1740,7 @@ local function process_level_3_position(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -1727,7 +1886,7 @@ local function process_level_3_position(x, y, data, void_or_lab) end end -local function process_level_2_position(x, y, data, void_or_lab) +local function generate_zone_2(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1744,7 +1903,7 @@ local function process_level_2_position(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -1871,7 +2030,7 @@ local function process_level_2_position(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = void_or_lab, position = p} end -local function process_forest_zone_1(x, y, data, void_or_lab) +local function generate_zone_forest_1(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local buildings = data.buildings @@ -1879,6 +2038,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab) local entities = data.entities local markets = data.markets local treasure = data.treasure + data.forest_zone = true local small_caves = get_perlin('dungeons', p, seed + 33322) local noise_cave_ponds = get_perlin('cave_ponds', p, seed) @@ -1888,7 +2048,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -2054,7 +2214,7 @@ local function process_forest_zone_1(x, y, data, void_or_lab) end end -local function process_level_1_position(x, y, data, void_or_lab) +local function generate_zone_1(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local buildings = data.buildings @@ -2070,7 +2230,7 @@ local function process_level_1_position(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then tiles[#tiles + 1] = {name = 'deepwater-green', position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 32) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -2218,7 +2378,7 @@ local function process_level_1_position(x, y, data, void_or_lab) end end -local function process_level_0_position(x, y, data, void_or_lab) +local function starting_zone(x, y, data, void_or_lab) local p = {x = x, y = y} local seed = data.seed local buildings = data.buildings @@ -2237,7 +2397,7 @@ local function process_level_0_position(x, y, data, void_or_lab) if smol_areas < 0.055 and smol_areas > -0.025 then entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p} if random(1, 32) == 1 then - Generate_resources(buildings, p, Public.level_depth) + Generate_resources(buildings, p, zone_settings.zone_depth) end if random(1, 128) == 1 then Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier) @@ -2356,31 +2516,88 @@ local function process_level_0_position(x, y, data, void_or_lab) end end -Public.levels = { - process_level_0_position, - process_level_1_position, - process_forest_zone_1, -- zone 3 - process_level_3_position, - process_level_5_position, - process_scrap_zone_1, -- zone 6 - process_level_9_position, - process_level_4_position, - process_level_2_position, - process_level_3_position, - process_forest_zone_2, -- zone 11 - process_level_4_position, - process_level_5_position, - process_forest_zone_2, -- zone 14 - process_level_7_position, - process_scrap_zone_1, -- zone 16 - process_level_9_position, - process_level_10_position, - process_level_11_position, - process_level_12_position, - process_level_13_position, - process_level_14_position +local zones = { + generate_zone_1, + generate_zone_forest_1, + generate_zone_3, + generate_zone_5, + generate_zone_11, + generate_zone_forest_2, + process_zone_scrap_1, + process_zone_scrap_2, + generate_zone_9, + generate_zone_4, + process_zone_scrap_1, + generate_zone_2, + generate_zone_3, + process_zone_scrap_2, + generate_zone_3, + generate_zone_forest_2, + generate_zone_4, + generate_zone_forest_1, + generate_zone_forest_2, + generate_zone_2, + generate_zone_4, + process_zone_scrap_2, + generate_zone_5, + generate_zone_1, + generate_zone_forest_2, + generate_zone_7, + process_zone_scrap_1, + generate_zone_9, + generate_zone_10, + generate_zone_11, + generate_zone_12, + generate_zone_forest_2, + process_zone_scrap_2, + process_zone_scrap_1, + generate_zone_11, + generate_zone_12, + process_zone_scrap_1, + generate_zone_13, + generate_zone_14, + process_zone_scrap_1, + generate_zone_forest_1, + generate_zone_14, + process_zone_scrap_2 } +--[[ local zones_non_raffled = { + generate_zone_1, + generate_zone_2, + generate_zone_3, + generate_zone_4, + generate_zone_5, + generate_zone_forest_1, + generate_zone_forest_2, + process_zone_scrap_1, + process_zone_scrap_2, + generate_zone_7, + generate_zone_9, + generate_zone_11, + generate_zone_10, + generate_zone_11, + generate_zone_12, + generate_zone_13, + generate_zone_14 +} ]] + +zone_settings.size = #zones + +local function shuffle_terrains(new_zone) + local adjusted_zones = WPT.get('adjusted_zones') + + if not adjusted_zones.shuffled_terrains then + shuffle(zones) + adjusted_zones.shuffled_terrains = new_zone + end + + -- if adjusted_zones.shuffled_terrains and adjusted_zones.shuffled_terrains ~= new_zone then + -- table.shuffle_table(zones) + -- adjusted_zones.shuffled_terrains = new_zone + -- end +end + local function is_out_of_map(p) if p.x < 480 and p.x >= -480 then return @@ -2389,12 +2606,30 @@ local function is_out_of_map(p) end local function process_bits(p, data) - local levels = Public.levels local left_top_y = data.area.left_top.y - local index = floor((abs(left_top_y / Public.level_depth)) % 22) + 1 - local process_level = levels[index] - if not process_level then - process_level = levels[#levels] + local index = floor((abs(left_top_y / zone_settings.zone_depth)) % zone_settings.size) + 1 + shuffle_terrains(index) + + local generate_zone + if left_top_y >= -zone_settings.zone_depth then + generate_zone = starting_zone + else + generate_zone = zones[index] + if not generate_zone then + generate_zone = zones[zone_settings.size] + end + end + + data.current_zone = index + + local adjusted_zones = WPT.get('adjusted_zones') + + if data.forest_zone and not adjusted_zones.forest[index] then + adjusted_zones.forest[index] = true + end + + if data.scrap_zone and not adjusted_zones.scrap[index] then + adjusted_zones.scrap[index] = true end local void_or_tile = WPT.get('void_or_tile') @@ -2402,7 +2637,7 @@ local function process_bits(p, data) local x = p.x local y = p.y - process_level(x, y, data, void_or_tile) + generate_zone(x, y, data, void_or_tile) end local function border_chunk(p, data) @@ -2508,8 +2743,8 @@ function Public.heavy_functions(data) return end - if top_y % Public.level_depth == 0 and top_y < 0 then - WPT.set().left_top = data.left_top + if top_y % zone_settings.zone_depth == 0 and top_y < 0 then + WPT.set('left_top', data.left_top) return wall(p, data) end From 4ce23426297ac4860e3bb18e929fcb1ba20c2bcb Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:10:40 +0200 Subject: [PATCH 10/24] rpg - revert inventory bonus --- modules/rpg/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rpg/functions.lua b/modules/rpg/functions.lua index 6d98a923..4f644ea8 100644 --- a/modules/rpg/functions.lua +++ b/modules/rpg/functions.lua @@ -519,7 +519,7 @@ function Public.update_player_stats(player) local rpg_extra = Public.get('rpg_extra') local rpg_t = Public.get_value_from_player(player.index) local strength = rpg_t.strength - 10 - P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.1, 3)) + P.update_single_modifier(player, 'character_inventory_slots_bonus', 'rpg', round(strength * 0.2, 3)) P.update_single_modifier(player, 'character_mining_speed_modifier', 'rpg', round(strength * 0.006, 3)) P.update_single_modifier(player, 'character_maximum_following_robot_count_bonus', 'rpg', round(strength / 2 * 0.03, 3)) From 38415cead945b3ce7602ca1b060e6afcacc4f7af Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:11:03 +0200 Subject: [PATCH 11/24] player modifiers - limit rpg inventory --- utils/player_modifiers.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/player_modifiers.lua b/utils/player_modifiers.lua index 1091dd44..c2ac34d5 100644 --- a/utils/player_modifiers.lua +++ b/utils/player_modifiers.lua @@ -8,7 +8,8 @@ local round = math.round local this = { modifiers = {}, - disabled_modifier = {} + disabled_modifier = {}, + rpg_inventory_slot_limit = 320 -- huge inventory lags the server, this fixes it } Global.register( @@ -74,7 +75,7 @@ function Public.update_player_modifiers(player) if disabled_modifiers and disabled_modifiers[k] then player[modifier] = 0 else - player[modifier] = round(sum_value, 8) + player[modifier] = round(sum_value, 4) end end end @@ -92,9 +93,13 @@ function Public.update_single_modifier(player, modifier, category, value) if modifiers[k] == modifier and player_modifiers[k] then if category then if not player_modifiers[k][category] then - player_modifiers[k][category] = {} + player_modifiers[k][category] = 0 end player_modifiers[k][category] = value + + if category == 'rpg' and modifiers[k] == 'character_inventory_slots_bonus' and player_modifiers[k][category] >= this.rpg_inventory_slot_limit then + player_modifiers[k][category] = this.rpg_inventory_slot_limit - player.force.character_inventory_slots_bonus + end else player_modifiers[k] = value end From 98d29e73da1da684a8b4f1db29cfab005c434be6 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:11:18 +0200 Subject: [PATCH 12/24] mtn v3 - fixes --- locale/en/mtn_fortress_v3.cfg | 2 +- maps/mountain_fortress_v3/breached_wall.lua | 6 +- maps/mountain_fortress_v3/functions.lua | 18 +- maps/mountain_fortress_v3/locomotive.lua | 4 +- .../locomotive/market.lua | 2 + .../locomotive/spawn_locomotive.lua | 1 + maps/mountain_fortress_v3/main.lua | 26 ++- maps/mountain_fortress_v3/mining.lua | 2 +- maps/mountain_fortress_v3/mystical_chest.lua | 45 ---- maps/mountain_fortress_v3/table.lua | 14 +- maps/mountain_fortress_v3/terrain.lua | 205 ++++++++---------- 11 files changed, 140 insertions(+), 185 deletions(-) diff --git a/locale/en/mtn_fortress_v3.cfg b/locale/en/mtn_fortress_v3.cfg index 07a960cf..bdf6a061 100644 --- a/locale/en/mtn_fortress_v3.cfg +++ b/locale/en/mtn_fortress_v3.cfg @@ -1,7 +1,7 @@ [mountain_fortress_v3] map_info_main_caption=M O U N T A I N F O R T R E S S V3 map_info_sub_caption= ~~ diggy diggy choo choo ~~ -map_info_text=[color=red]READ THIS!\nIf there are any code bugs or desyncs. Please report asap to @Gerkiz!\nIf there are any game breaking bugs then this map might be shutdown to hot-fix the issue.[/color]\n\nThe biters have caught the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research will overhaul your mining equipment, increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause rocks to fall down the mountain, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nEnter the cargo wagon to reveal the wagon surface!\n\nRandom buildings that generate resources can be found throughout the world.\n\nPlacing steel-chests near cargo-wagons enables you to quickly move content.\n\nStaying inside the locomotive aura prevents biters from spawning when mining entities.\n\nRPG GUI is disabled inside the locomotive.\nDisconnecting wagons is disabled.\nYou can't cancel crafting when standing inside the locomotive aura.\n\nDon't try to run north with your Spidertron if the train is not near you.\nYou have been warned.\n\nMining drills have great mining-bonus which also is increased after each research, use them when you can!\n\nThe mystical chest in the locomotive offers some rewards.\nOne must feed the chest to receive such rewards.\n\nGood luck on your journey! +map_info_text=[color=red]READ THIS!\nIf there are any code bugs or desyncs. Please report asap to @Gerkiz!\nIf there are any game breaking bugs then this map might be shutdown to hot-fix the issue.[/color]\n\nThe biters have caught the scent of fish in the cargo wagon.\nGuide the choo into the mountain and protect it as long as possible!\nThis however will not be an easy task,\nsince their strength and numbers increase over time.\n\nIn additon, the southern grounds collapse over time.\n\nDelve deep for greater treasures, but also face increased dangers.\nMining productivity research will overhaul your mining equipment, increasing the size of your backpack.\n\nAs you dig, you will encounter impassable dark chasms or rivers.\nArtillery will try to shoot you down! Dig fast, dig north!\n\nSome explosives may cause rocks to fall down the mountain, filling the void, creating new ways.\nAll they need is a container and a well aimed shot.\n\nEnter the cargo wagon to reveal the wagon surface!\n\nRandom buildings that generate resources can be found throughout the world.\n\nPlacing steel-chests near cargo-wagons enables you to quickly move content.\n\nStaying inside the locomotive aura prevents biters from spawning when mining entities.\n\nRadars do not generate new areas.\n\nRPG GUI is disabled inside the locomotive.\n\nDisconnecting wagons is disabled.\nYou can't cancel crafting when standing inside the locomotive aura.\n\nDon't try to run north with your Spidertron if the train is not near you.\nYou have been warned.\n\nMining drills have great mining-bonus which also is increased after each research, use them when you can!\n\nThe mystical chest in the locomotive offers some rewards.\nOne must feed the chest to receive such rewards.\n\nGood luck on your journey! [breached_wall] collapse_start=[color=blue]Mapkeeper:[/color]\nWarning, Collapse has begun! diff --git a/maps/mountain_fortress_v3/breached_wall.lua b/maps/mountain_fortress_v3/breached_wall.lua index 27472fb1..0e39d38e 100644 --- a/maps/mountain_fortress_v3/breached_wall.lua +++ b/maps/mountain_fortress_v3/breached_wall.lua @@ -125,8 +125,12 @@ end local compare_player_pos = function(player) local p = player.position local index = player.index - local zone = floor((abs(p.y / zone_settings.zone_depth)) % zone_settings.size) + 1 local adjusted_zones = WPT.get('adjusted_zones') + if not adjusted_zones.size then + return + end + + local zone = floor((abs(p.y / zone_settings.zone_depth)) % adjusted_zones.size) + 1 if adjusted_zones.scrap[zone] then RPG.set_value_to_player(index, 'scrap_zone', true) diff --git a/maps/mountain_fortress_v3/functions.lua b/maps/mountain_fortress_v3/functions.lua index e75e1283..caa70565 100644 --- a/maps/mountain_fortress_v3/functions.lua +++ b/maps/mountain_fortress_v3/functions.lua @@ -13,6 +13,7 @@ local Difficulty = require 'modules.difficulty_vote_by_amount' local ICW_Func = require 'maps.mountain_fortress_v3.icw.functions' local math2d = require 'math2d' local Misc = require 'utils.commands.misc' +local Core = require 'utils.core' local zone_settings = WPT.zone_settings local this = { @@ -159,7 +160,7 @@ local function do_magic_crafters() local index = magic_crafters.index - for i = 1, magic_crafters_per_tick do + for _ = 1, magic_crafters_per_tick do if index > limit then index = 1 end @@ -211,7 +212,7 @@ local function do_magic_fluid_crafters() local index = magic_fluid_crafters.index - for i = 1, magic_fluid_crafters_per_tick do + for _ = 1, magic_fluid_crafters_per_tick do if index > limit then index = 1 end @@ -430,7 +431,7 @@ Public.disable_minable_and_ICW_callback = function(entity) if entity and entity.valid then entity.minable = false - ICW.register_wagon(entity, true) + ICW.register_wagon(entity) end end ) @@ -791,12 +792,13 @@ local function calc_players() return #players end local total = 0 - for i = 1, #players do - local player = players[i] - if player.afk_time < 36000 then - total = total + 1 + Core.iter_connected_players( + function(player) + if player.afk_time < 36000 then + total = total + 1 + end end - end + ) if total <= 0 then total = #players end diff --git a/maps/mountain_fortress_v3/locomotive.lua b/maps/mountain_fortress_v3/locomotive.lua index c7545bf9..a147d7aa 100644 --- a/maps/mountain_fortress_v3/locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive.lua @@ -85,7 +85,7 @@ local function validate_player(player) return true end -local function property_boost(data) +local function give_passive_xp(data) local xp_floating_text_color = {r = 188, g = 201, b = 63} local visuals_delay = 1800 local loco_surface = WPT.get('loco_surface') @@ -430,7 +430,7 @@ function Public.boost_players_around_train() locomotive_surface = locomotive_surface, rpg = rpg } - property_boost(data) + give_passive_xp(data) end function Public.is_around_train(entity) diff --git a/maps/mountain_fortress_v3/locomotive/market.lua b/maps/mountain_fortress_v3/locomotive/market.lua index 3fcecdd1..9374664f 100644 --- a/maps/mountain_fortress_v3/locomotive/market.lua +++ b/maps/mountain_fortress_v3/locomotive/market.lua @@ -553,6 +553,7 @@ local function redraw_market_items(gui, player, search_text) frame.add( { type = 'sprite-button', + ---@diagnostic disable-next-line: ambiguity-1 sprite = data.sprite or 'item/' .. item, number = item_count, name = item, @@ -611,6 +612,7 @@ local function redraw_market_items(gui, player, search_text) frame.add( { type = 'sprite-button', + ---@diagnostic disable-next-line: ambiguity-1 sprite = data.sprite or 'item/' .. item, number = item_count, name = item, diff --git a/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua b/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua index 04a05019..e6042d7d 100644 --- a/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua +++ b/maps/mountain_fortress_v3/locomotive/spawn_locomotive.lua @@ -72,6 +72,7 @@ local set_loco_tiles = local p = {} + ---@diagnostic disable-next-line: count-down-loop for x = position.x - 5, 1, 3 do for y = 1, position.y + 5, 2 do if random(1, 4) == 1 then diff --git a/maps/mountain_fortress_v3/main.lua b/maps/mountain_fortress_v3/main.lua index a2db0647..e6461ba7 100644 --- a/maps/mountain_fortress_v3/main.lua +++ b/maps/mountain_fortress_v3/main.lua @@ -313,7 +313,8 @@ end local is_player_valid = function() local players = game.connected_players - for _, player in pairs(players) do + for i = 1, #players do + local player = players[i] if player.connected and player.controller_type == 2 then player.set_controller {type = defines.controllers.god} player.create_character() @@ -467,9 +468,11 @@ end local on_tick = function() local update_gui = Gui_mf.update_gui local tick = game.tick + local players = game.connected_players if tick % 40 == 0 then - for _, player in pairs(game.connected_players) do + for i = 1, #players do + local player = players[i] update_gui(player) end lock_locomotive_positions() @@ -537,5 +540,24 @@ end Event.on_nth_tick(10, on_tick) Event.on_init(on_init) Event.add(WPT.events.reset_map, Public.reset_map) +Event.add( + defines.events.on_sector_scanned, + function(event) + local radar = event.radar + if not radar or not radar.valid then + return + end + + local radars_reveal_new_chunks = WPT.get('radars_reveal_new_chunks') + if radars_reveal_new_chunks then + return + end + + local pos = event.chunk_position + + radar.force.cancel_charting(radar.surface.index) + radar.force.unchart_chunk(pos, radar.surface.index) + end +) return Public diff --git a/maps/mountain_fortress_v3/mining.lua b/maps/mountain_fortress_v3/mining.lua index 1ca8f2a7..4c360eb2 100644 --- a/maps/mountain_fortress_v3/mining.lua +++ b/maps/mountain_fortress_v3/mining.lua @@ -177,7 +177,7 @@ local function create_particles(surface, name, position, amount, cause_position) d2 = (cause_position.y - position.y) * 0.025 end - for i = 1, amount, 1 do + for _ = 1, amount, 1 do local m = random(4, 10) local m2 = m * 0.005 diff --git a/maps/mountain_fortress_v3/mystical_chest.lua b/maps/mountain_fortress_v3/mystical_chest.lua index 7507b535..1920e536 100644 --- a/maps/mountain_fortress_v3/mystical_chest.lua +++ b/maps/mountain_fortress_v3/mystical_chest.lua @@ -1,7 +1,6 @@ local Color = require 'utils.color_presets' local Event = require 'utils.event' local WPT = require 'maps.mountain_fortress_v3.table' -local WD = require 'modules.wave_defense.table' local RPG = require 'modules.rpg.main' local Alert = require 'utils.alert' local Task = require 'utils.task' @@ -265,17 +264,6 @@ local function roll_item_stacks(remaining_budget, max_slots, blacklist) return item_stack_set, item_stack_set_worth end -local pause_wd_token = - Token.register( - function() - WD.pause(false) - local mc_rewards = WPT.get('mc_rewards') - mc_rewards.temp_boosts.wave_defense = nil - local message = ({'locomotive.wd_resumed'}) - Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac') - end -) - local restore_mining_speed_token = Token.register( function() @@ -379,19 +367,6 @@ local mc_random_rewards = { end), 512 }, - { - name = 'Inventory Bonus', - color = {r = 0.00, g = 0.00, b = 0.25}, - tooltip = 'Selecting this will grant the team permanent inventory bonus!', - func = (function(player) - local force = game.forces.player - force.character_inventory_slots_bonus = force.character_inventory_slots_bonus + 1 - local message = ({'locomotive.inventory_bonus', player.name}) - Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac') - return true - end), - 512 - }, { name = 'Heal Locomotive', color = {r = 0.00, g = 0.00, b = 0.25}, @@ -404,26 +379,6 @@ local mc_random_rewards = { return true end), 256 - }, - { - name = 'Wave Defense', - str = 'wave_defense', - color = {r = 0.35, g = 0.00, b = 0.00}, - tooltip = 'Selecting this will pause the wave defense for 5 minutes. Ideal if you want to take a break!', - func = (function(player) - local mc_rewards = WPT.get('mc_rewards') - if mc_rewards.temp_boosts.wave_defense then - return false, '[Rewards] Wave Defense break is already applied. Please choose another reward.' - end - mc_rewards.temp_boosts.wave_defense = true - - WD.pause(true) - Task.set_timeout_in_ticks(18000, pause_wd_token) - local message = ({'locomotive.wd_paused', player.name}) - Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac') - return true - end), - 64 } } diff --git a/maps/mountain_fortress_v3/table.lua b/maps/mountain_fortress_v3/table.lua index 5a01fd81..29687451 100644 --- a/maps/mountain_fortress_v3/table.lua +++ b/maps/mountain_fortress_v3/table.lua @@ -19,8 +19,7 @@ Global.register( Public.zone_settings = { zone_depth = 704, - zone_width = 510, - size = nil + zone_width = 510 } Public.pickaxe_upgrades = { @@ -230,9 +229,12 @@ function Public.reset_table() } this.adjusted_zones = { scrap = {}, - forest = {} + forest = {}, + size = nil, + shuffled_zones = nil } this.alert_zone_1 = false -- alert the players + this.radars_reveal_new_chunks = false -- allows for the player to explore the map instead for k, _ in pairs(this.players) do this.players[k] = {} @@ -270,10 +272,6 @@ function Public.remove(key, sub_key) end end -local on_init = function() - Public.reset_table() -end - -Event.on_init(on_init) +Event.on_init(Public.reset_table) return Public diff --git a/maps/mountain_fortress_v3/terrain.lua b/maps/mountain_fortress_v3/terrain.lua index a810c496..c2bb0fc6 100644 --- a/maps/mountain_fortress_v3/terrain.lua +++ b/maps/mountain_fortress_v3/terrain.lua @@ -144,7 +144,7 @@ local function is_position_near(area, table_to_check) end for i = 1, #table_to_check do - if inside(table_to_check[i], area) then + if inside(table_to_check[i]) then status = true end end @@ -152,7 +152,7 @@ local function is_position_near(area, table_to_check) return status end -local function place_wagon(data) +local function place_wagon(data, adjusted_zones) local placed_trains_in_zone = WPT.get('placed_trains_in_zone') if not placed_trains_in_zone.randomized then placed_trains_in_zone.limit = random(1, 2) @@ -164,11 +164,11 @@ local function place_wagon(data) data.new_zone = 1 end - if data.new_zone == zone_settings.size then + if data.new_zone == adjusted_zones.size then data.new_zone = 1 end - if data.current_zone == zone_settings.size then + if data.current_zone == adjusted_zones.size then local new_zone = placed_trains_in_zone.zones[data.new_zone] if new_zone then new_zone.placed = 0 @@ -215,6 +215,7 @@ local function place_wagon(data) local location local direction + local r1 = random(2, 4) * 2 local r2 = random(2, 4) * 2 @@ -226,7 +227,7 @@ local function place_wagon(data) direction = 2 end - for k, tile in pairs(location) do + for _, tile in pairs(location) do tiles[#tiles + 1] = {name = 'nuclear-ground', position = tile.position} if tile.position.y % 1 == 0 and tile.position.x % 1 == 0 then entities[#entities + 1] = { @@ -458,7 +459,7 @@ local function wall(p, data) end end -local function generate_zone_14(x, y, data) +local function zone_14(x, y, data, _, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -510,7 +511,7 @@ local function generate_zone_14(x, y, data) if small_caves > -0.41 and small_caves < 0.41 then if noise_cave_ponds > 0.35 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -538,7 +539,7 @@ local function generate_zone_14(x, y, data) tiles[#tiles + 1] = {name = 'water-shallow', position = p} end -local function generate_zone_13(x, y, data) +local function zone_13(x, y, data, _, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -590,7 +591,7 @@ local function generate_zone_13(x, y, data) if small_caves > -0.40 and small_caves < 0.40 then if noise_cave_ponds > 0.35 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -618,7 +619,7 @@ local function generate_zone_13(x, y, data) tiles[#tiles + 1] = {name = 'water-shallow', position = p} end -local function generate_zone_12(x, y, data, void_or_lab) +local function zone_12(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -653,7 +654,7 @@ local function generate_zone_12(x, y, data, void_or_lab) end if noise_1 < -0.72 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -704,7 +705,7 @@ local function generate_zone_12(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = 'tutorial-grid', position = p} end -local function generate_zone_11(x, y, data) +local function zone_11(x, y, data, _, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -767,7 +768,7 @@ local function generate_zone_11(x, y, data) } end - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -800,7 +801,7 @@ local function generate_zone_11(x, y, data) end end -local function generate_zone_10(x, y, data) +local function zone_10(x, y, data, _, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -844,7 +845,7 @@ local function generate_zone_10(x, y, data) return end if abs(scrapyard) > 0.25 and abs(scrapyard) < 0.40 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -914,7 +915,7 @@ local function generate_zone_10(x, y, data) tiles[#tiles + 1] = {name = 'grass-2', position = p} end -local function generate_zone_9(x, y, data) +local function zone_9(x, y, data, _, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -949,7 +950,7 @@ local function generate_zone_9(x, y, data) end if maze_noise > 0 and maze_noise < 0.45 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -987,7 +988,7 @@ local function generate_zone_9(x, y, data) end --SCRAPYARD -local function process_zone_scrap_2(x, y, data, void_or_lab) +local function zone_scrap_2(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1033,7 +1034,7 @@ local function process_zone_scrap_2(x, y, data, void_or_lab) return end if scrapyard_modified < -0.28 or scrapyard_modified > 0.28 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1116,7 +1117,7 @@ local function process_zone_scrap_2(x, y, data, void_or_lab) end --SCRAPYARD -local function process_zone_scrap_1(x, y, data, void_or_lab) +local function zone_scrap_1(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1162,7 +1163,7 @@ local function process_zone_scrap_1(x, y, data, void_or_lab) return end if scrapyard < -0.28 or scrapyard > 0.28 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1244,7 +1245,7 @@ local function process_zone_scrap_1(x, y, data, void_or_lab) end end -local function generate_zone_7(x, y, data, void_or_lab) +local function zone_7(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1304,7 +1305,7 @@ local function generate_zone_7(x, y, data, void_or_lab) if cave_rivers_4 > -0.20 and cave_rivers_4 < 0.20 then tiles[#tiles + 1] = {name = 'grass-' .. floor(cave_rivers_4 * 32) % 3 + 1, position = p} if cave_rivers_4 > -0.10 and cave_rivers_4 < 0.10 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1361,7 +1362,7 @@ local function generate_zone_7(x, y, data, void_or_lab) end end -local function generate_zone_forest_2(x, y, data, void_or_lab) +local function zone_forest_2(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1418,7 +1419,7 @@ local function generate_zone_forest_2(x, y, data, void_or_lab) end local noise_forest_location = get_perlin('forest_location', p, seed) if cave_rivers > -0.1 and cave_rivers < 0.1 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1497,7 +1498,7 @@ local function generate_zone_forest_2(x, y, data, void_or_lab) end end -local function generate_zone_5(x, y, data, void_or_lab) +local function zone_5(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1561,7 +1562,7 @@ local function generate_zone_5(x, y, data, void_or_lab) if small_caves > -0.40 and small_caves < 0.40 then if noise_cave_ponds > 0.35 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1589,7 +1590,7 @@ local function generate_zone_5(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = void_or_lab, position = p} end -local function generate_zone_4(x, y, data, void_or_lab) +local function zone_4(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1632,7 +1633,7 @@ local function generate_zone_4(x, y, data, void_or_lab) note = true } end - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1720,7 +1721,7 @@ local function generate_zone_4(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = void_or_lab, position = p} end -local function generate_zone_3(x, y, data, void_or_lab) +local function zone_3(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -1857,7 +1858,7 @@ local function generate_zone_3(x, y, data, void_or_lab) --Main Rock Terrain local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 75000) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -1886,7 +1887,7 @@ local function generate_zone_3(x, y, data, void_or_lab) end end -local function generate_zone_2(x, y, data, void_or_lab) +local function zone_2(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local tiles = data.tiles @@ -2005,7 +2006,7 @@ local function generate_zone_2(x, y, data, void_or_lab) --Main Rock Terrain local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 75000) if no_rocks_2 > 0.80 or no_rocks_2 < -0.80 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -2030,7 +2031,7 @@ local function generate_zone_2(x, y, data, void_or_lab) tiles[#tiles + 1] = {name = void_or_lab, position = p} end -local function generate_zone_forest_1(x, y, data, void_or_lab) +local function zone_forest_1(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local buildings = data.buildings @@ -2149,7 +2150,7 @@ local function generate_zone_forest_1(x, y, data, void_or_lab) --Main Rock Terrain local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 5000) if no_rocks_2 > 0.64 or no_rocks_2 < -0.64 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -2214,7 +2215,7 @@ local function generate_zone_forest_1(x, y, data, void_or_lab) end end -local function generate_zone_1(x, y, data, void_or_lab) +local function zone_1(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local buildings = data.buildings @@ -2331,7 +2332,7 @@ local function generate_zone_1(x, y, data, void_or_lab) --Main Rock Terrain local no_rocks_2 = get_perlin('no_rocks_2', p, seed + 75000) if no_rocks_2 > 0.66 or no_rocks_2 < -0.66 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -2378,7 +2379,7 @@ local function generate_zone_1(x, y, data, void_or_lab) end end -local function starting_zone(x, y, data, void_or_lab) +local function starting_zone(x, y, data, void_or_lab, adjusted_zones) local p = {x = x, y = y} local seed = data.seed local buildings = data.buildings @@ -2492,7 +2493,7 @@ local function starting_zone(x, y, data, void_or_lab) --Main Rock Terrain if no_rocks_2 > 0.334 and no_rocks_2 < 0.544 then - local success = place_wagon(data) + local success = place_wagon(data, adjusted_zones) if success then return end @@ -2517,78 +2518,27 @@ local function starting_zone(x, y, data, void_or_lab) end local zones = { - generate_zone_1, - generate_zone_forest_1, - generate_zone_3, - generate_zone_5, - generate_zone_11, - generate_zone_forest_2, - process_zone_scrap_1, - process_zone_scrap_2, - generate_zone_9, - generate_zone_4, - process_zone_scrap_1, - generate_zone_2, - generate_zone_3, - process_zone_scrap_2, - generate_zone_3, - generate_zone_forest_2, - generate_zone_4, - generate_zone_forest_1, - generate_zone_forest_2, - generate_zone_2, - generate_zone_4, - process_zone_scrap_2, - generate_zone_5, - generate_zone_1, - generate_zone_forest_2, - generate_zone_7, - process_zone_scrap_1, - generate_zone_9, - generate_zone_10, - generate_zone_11, - generate_zone_12, - generate_zone_forest_2, - process_zone_scrap_2, - process_zone_scrap_1, - generate_zone_11, - generate_zone_12, - process_zone_scrap_1, - generate_zone_13, - generate_zone_14, - process_zone_scrap_1, - generate_zone_forest_1, - generate_zone_14, - process_zone_scrap_2 + ['zone_1'] = zone_1, + ['zone_2'] = zone_2, + ['zone_3'] = zone_3, + ['zone_4'] = zone_4, + ['zone_5'] = zone_5, + ['zone_forest_1'] = zone_forest_1, + ['zone_forest_2'] = zone_forest_2, + ['zone_scrap_1'] = zone_scrap_1, + ['zone_scrap_2'] = zone_scrap_2, + ['zone_7'] = zone_7, + ['zone_9'] = zone_9, + ['zone_10'] = zone_10, + ['zone_11'] = zone_11, + ['zone_12'] = zone_12, + ['zone_13'] = zone_13, + ['zone_14'] = zone_14 } ---[[ local zones_non_raffled = { - generate_zone_1, - generate_zone_2, - generate_zone_3, - generate_zone_4, - generate_zone_5, - generate_zone_forest_1, - generate_zone_forest_2, - process_zone_scrap_1, - process_zone_scrap_2, - generate_zone_7, - generate_zone_9, - generate_zone_11, - generate_zone_10, - generate_zone_11, - generate_zone_12, - generate_zone_13, - generate_zone_14 -} ]] - -zone_settings.size = #zones - -local function shuffle_terrains(new_zone) - local adjusted_zones = WPT.get('adjusted_zones') - +local function shuffle_terrains(adjusted_zones, new_zone) if not adjusted_zones.shuffled_terrains then - shuffle(zones) + shuffle(adjusted_zones.shuffled_zones) adjusted_zones.shuffled_terrains = new_zone end @@ -2605,25 +2555,43 @@ local function is_out_of_map(p) return true end -local function process_bits(p, data) +local function init_terrain(adjusted_zones) + if adjusted_zones.init_terrain then + return + end + + local count = 1 + local shuffled_zones = {} + + for zone_name, _ in pairs(zones) do + shuffled_zones[count] = zone_name + count = count + 1 + end + + adjusted_zones.size = count + adjusted_zones.shuffled_zones = shuffled_zones + adjusted_zones.init_terrain = true +end + +local function process_bits(p, data, adjusted_zones) local left_top_y = data.area.left_top.y - local index = floor((abs(left_top_y / zone_settings.zone_depth)) % zone_settings.size) + 1 - shuffle_terrains(index) + + local index = floor((abs(left_top_y / zone_settings.zone_depth)) % adjusted_zones.size) + 1 + + shuffle_terrains(adjusted_zones, index) local generate_zone if left_top_y >= -zone_settings.zone_depth then generate_zone = starting_zone else - generate_zone = zones[index] + generate_zone = zones[adjusted_zones.shuffled_zones[index]] if not generate_zone then - generate_zone = zones[zone_settings.size] + generate_zone = zones[adjusted_zones.shuffled_zones[adjusted_zones.size]] end end data.current_zone = index - local adjusted_zones = WPT.get('adjusted_zones') - if data.forest_zone and not adjusted_zones.forest[index] then adjusted_zones.forest[index] = true end @@ -2637,7 +2605,7 @@ local function process_bits(p, data) local x = p.x local y = p.y - generate_zone(x, y, data, void_or_tile) + generate_zone(x, y, data, void_or_tile, adjusted_zones) end local function border_chunk(p, data) @@ -2729,6 +2697,9 @@ function Public.heavy_functions(data) local p = data.position local get_tile = surface.get_tile(p) + local adjusted_zones = WPT.get('adjusted_zones') + init_terrain(adjusted_zones) + local map_name = 'mountain_fortress_v3' if string.sub(surface.name, 0, #map_name) ~= map_name then @@ -2749,7 +2720,7 @@ function Public.heavy_functions(data) end if top_y < 0 then - return process_bits(p, data) + return process_bits(p, data, adjusted_zones) end if top_y > 120 then From 5a6539b6db235aa3256bcbee8df11f54cdaaf946 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:11:26 +0200 Subject: [PATCH 13/24] fix gui issue --- modules/difficulty_vote_by_amount.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/difficulty_vote_by_amount.lua b/modules/difficulty_vote_by_amount.lua index 0b6714b1..c16684f8 100644 --- a/modules/difficulty_vote_by_amount.lua +++ b/modules/difficulty_vote_by_amount.lua @@ -333,7 +333,7 @@ Gui.on_click( end local player = event.player - if not player or not player.valid or not player.character then + if not player or not player.valid then return end @@ -373,13 +373,14 @@ Gui.on_click( return end local player = event.player - if not player or not player.valid or not player.character then + if not player or not player.valid then return end if game.tick > this.difficulty_poll_closing_timeout then clear_main_frame(player) return end + local screen = player.gui.center if screen[main_frame_name] and screen[main_frame_name].valid then clear_main_frame(player) @@ -397,7 +398,7 @@ Gui.on_click( return end local player = event.player - if not player or not player.valid or not player.character then + if not player or not player.valid then return end clear_main_frame(player) From 86ae1d5c9b774a6461e151e99134b21b2cf87f8f Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:11:57 +0200 Subject: [PATCH 14/24] fix lua tooltip warnings --- utils/antigrief.lua | 39 ++++++++++++++------------------------- utils/event.lua | 2 +- utils/gui.lua | 11 ++++++----- utils/table.lua | 1 + 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/utils/antigrief.lua b/utils/antigrief.lua index 4ffd8a66..3745a099 100644 --- a/utils/antigrief.lua +++ b/utils/antigrief.lua @@ -88,7 +88,7 @@ end -- Removes the first 100 entries of a table local function overflow(t) - for _=1,100,1 do + for _ = 1, 100, 1 do table.remove(t, 1) end end @@ -352,12 +352,7 @@ local function on_player_used_capsule(event) local prefix = '[Capsule]' msg = format(player.name .. ' damaged: %s with: %s', get_entities(name, entities), name) - local ban_msg = - format( - 'Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness', - get_entities(name, entities), - name - ) + local ban_msg = format('Damaged: %s with: %s. This action was performed automatically. Visit getcomfy.eu/discord for forgiveness', get_entities(name, entities), name) do_action(player, prefix, msg, ban_msg, true) else @@ -736,13 +731,7 @@ local function on_player_cancelled_crafting(event) player.character.die('player') - Utils.action_warning( - '[Crafting]', - player.name .. - ' canceled their craft of item ' .. - event.recipe.name .. - ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.' - ) + Utils.action_warning('[Crafting]', player.name .. ' canceled their craft of item ' .. event.recipe.name .. ' of total count ' .. crafting_queue_item_count .. ' in raw items (' .. crafted_items .. ' slots) but had no inventory left.') end if not this.cancel_crafting_history then @@ -865,9 +854,9 @@ local function on_permission_string_imported(event) end --- This is used for the RPG module, when casting capsules. ----@param player ----@param position ----@param msg +---@param player userdata +---@param position table +---@param msg string function Public.insert_into_capsule_history(player, position, msg) if not this.capsule_history then this.capsule_history = {} @@ -901,8 +890,8 @@ function Public.reset_tables() end --- Add entity type to the whitelist so it gets logged. ----@param key ----@param value +---@param key string +---@param value string function Public.whitelist_types(key, value) if key and value then this.whitelist_types[key] = value @@ -912,35 +901,35 @@ function Public.whitelist_types(key, value) end --- If the event should also check trusted players. ----@param value +---@param value string function Public.do_not_check_trusted(value) this.do_not_check_trusted = value or false return this.do_not_check_trusted end --- If ANY actions should be performed when a player misbehaves. ----@param value +---@param value string function Public.enable_capsule_warning(value) this.enable_capsule_warning = value or false return this.enable_capsule_warning end --- If ANY actions should be performed when a player misbehaves. ----@param value +---@param value string function Public.enable_capsule_cursor_warning(value) this.enable_capsule_cursor_warning = value or false return this.enable_capsule_cursor_warning end --- If the script should jail a person instead of kicking them ----@param value +---@param value string function Public.enable_jail(value) this.enable_jail = value or false return this.enable_jail end --- Defines what the threshold for amount of explosives in chest should be - logged or not. ----@param value +---@param value string function Public.explosive_threshold(value) if value then this.explosive_threshold = value @@ -950,7 +939,7 @@ function Public.explosive_threshold(value) end --- Defines what the threshold for amount of times before the script should take action. ----@param value +---@param value string function Public.damage_entity_threshold(value) if value then this.damage_entity_threshold = value diff --git a/utils/event.lua b/utils/event.lua index 7a20999c..0f9b4c95 100644 --- a/utils/event.lua +++ b/utils/event.lua @@ -477,7 +477,7 @@ function Event.remove_removable_nth_tick_function(tick, name) local handlers = on_nth_tick_event_handlers[tick] local f = function_nth_tick_table[name] - for k, v in pairs(function_nth_tick_table[name]) do + for _, v in pairs(function_nth_tick_table[name]) do local t = v.tick if t == tick then f = v.handler diff --git a/utils/gui.lua b/utils/gui.lua index 5a90aa1c..d6a0616b 100644 --- a/utils/gui.lua +++ b/utils/gui.lua @@ -298,6 +298,7 @@ local function custom_handler_factory(handlers) end --luacheck: ignore custom_raise +---@diagnostic disable-next-line: unused-function, unused-local local function custom_raise(handlers, element, player) local handler = handlers[element.name] if not handler then @@ -355,8 +356,8 @@ function Public.get_parent_frame(player) end --- This adds the given gui to the top gui. ----@param player ----@param frame +---@param player userdata +---@param frame userdata function Public.add_mod_button(player, frame) if Public.get_button_flow(player)[frame.name] and Public.get_button_flow(player)[frame.name].valid then return @@ -365,7 +366,7 @@ function Public.add_mod_button(player, frame) Public.get_button_flow(player).add(frame) end ----@param state +---@param state boolean --- If we should use the new mod gui or not function Public.set_mod_gui_top_frame(state) settings.mod_gui_top_frame = state or false @@ -377,7 +378,7 @@ function Public.get_mod_gui_top_frame() end --- This adds the given gui to the main gui. ----@param tbl +---@param tbl table function Public.add_tab_to_gui(tbl) if not tbl then return @@ -411,7 +412,7 @@ function Public.screen_to_bypass(elem) end --- Fetches the main gui tabs. You are forbidden to write as this is local. ----@param key +---@param key string function Public.get(key) if key then return main_gui_tabs[key] diff --git a/utils/table.lua b/utils/table.lua index 8d24b99b..70ce292b 100644 --- a/utils/table.lua +++ b/utils/table.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field --luacheck: globals table local Stats = require 'utils.stats' local random = math.random From 095895ed81d99cd180a81a9629345d9a6664ab2c Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:12:25 +0200 Subject: [PATCH 15/24] perlin - made it faster when using in loop --- utils/simplex_noise.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/utils/simplex_noise.lua b/utils/simplex_noise.lua index ec0b3715..833ea750 100644 --- a/utils/simplex_noise.lua +++ b/utils/simplex_noise.lua @@ -286,11 +286,6 @@ for i = 0, 511 do perm[i + 1] = p[bit32_band(i, 255) + 1] end --- special case of dot with 3 inputs -local function dot2(g, x, y) - return x * g[1] + y * g[2] -end - local F2 = 0.5 * (math.sqrt(3.0) - 1.0) local G2 = (3.0 - math.sqrt(3.0)) / 6.0 @@ -317,6 +312,7 @@ function Simplex.d2(xin, yin, seed) i1 = 0 j1 = 1 end + -- upper triangle, YX order: (0,0)->(0,1)->(1,1) -- A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and -- a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where @@ -339,7 +335,7 @@ function Simplex.d2(xin, yin, seed) n0 = 0.0 else t0 = t0 * t0 - n0 = t0 * t0 * dot2(grad3[gi0 + 1], x0, y0) -- (x,y) of grad3 used for 2D gradient + n0 = t0 * t0 * (x0 * grad3[gi0 + 1][1] + y0 * grad3[gi0 + 1][2]) -- (x,y) of grad3 used for 2D gradient end local t1 = 0.5 - x1 * x1 - y1 * y1 @@ -347,7 +343,7 @@ function Simplex.d2(xin, yin, seed) n1 = 0.0 else t1 = t1 * t1 - n1 = t1 * t1 * dot2(grad3[gi1 + 1], x1, y1) + n1 = t1 * t1 * (x1 * grad3[gi1 + 1][1] + y1 * grad3[gi1 + 1][2]) end local t2 = 0.5 - x2 * x2 - y2 * y2 @@ -355,7 +351,7 @@ function Simplex.d2(xin, yin, seed) n2 = 0.0 else t2 = t2 * t2 - n2 = t2 * t2 * dot2(grad3[gi2 + 1], x2, y2) + n2 = t2 * t2 * (x2 * grad3[gi2 + 1][1] + y2 * grad3[gi2 + 1][2]) end -- Add contributions from each corner to get the final noise value. From c048002b7d2769e7025a67e6e8e90566dc18801e Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:12:34 +0200 Subject: [PATCH 16/24] gui label fixes --- utils/gui/group.lua | 38 +++++++++++++------- utils/gui/player_list.lua | 6 +++- utils/gui/score.lua | 16 ++++----- utils/gui/server_select.lua | 72 +++++++++++++++++++------------------ 4 files changed, 75 insertions(+), 57 deletions(-) diff --git a/utils/gui/group.lua b/utils/gui/group.lua index c2fa9191..35652038 100644 --- a/utils/gui/group.lua +++ b/utils/gui/group.lua @@ -30,8 +30,8 @@ local function build_group_gui(data) local group_name_width = 150 local description_width = 240 local members_width = 90 - local member_columns = 3 - local actions_width = 80 + local member_columns = 2 + local actions_width = 130 local total_height = frame.style.minimal_height - 60 frame.clear() @@ -46,11 +46,12 @@ local function build_group_gui(data) for _, h in pairs(headings) do local l = t.add({type = 'label', caption = h[1]}) l.style.font_color = {r = 0.98, g = 0.66, b = 0.22} - l.style.font = 'default-listbox' + l.style.font = 'heading-2' l.style.top_padding = 6 l.style.minimal_height = 40 l.style.minimal_width = h[2] l.style.maximal_width = h[2] + l.style.horizontal_align = 'center' end local scroll_pane = @@ -76,11 +77,12 @@ local function build_group_gui(data) for _, group in pairs(this.tag_groups) do if (group.name and group.founder and group.description) then local l = t.add({type = 'label', caption = group.name}) - l.style.font = 'default-bold' l.style.top_padding = 16 l.style.bottom_padding = 16 l.style.minimal_width = group_name_width l.style.maximal_width = group_name_width + l.style.font = 'heading-3' + l.style.horizontal_align = 'center' local color if game.players[group.founder] and game.players[group.founder].color then color = game.players[group.founder].color @@ -97,11 +99,17 @@ local function build_group_gui(data) l.style.maximal_width = description_width l.style.font_color = {r = 0.90, g = 0.90, b = 0.90} l.style.single_line = false + l.style.font = 'heading-3' + l.style.horizontal_align = 'center' - local tt = t.add({type = 'table', column_count = member_columns}) + local tt = t.add({type = 'table', column_count = 2}) + local flow = tt.add({type = 'flow'}) + flow.style.left_padding = 65 + local ttt = tt.add({type = 'table', column_count = member_columns}) + ttt.style.minimal_width = members_width * 2 - 25 for _, p in pairs(game.connected_players) do if group.name == this.player_group[p.name] then - l = tt.add({type = 'label', caption = p.name}) + l = ttt.add({type = 'label', caption = p.name}) color = { r = p.color.r * 0.6 + 0.4, g = p.color.g * 0.6 + 0.4, @@ -109,8 +117,10 @@ local function build_group_gui(data) a = 1 } l.style.font_color = color - --l.style.minimal_width = members_width - l.style.maximal_width = members_width * 2 + l.style.maximal_width = members_width * 2 - 60 + l.style.single_line = false + l.style.font = 'heading-3' + l.style.horizontal_align = 'center' end end @@ -153,10 +163,12 @@ end local build_group_gui_token = Token.register(build_group_gui) local function refresh_gui() - for _, p in pairs(game.connected_players) do - local frame = Gui.get_player_active_frame(p) + local players = game.connected_players + for i = 1, #players do + local player = players[i] + local frame = Gui.get_player_active_frame(player) if frame then - if frame.name == module_name then + if frame.frame2 and frame.frame2.valid then local new_group_name = frame.frame2.group_table.new_group_name.text local new_group_description = frame.frame2.group_table.new_group_description.text @@ -168,10 +180,10 @@ local function refresh_gui() new_group_description = '' end - local data = {player = p, frame = frame} + local data = {player = player, frame = frame} build_group_gui(data) - frame = Gui.get_player_active_frame(p) + frame = Gui.get_player_active_frame(player) frame.frame2.group_table.new_group_name.text = new_group_name frame.frame2.group_table.new_group_description.text = new_group_description end diff --git a/utils/gui/player_list.lua b/utils/gui/player_list.lua index 52cb1df7..7522aed3 100644 --- a/utils/gui/player_list.lua +++ b/utils/gui/player_list.lua @@ -576,7 +576,7 @@ local function player_list_show(data) name = 'player_list_panel_header_' .. k, caption = v } - header_label.style.font = 'default-bold' + header_label.style.font = 'heading-2' header_label.style.font_color = {r = 0.98, g = 0.66, b = 0.22} end @@ -677,6 +677,7 @@ local function player_list_show(data) } name_label.style.minimal_width = column_widths['name_label'] name_label.style.maximal_width = column_widths['name_label'] + name_label.style.font = 'heading-3' -- RPG level if this.rpg_enabled then @@ -689,6 +690,7 @@ local function player_list_show(data) } rpg_level_label.style.minimal_width = column_widths['rpg_level_label'] rpg_level_label.style.maximal_width = column_widths['rpg_level_label'] + rpg_level_label.style.font = 'heading-3' end -- Total time @@ -700,6 +702,7 @@ local function player_list_show(data) } total_label.style.minimal_width = column_widths['total_label'] total_label.style.maximal_width = column_widths['total_label'] + total_label.style.font = 'heading-3' -- Current time local current_label = @@ -710,6 +713,7 @@ local function player_list_show(data) } current_label.style.minimal_width = column_widths['current_label'] current_label.style.maximal_width = column_widths['current_label'] + current_label.style.font = 'heading-3' -- Poke local flow = player_list_panel_table.add {type = 'flow', name = 'button_flow_' .. i, direction = 'horizontal'} diff --git a/utils/gui/score.lua b/utils/gui/score.lua index baee7819..6b651d5f 100644 --- a/utils/gui/score.lua +++ b/utils/gui/score.lua @@ -127,22 +127,22 @@ local function add_global_stats(frame, player) local t = frame.add {type = 'table', column_count = 5} local l = t.add {type = 'label', caption = 'Rockets launched: '} - l.style.font = 'default-game' + l.style.font = 'heading-2' l.style.font_color = {r = 175, g = 75, b = 255} l.style.minimal_width = 140 local rocketsLaunched_label = t.add {type = 'label', caption = format_number(player.force.rockets_launched, true)} - rocketsLaunched_label.style.font = 'default-listbox' + rocketsLaunched_label.style.font = 'heading-3' rocketsLaunched_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} rocketsLaunched_label.style.minimal_width = 123 local bugs_dead_label = t.add {type = 'label', caption = 'Dead bugs: '} - bugs_dead_label.style.font = 'default-game' + bugs_dead_label.style.font = 'heading-2' bugs_dead_label.style.font_color = {r = 0.90, g = 0.3, b = 0.3} bugs_dead_label.style.minimal_width = 100 local killcount_label = t.add {type = 'label', caption = format_number(tonumber(get_total_biter_killcount(player.force)), true)} - killcount_label.style.font = 'default-listbox' + killcount_label.style.font = 'heading-3' killcount_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} killcount_label.style.minimal_width = 145 end @@ -191,10 +191,10 @@ local function show_score(data) caption = cap, name = header.name } - label.style.font = 'default-listbox' + label.style.font = 'heading-2' label.style.font_color = {r = 0.98, g = 0.66, b = 0.22} -- yellow label.style.minimal_width = 150 - label.style.horizontal_align = 'right' + label.style.horizontal_align = 'center' end -- Score list @@ -243,10 +243,10 @@ local function show_score(data) caption = column.caption, color = column.color or default_color } - label.style.font = 'default' + label.style.font = 'heading-3' label.style.minimal_width = 150 label.style.maximal_width = 150 - label.style.horizontal_align = 'right' + label.style.horizontal_align = 'center' end -- foreach column end -- foreach entry end diff --git a/utils/gui/server_select.lua b/utils/gui/server_select.lua index 997708ed..ddde5d00 100644 --- a/utils/gui/server_select.lua +++ b/utils/gui/server_select.lua @@ -66,42 +66,44 @@ local function draw_main_frame(player) } else for _, i in ipairs(instances) do - viewer_table.add { - type = 'label', - caption = i.name, - tooltip = i.connected .. '\nVersion: ' .. i.version, - style = 'caption_label' - } - local flow = viewer_table.add {type = 'flow'} - flow.style.horizontal_align = 'right' - flow.style.horizontally_stretchable = true - local empty_flow = viewer_table.add {type = 'flow'} - local button = - empty_flow.add { - type = 'button', - caption = 'Connect', - tooltip = 'Click to connect to this server.\n' .. i.connected .. '\nVersion: ' .. i.version, - name = instance_id_name - } - Gui.set_data(button, i.id) - apply_button_style(button) + if string.len(i.name) > 1 then + viewer_table.add { + type = 'label', + caption = i.name, + tooltip = i.connected .. '\nVersion: ' .. i.version, + style = 'caption_label' + } + local flow = viewer_table.add {type = 'flow'} + flow.style.horizontal_align = 'right' + flow.style.horizontally_stretchable = true + local empty_flow = viewer_table.add {type = 'flow'} + local button = + empty_flow.add { + type = 'button', + caption = 'Connect', + tooltip = 'Click to connect to this server.\n' .. i.connected .. '\nVersion: ' .. i.version, + name = instance_id_name + } + Gui.set_data(button, i.id) + apply_button_style(button) - if i.id == instance.id then - button.enabled = false - button.tooltip = 'You are here' - elseif i.status == 'unknown' then - button.enabled = i.game_port ~= nil - button.style.font_color = {r = 0.65} - button.style.hovered_font_color = {r = 0.65} - button.style.clicked_font_color = {r = 0.65} - button.style.disabled_font_color = {r = 0.75, g = 0.1, b = 0.1} - button.tooltip = 'Unknown status for this server' - elseif i.status ~= 'running' then - button.enabled = false - button.tooltip = 'This server is offline' - elseif i.version ~= instance.version then - button.enabled = false - button.tooltip = "We're on version: " .. instance.version .. '\nDestination server is on version: ' .. i.version + if i.id == instance.id then + button.enabled = false + button.tooltip = 'You are here' + elseif i.status == 'unknown' then + button.enabled = i.game_port ~= nil + button.style.font_color = {r = 0.65} + button.style.hovered_font_color = {r = 0.65} + button.style.clicked_font_color = {r = 0.65} + button.style.disabled_font_color = {r = 0.75, g = 0.1, b = 0.1} + button.tooltip = 'Unknown status for this server' + elseif i.status ~= 'running' then + button.enabled = false + button.tooltip = 'This server is offline' + elseif i.version ~= instance.version then + button.enabled = false + button.tooltip = "We're on version: " .. instance.version .. '\nDestination server is on version: ' .. i.version + end end end end From 5bbd70443804cbb68f172b6ed2a7a356fb91e87a Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 16:12:47 +0200 Subject: [PATCH 17/24] Added new function to iterate over all connected players --- utils/core.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/core.lua b/utils/core.lua index 4269e0db..27839b0b 100644 --- a/utils/core.lua +++ b/utils/core.lua @@ -103,6 +103,16 @@ function Public.get_actor() return '' end +--- Iterates over all connected players +---@param callback function +function Public.iter_connected_players(callback) + local players = game.connected_players + for i = 1, #players do + local player = players[i] + callback(player) + end +end + function Public.cast_bool(var) if var then return true From a5a0dafb2c94ee5ae525625c59e8b00028586519 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 22:00:46 +0200 Subject: [PATCH 18/24] test webhook event --- utils/gui/bottom_frame.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/gui/bottom_frame.lua b/utils/gui/bottom_frame.lua index 0bca097b..27c3f40e 100644 --- a/utils/gui/bottom_frame.lua +++ b/utils/gui/bottom_frame.lua @@ -211,7 +211,7 @@ local function set_location(player, state) end --- Activates the custom buttons ----@param boolean +---@param value boolean function Public.activate_custom_buttons(value) if value then this.activate_custom_buttons = value From d274165af5119e036fb56426bbf880948d521c8d Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Thu, 7 Apr 2022 23:27:22 +0200 Subject: [PATCH 19/24] template fix --- utils/git/biter_battles/main.lua | 1 + utils/git/biter_hatchery/main.lua | 1 + utils/git/choppy_dx/main.lua | 1 + utils/git/chronosphere/main.lua | 1 + utils/git/develop/main.lua | 1 + utils/git/fish_defender/main.lua | 1 + utils/git/journey/main.lua | 1 + utils/git/labyrinth/main.lua | 1 + utils/git/minesweeper/main.lua | 1 + utils/git/mountain_fortress_v3/main.lua | 1 + utils/git/planet_prison/main.lua | 1 + 11 files changed, 11 insertions(+) create mode 100644 utils/git/biter_battles/main.lua create mode 100644 utils/git/biter_hatchery/main.lua create mode 100644 utils/git/choppy_dx/main.lua create mode 100644 utils/git/chronosphere/main.lua create mode 100644 utils/git/develop/main.lua create mode 100644 utils/git/fish_defender/main.lua create mode 100644 utils/git/journey/main.lua create mode 100644 utils/git/labyrinth/main.lua create mode 100644 utils/git/minesweeper/main.lua create mode 100644 utils/git/mountain_fortress_v3/main.lua create mode 100644 utils/git/planet_prison/main.lua diff --git a/utils/git/biter_battles/main.lua b/utils/git/biter_battles/main.lua new file mode 100644 index 00000000..946597c7 --- /dev/null +++ b/utils/git/biter_battles/main.lua @@ -0,0 +1 @@ +return require 'maps.biter_battles_v2.main' diff --git a/utils/git/biter_hatchery/main.lua b/utils/git/biter_hatchery/main.lua new file mode 100644 index 00000000..08ac50b8 --- /dev/null +++ b/utils/git/biter_hatchery/main.lua @@ -0,0 +1 @@ +return require 'maps.biter_hatchery.main' diff --git a/utils/git/choppy_dx/main.lua b/utils/git/choppy_dx/main.lua new file mode 100644 index 00000000..c369d1f4 --- /dev/null +++ b/utils/git/choppy_dx/main.lua @@ -0,0 +1 @@ +return require 'maps.choppy_dx' diff --git a/utils/git/chronosphere/main.lua b/utils/git/chronosphere/main.lua new file mode 100644 index 00000000..1b4e0c0e --- /dev/null +++ b/utils/git/chronosphere/main.lua @@ -0,0 +1 @@ +return require 'maps.chronosphere.main' diff --git a/utils/git/develop/main.lua b/utils/git/develop/main.lua new file mode 100644 index 00000000..5403cf6a --- /dev/null +++ b/utils/git/develop/main.lua @@ -0,0 +1 @@ +_DEBUG = true diff --git a/utils/git/fish_defender/main.lua b/utils/git/fish_defender/main.lua new file mode 100644 index 00000000..c9730ba8 --- /dev/null +++ b/utils/git/fish_defender/main.lua @@ -0,0 +1 @@ +return require 'maps.fish_defender_v2.main' diff --git a/utils/git/journey/main.lua b/utils/git/journey/main.lua new file mode 100644 index 00000000..0ab6ea23 --- /dev/null +++ b/utils/git/journey/main.lua @@ -0,0 +1 @@ +return require 'maps.journey.main' diff --git a/utils/git/labyrinth/main.lua b/utils/git/labyrinth/main.lua new file mode 100644 index 00000000..1a9548be --- /dev/null +++ b/utils/git/labyrinth/main.lua @@ -0,0 +1 @@ +return require 'maps.labyrinth' diff --git a/utils/git/minesweeper/main.lua b/utils/git/minesweeper/main.lua new file mode 100644 index 00000000..b767d4b0 --- /dev/null +++ b/utils/git/minesweeper/main.lua @@ -0,0 +1 @@ +return require 'maps.minesweeper.main' diff --git a/utils/git/mountain_fortress_v3/main.lua b/utils/git/mountain_fortress_v3/main.lua new file mode 100644 index 00000000..7b781e4a --- /dev/null +++ b/utils/git/mountain_fortress_v3/main.lua @@ -0,0 +1 @@ +return require 'maps.mountain_fortress_v3.main' diff --git a/utils/git/planet_prison/main.lua b/utils/git/planet_prison/main.lua new file mode 100644 index 00000000..599798bf --- /dev/null +++ b/utils/git/planet_prison/main.lua @@ -0,0 +1 @@ +return require 'maps.planet_prison' From 8177457a5b317baba6bb7e8a71494f7168add011 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Fri, 8 Apr 2022 00:04:29 +0200 Subject: [PATCH 20/24] fix --- {utils/git/biter_battles => templates/Biter_Battles_v2}/main.lua | 0 {utils/git/biter_hatchery => templates/Biter_Hatchery}/main.lua | 0 {utils/git/choppy_dx => templates/Choppy_dx}/main.lua | 0 {utils/git/chronosphere => templates/Chronosphere}/main.lua | 0 {utils/git/develop => templates/Develop}/main.lua | 0 {utils/git/fish_defender => templates/Fish_Defender}/main.lua | 0 {utils/git/journey => templates/Journey}/main.lua | 0 {utils/git/labyrinth => templates/Labyrinth}/main.lua | 0 {utils/git/minesweeper => templates/Minesweeper}/main.lua | 0 .../Mountain_Fortress_v3}/main.lua | 0 {utils/git/planet_prison => templates/Planet_Prison}/main.lua | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {utils/git/biter_battles => templates/Biter_Battles_v2}/main.lua (100%) rename {utils/git/biter_hatchery => templates/Biter_Hatchery}/main.lua (100%) rename {utils/git/choppy_dx => templates/Choppy_dx}/main.lua (100%) rename {utils/git/chronosphere => templates/Chronosphere}/main.lua (100%) rename {utils/git/develop => templates/Develop}/main.lua (100%) rename {utils/git/fish_defender => templates/Fish_Defender}/main.lua (100%) rename {utils/git/journey => templates/Journey}/main.lua (100%) rename {utils/git/labyrinth => templates/Labyrinth}/main.lua (100%) rename {utils/git/minesweeper => templates/Minesweeper}/main.lua (100%) rename {utils/git/mountain_fortress_v3 => templates/Mountain_Fortress_v3}/main.lua (100%) rename {utils/git/planet_prison => templates/Planet_Prison}/main.lua (100%) diff --git a/utils/git/biter_battles/main.lua b/templates/Biter_Battles_v2/main.lua similarity index 100% rename from utils/git/biter_battles/main.lua rename to templates/Biter_Battles_v2/main.lua diff --git a/utils/git/biter_hatchery/main.lua b/templates/Biter_Hatchery/main.lua similarity index 100% rename from utils/git/biter_hatchery/main.lua rename to templates/Biter_Hatchery/main.lua diff --git a/utils/git/choppy_dx/main.lua b/templates/Choppy_dx/main.lua similarity index 100% rename from utils/git/choppy_dx/main.lua rename to templates/Choppy_dx/main.lua diff --git a/utils/git/chronosphere/main.lua b/templates/Chronosphere/main.lua similarity index 100% rename from utils/git/chronosphere/main.lua rename to templates/Chronosphere/main.lua diff --git a/utils/git/develop/main.lua b/templates/Develop/main.lua similarity index 100% rename from utils/git/develop/main.lua rename to templates/Develop/main.lua diff --git a/utils/git/fish_defender/main.lua b/templates/Fish_Defender/main.lua similarity index 100% rename from utils/git/fish_defender/main.lua rename to templates/Fish_Defender/main.lua diff --git a/utils/git/journey/main.lua b/templates/Journey/main.lua similarity index 100% rename from utils/git/journey/main.lua rename to templates/Journey/main.lua diff --git a/utils/git/labyrinth/main.lua b/templates/Labyrinth/main.lua similarity index 100% rename from utils/git/labyrinth/main.lua rename to templates/Labyrinth/main.lua diff --git a/utils/git/minesweeper/main.lua b/templates/Minesweeper/main.lua similarity index 100% rename from utils/git/minesweeper/main.lua rename to templates/Minesweeper/main.lua diff --git a/utils/git/mountain_fortress_v3/main.lua b/templates/Mountain_Fortress_v3/main.lua similarity index 100% rename from utils/git/mountain_fortress_v3/main.lua rename to templates/Mountain_Fortress_v3/main.lua diff --git a/utils/git/planet_prison/main.lua b/templates/Planet_Prison/main.lua similarity index 100% rename from utils/git/planet_prison/main.lua rename to templates/Planet_Prison/main.lua From 2880571e6a1d2f1c28e058c7181d8abe222f47ec Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Fri, 8 Apr 2022 00:08:40 +0200 Subject: [PATCH 21/24] minor change --- control.lua | 3 +++ templates/Biter_Battles_v2/{main.lua => map_loader.lua} | 0 templates/Biter_Hatchery/{main.lua => map_loader.lua} | 0 templates/Choppy_dx/{main.lua => map_loader.lua} | 0 templates/Chronosphere/{main.lua => map_loader.lua} | 0 templates/Develop/{main.lua => map_loader.lua} | 0 templates/Fish_Defender/{main.lua => map_loader.lua} | 0 templates/Journey/{main.lua => map_loader.lua} | 0 templates/Labyrinth/{main.lua => map_loader.lua} | 0 templates/Minesweeper/{main.lua => map_loader.lua} | 0 templates/Mountain_Fortress_v3/{main.lua => map_loader.lua} | 0 templates/Planet_Prison/{main.lua => map_loader.lua} | 0 12 files changed, 3 insertions(+) rename templates/Biter_Battles_v2/{main.lua => map_loader.lua} (100%) rename templates/Biter_Hatchery/{main.lua => map_loader.lua} (100%) rename templates/Choppy_dx/{main.lua => map_loader.lua} (100%) rename templates/Chronosphere/{main.lua => map_loader.lua} (100%) rename templates/Develop/{main.lua => map_loader.lua} (100%) rename templates/Fish_Defender/{main.lua => map_loader.lua} (100%) rename templates/Journey/{main.lua => map_loader.lua} (100%) rename templates/Labyrinth/{main.lua => map_loader.lua} (100%) rename templates/Minesweeper/{main.lua => map_loader.lua} (100%) rename templates/Mountain_Fortress_v3/{main.lua => map_loader.lua} (100%) rename templates/Planet_Prison/{main.lua => map_loader.lua} (100%) diff --git a/control.lua b/control.lua index 49b016e5..e261672d 100644 --- a/control.lua +++ b/control.lua @@ -250,6 +250,9 @@ require 'utils.freeplay' --require 'terrain_layouts.scrap_towny_ffa' --------------------------------------------------------------- +-- this file exists only for the panel to sync and start from within the panel +require 'map_loader' + if _DUMP_ENV then require 'utils.dump_env' require 'utils.profiler' diff --git a/templates/Biter_Battles_v2/main.lua b/templates/Biter_Battles_v2/map_loader.lua similarity index 100% rename from templates/Biter_Battles_v2/main.lua rename to templates/Biter_Battles_v2/map_loader.lua diff --git a/templates/Biter_Hatchery/main.lua b/templates/Biter_Hatchery/map_loader.lua similarity index 100% rename from templates/Biter_Hatchery/main.lua rename to templates/Biter_Hatchery/map_loader.lua diff --git a/templates/Choppy_dx/main.lua b/templates/Choppy_dx/map_loader.lua similarity index 100% rename from templates/Choppy_dx/main.lua rename to templates/Choppy_dx/map_loader.lua diff --git a/templates/Chronosphere/main.lua b/templates/Chronosphere/map_loader.lua similarity index 100% rename from templates/Chronosphere/main.lua rename to templates/Chronosphere/map_loader.lua diff --git a/templates/Develop/main.lua b/templates/Develop/map_loader.lua similarity index 100% rename from templates/Develop/main.lua rename to templates/Develop/map_loader.lua diff --git a/templates/Fish_Defender/main.lua b/templates/Fish_Defender/map_loader.lua similarity index 100% rename from templates/Fish_Defender/main.lua rename to templates/Fish_Defender/map_loader.lua diff --git a/templates/Journey/main.lua b/templates/Journey/map_loader.lua similarity index 100% rename from templates/Journey/main.lua rename to templates/Journey/map_loader.lua diff --git a/templates/Labyrinth/main.lua b/templates/Labyrinth/map_loader.lua similarity index 100% rename from templates/Labyrinth/main.lua rename to templates/Labyrinth/map_loader.lua diff --git a/templates/Minesweeper/main.lua b/templates/Minesweeper/map_loader.lua similarity index 100% rename from templates/Minesweeper/main.lua rename to templates/Minesweeper/map_loader.lua diff --git a/templates/Mountain_Fortress_v3/main.lua b/templates/Mountain_Fortress_v3/map_loader.lua similarity index 100% rename from templates/Mountain_Fortress_v3/main.lua rename to templates/Mountain_Fortress_v3/map_loader.lua diff --git a/templates/Planet_Prison/main.lua b/templates/Planet_Prison/map_loader.lua similarity index 100% rename from templates/Planet_Prison/main.lua rename to templates/Planet_Prison/map_loader.lua From 6e98f1c1bc676b4a90701e7138e9fd84ef222f68 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Fri, 8 Apr 2022 00:11:10 +0200 Subject: [PATCH 22/24] final fix --- control.lua | 5 +++-- .../templates}/Biter_Battles_v2/map_loader.lua | 0 {templates => utils/templates}/Biter_Hatchery/map_loader.lua | 0 {templates => utils/templates}/Choppy_dx/map_loader.lua | 0 {templates => utils/templates}/Chronosphere/map_loader.lua | 0 {templates => utils/templates}/Develop/map_loader.lua | 0 {templates => utils/templates}/Fish_Defender/map_loader.lua | 0 {templates => utils/templates}/Journey/map_loader.lua | 0 {templates => utils/templates}/Labyrinth/map_loader.lua | 0 {templates => utils/templates}/Minesweeper/map_loader.lua | 0 .../templates}/Mountain_Fortress_v3/map_loader.lua | 0 {templates => utils/templates}/Planet_Prison/map_loader.lua | 0 utils/templates/map_loader.lua | 0 13 files changed, 3 insertions(+), 2 deletions(-) rename {templates => utils/templates}/Biter_Battles_v2/map_loader.lua (100%) rename {templates => utils/templates}/Biter_Hatchery/map_loader.lua (100%) rename {templates => utils/templates}/Choppy_dx/map_loader.lua (100%) rename {templates => utils/templates}/Chronosphere/map_loader.lua (100%) rename {templates => utils/templates}/Develop/map_loader.lua (100%) rename {templates => utils/templates}/Fish_Defender/map_loader.lua (100%) rename {templates => utils/templates}/Journey/map_loader.lua (100%) rename {templates => utils/templates}/Labyrinth/map_loader.lua (100%) rename {templates => utils/templates}/Minesweeper/map_loader.lua (100%) rename {templates => utils/templates}/Mountain_Fortress_v3/map_loader.lua (100%) rename {templates => utils/templates}/Planet_Prison/map_loader.lua (100%) create mode 100644 utils/templates/map_loader.lua diff --git a/control.lua b/control.lua index e261672d..608b235f 100644 --- a/control.lua +++ b/control.lua @@ -250,8 +250,9 @@ require 'utils.freeplay' --require 'terrain_layouts.scrap_towny_ffa' --------------------------------------------------------------- --- this file exists only for the panel to sync and start from within the panel -require 'map_loader' +--- this file exists only for the panel to sync and start from within the panel +-- it does nothing if it's not synced from within the panel +require 'utils/templates/map_loader' if _DUMP_ENV then require 'utils.dump_env' diff --git a/templates/Biter_Battles_v2/map_loader.lua b/utils/templates/Biter_Battles_v2/map_loader.lua similarity index 100% rename from templates/Biter_Battles_v2/map_loader.lua rename to utils/templates/Biter_Battles_v2/map_loader.lua diff --git a/templates/Biter_Hatchery/map_loader.lua b/utils/templates/Biter_Hatchery/map_loader.lua similarity index 100% rename from templates/Biter_Hatchery/map_loader.lua rename to utils/templates/Biter_Hatchery/map_loader.lua diff --git a/templates/Choppy_dx/map_loader.lua b/utils/templates/Choppy_dx/map_loader.lua similarity index 100% rename from templates/Choppy_dx/map_loader.lua rename to utils/templates/Choppy_dx/map_loader.lua diff --git a/templates/Chronosphere/map_loader.lua b/utils/templates/Chronosphere/map_loader.lua similarity index 100% rename from templates/Chronosphere/map_loader.lua rename to utils/templates/Chronosphere/map_loader.lua diff --git a/templates/Develop/map_loader.lua b/utils/templates/Develop/map_loader.lua similarity index 100% rename from templates/Develop/map_loader.lua rename to utils/templates/Develop/map_loader.lua diff --git a/templates/Fish_Defender/map_loader.lua b/utils/templates/Fish_Defender/map_loader.lua similarity index 100% rename from templates/Fish_Defender/map_loader.lua rename to utils/templates/Fish_Defender/map_loader.lua diff --git a/templates/Journey/map_loader.lua b/utils/templates/Journey/map_loader.lua similarity index 100% rename from templates/Journey/map_loader.lua rename to utils/templates/Journey/map_loader.lua diff --git a/templates/Labyrinth/map_loader.lua b/utils/templates/Labyrinth/map_loader.lua similarity index 100% rename from templates/Labyrinth/map_loader.lua rename to utils/templates/Labyrinth/map_loader.lua diff --git a/templates/Minesweeper/map_loader.lua b/utils/templates/Minesweeper/map_loader.lua similarity index 100% rename from templates/Minesweeper/map_loader.lua rename to utils/templates/Minesweeper/map_loader.lua diff --git a/templates/Mountain_Fortress_v3/map_loader.lua b/utils/templates/Mountain_Fortress_v3/map_loader.lua similarity index 100% rename from templates/Mountain_Fortress_v3/map_loader.lua rename to utils/templates/Mountain_Fortress_v3/map_loader.lua diff --git a/templates/Planet_Prison/map_loader.lua b/utils/templates/Planet_Prison/map_loader.lua similarity index 100% rename from templates/Planet_Prison/map_loader.lua rename to utils/templates/Planet_Prison/map_loader.lua diff --git a/utils/templates/map_loader.lua b/utils/templates/map_loader.lua new file mode 100644 index 00000000..e69de29b From e7658d12a12ac7632afce04bff04d0a0904c350e Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Fri, 8 Apr 2022 00:34:10 +0200 Subject: [PATCH 23/24] small change --- utils/templates/map_loader.lua => map_loader.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename utils/templates/map_loader.lua => map_loader.lua (100%) diff --git a/utils/templates/map_loader.lua b/map_loader.lua similarity index 100% rename from utils/templates/map_loader.lua rename to map_loader.lua From bdd16d9a2f64b948a00d2e9ce963b309e8c855af Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Fri, 8 Apr 2022 00:35:03 +0200 Subject: [PATCH 24/24] minor change --- control.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control.lua b/control.lua index 608b235f..de2d5540 100644 --- a/control.lua +++ b/control.lua @@ -252,7 +252,7 @@ require 'utils.freeplay' --- this file exists only for the panel to sync and start from within the panel -- it does nothing if it's not synced from within the panel -require 'utils/templates/map_loader' +require 'map_loader' if _DUMP_ENV then require 'utils.dump_env'