From e2a33f9f30bb9edcdb60534f5a4edfd5591e7769 Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Wed, 24 Mar 2021 20:14:55 +0100 Subject: [PATCH] luacheck more fixes --- .luacheckrc | 5 +- chatbot.lua | 6 +- maps/atoll.lua | 12 +- maps/blue_beach.lua | 24 +--- maps/cave_miner.lua | 1 + maps/cave_miner_changelog.txt | 115 ------------------ maps/cave_miner_kaboomsticks.lua | 9 +- maps/choppy.lua | 1 + maps/choppy_dx.lua | 1 + maps/cratewood_forest.lua | 1 + maps/crossing.lua | 1 + maps/cube.lua | 1 + maps/deep_jungle.lua | 1 + maps/deep_jungle_old.lua | 1 + maps/desert_oasis.lua | 1 + maps/hedge_maze.lua | 1 + maps/hunger_games_map_intro.lua | 1 + maps/junkyard.lua | 1 + maps/labyrinth.lua | 1 + maps/labyrinth_changelog.txt | 12 -- maps/labyrinth_map_intro.lua | 1 + maps/lost.lua | 1 + maps/lost_desert.lua | 1 + maps/maze_challenge.lua | 1 + maps/mixed_railworld.lua | 1 + maps/mountain_fortress.lua | 1 + maps/mountain_fortress_v3/commands.lua | 2 +- maps/mountain_fortress_v3/generate.lua | 2 - maps/mountain_fortress_v3/highscore.lua | 84 ++++++------- maps/mountain_race/main.lua | 1 + maps/mountain_race/team.lua | 1 + maps/mountain_race/terrain.lua | 1 + maps/native_war/gui.lua | 1 + maps/native_war/init.lua | 1 + maps/native_war/main.lua | 1 + maps/native_war/map_info.lua | 1 + .../mineable_wreckage_yields_scrap.lua | 1 + maps/native_war/share_chat.lua | 1 + maps/native_war/team.lua | 1 + maps/native_war/team_manager.lua | 1 + maps/native_war/terrain.lua | 1 + maps/native_war/xp.lua | 1 + maps/nightfall.lua | 1 + maps/nightfall_map_intro.lua | 1 + maps/overgrowth.lua | 1 + maps/overgrowth_map_info.lua | 1 + maps/pitch_black/difficulty.lua | 4 +- maps/pitch_black/gui.lua | 2 +- maps/planet_prison/mod/common.lua | 4 +- maps/quarters.lua | 1 + maps/railway_troopers/main.lua | 5 +- maps/railway_troopers_v2/main.lua | 14 +-- maps/rainbow_road.lua | 1 + maps/refactor-io.lua | 1 + maps/rivers.lua | 1 + maps/rocky_waste.lua | 1 + maps/spaghettorio.lua | 1 + maps/spiral_troopers.lua | 1 + maps/spooky_forest.lua | 1 + maps/stone_maze/1x1_rooms.lua | 1 + maps/stone_maze/2x2_rooms.lua | 1 + maps/stone_maze/3x3_rooms.lua | 1 + maps/stone_maze/global_functions.lua | 1 + maps/stone_maze/main.lua | 1 + maps/stoneblock.lua | 1 + maps/tank_battles.lua | 1 + maps/tank_battles_old.lua | 1 + maps/tank_conquest/tank_conquest.lua | 1 + maps/territorial_control.lua | 1 + maps/tetris/main.lua | 1 + maps/tetris/unused.lua | 1 + maps/wave_defense.lua | 2 +- maps/wave_of_death/WoD.lua | 1 + maps/wave_of_death/ai.lua | 1 + maps/wave_of_death/game_status.lua | 1 + maps/wave_of_death/init.lua | 1 + maps/wave_of_death/intro.lua | 1 + maps/wave_of_death/spectate.lua | 1 + maps/wave_of_death/terrain.lua | 1 + modules/admins_operate_biters.lua | 1 + modules/area_unlocked_on_rotated_entity.lua | 1 + modules/autodecon_when_depleted.lua | 1 + modules/autohotbar.lua | 1 + modules/backpack_research.lua | 4 +- modules/ban_drop.lua | 1 - modules/biter_evasion_hp_increaser.lua | 6 +- modules/biter_health_booster.lua | 2 +- modules/biter_noms_you.lua | 4 +- modules/biter_pets.lua | 23 ++-- modules/biter_player_count_difficulty.lua | 12 +- modules/biters_attack_moving_players.lua | 8 +- modules/biters_avoid_damage.lua | 4 +- modules/biters_double_damage.lua | 6 +- modules/burden.lua | 4 +- modules/charging_station.lua | 2 +- modules/comfylatron.lua | 6 +- modules/custom_death_messages.lua | 5 +- modules/dangerous_nights.lua | 4 +- modules/difficulty_vote.lua | 2 +- modules/difficulty_vote_by_amount.lua | 2 +- modules/dynamic_landfill.lua | 10 +- modules/dynamic_player_spawn.lua | 4 +- modules/evolution_extended.lua | 11 +- modules/explosive_biters.lua | 4 +- modules/explosive_player_respawn.lua | 4 +- modules/explosives_2.lua | 9 +- modules/explosives_are_explosive.lua | 9 +- modules/fjei/functions.lua | 1 + modules/fjei/gui.lua | 4 +- modules/fjei/main.lua | 1 + modules/flashlight_toggle_button.lua | 8 +- modules/floaty_chat.lua | 8 +- modules/fluids_are_explosive.lua | 9 +- modules/force_health_booster.lua | 2 +- modules/global_chat_toggle.lua | 1 - modules/hidden_dimension/main.lua | 1 + modules/hunger.lua | 3 +- modules/hunger_games.lua | 47 ++++--- modules/hunger_games_balance.lua | 37 +----- modules/immersive_cargo_wagons/functions.lua | 1 + modules/immersive_cargo_wagons/main.lua | 6 +- modules/landfill_reveals_nauvis.lua | 23 +--- modules/launch_fish_to_win.lua | 6 +- modules/manual_mining_booster.lua | 10 +- modules/map_info.lua | 2 +- modules/market_friendly_fire_protection.lua | 4 +- modules/mineable_wreckage_yields_ores.lua | 10 +- modules/mineable_wreckage_yields_scrap.lua | 2 +- modules/no_blueprint_library.lua | 6 +- modules/no_handcrafting.lua | 9 +- modules/no_robots.lua | 6 +- modules/ores_are_mixed.lua | 4 +- modules/players_trample_paths.lua | 4 +- modules/railgun_enhancer.lua | 6 +- modules/restrictive_fluid_mining.lua | 6 +- modules/rewards.lua | 36 +++--- .../rocket_launch_always_yields_science.lua | 4 +- modules/rocks_heal_over_time.lua | 12 +- modules/rocks_yield_coins.lua | 4 +- modules/rocks_yield_ore.lua | 4 +- modules/rocks_yield_ore_veins.lua | 2 +- modules/rpg.lua | 1 + modules/satellite_score.lua | 19 ++- modules/scramble_ores.lua | 23 ++-- modules/scrap_towny_ffa/biters.lua | 1 + modules/scrap_towny_ffa/building.lua | 1 + modules/scrap_towny_ffa/spawn.lua | 1 + modules/scrap_towny_ffa/team.lua | 1 + modules/scrap_towny_ffa/towny_balance.lua | 1 + modules/shopping_chests.lua | 22 ++-- modules/show_health.lua | 6 +- modules/simple_tags.lua | 2 +- modules/spaghett_challenge.lua | 14 +-- modules/spawners_contain_acid.lua | 5 +- modules/spitters_spit_biters.lua | 4 +- modules/splice.lua | 6 +- modules/splice_double.lua | 6 +- modules/surrounded_by_worms.lua | 6 +- modules/team_teleport.lua | 4 +- modules/teleporters.lua | 26 ++-- modules/teleporting_worms.lua | 5 +- modules/the_floor_is_lava.lua | 10 +- modules/towny/biters.lua | 1 + modules/towny/info.lua | 1 + modules/towny/main.lua | 1 + modules/towny/market.lua | 1 + modules/towny/team.lua | 1 + modules/towny/town_center.lua | 1 + modules/trees_grow.lua | 21 ++-- modules/trees_randomly_die.lua | 11 +- modules/wave_defense/gui.lua | 36 +++--- modules/wave_defense/main.lua | 6 +- terrain_layouts/scrap_01.lua | 4 +- terrain_layouts/scrap_02.lua | 28 +---- terrain_layouts/tree_01.lua | 14 +-- terrain_layouts/winter.lua | 15 +-- tools/cheat_mode.lua | 4 +- tools/map_functions.lua | 12 +- tools/map_intro.lua | 14 +-- tools/map_pregen.lua | 10 +- utils/core.lua | 30 ++--- utils/event.lua | 6 +- utils/gui.lua | 2 +- utils/list_utils.lua | 1 + utils/one_dimensional_noise.lua | 8 +- utils/perlin_noise.lua | 36 +++--- utils/profiler.lua | 5 +- utils/scenariohandler.lua | 3 +- utils/simplex_noise.lua | 9 -- utils/table.lua | 4 +- 190 files changed, 526 insertions(+), 727 deletions(-) delete mode 100644 maps/cave_miner_changelog.txt delete mode 100644 maps/labyrinth_changelog.txt diff --git a/.luacheckrc b/.luacheckrc index 24fec151..6f9f9155 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -232,6 +232,7 @@ stds.factorio_control = { other_fields = false, read_only = true, fields = { + 'set_visible', 'draw_line', 'draw_text', 'draw_circle', @@ -323,6 +324,7 @@ stds.factorio_control = { other_fields = false, read_only = false, fields = { + "disable_tutorial_triggers", "auto_save", "ban_player", "check_consistency", @@ -617,7 +619,7 @@ stds.stdlib = { read_globals = { table = { fields = { - "shuffle_table", "map", "avg", "count_keys", "sum", "max", "remove", "insert", "invert", "first", "sort", "compare", "maxn", "any", "array_to_dictionary", + "mean", "binary_search", "shuffle_table", "map", "avg", "count_keys", "sum", "max", "remove", "insert", "invert", "first", "sort", "compare", "maxn", "any", "array_to_dictionary", "each", "flatten", "keys", "filter", "remove_keys", "flexcopy", "find", "fullcopy", "values", "pack", "deepcopy", "concat", "clear", "min", "is_empty", "merge", "size", "dictionary_merge", "unpack", "last" }, @@ -1069,6 +1071,7 @@ stds.factorio_defines = { }, input_action = { fields = { + 'open_kills_gui', 'change_item_description', 'fast_entity_transfer', 'set_recipe_notifications', diff --git a/chatbot.lua b/chatbot.lua index 84fe684f..3431192d 100644 --- a/chatbot.lua +++ b/chatbot.lua @@ -109,17 +109,13 @@ commands.add_command( function(cmd) local trusted = session.get_trusted_table() local player = game.player - local p if player then if player ~= nil then - p = player.print if not player.admin then - p("You're not admin!", {r = 1, g = 0.5, b = 0.1}) + player.print("You're not admin!", {r = 1, g = 0.5, b = 0.1}) return end - else - p = log end if cmd.parameter == nil then diff --git a/maps/atoll.lua b/maps/atoll.lua index fc4efbb9..9081f0f3 100644 --- a/maps/atoll.lua +++ b/maps/atoll.lua @@ -5,10 +5,9 @@ require 'modules.surrounded_by_worms' local simplex_noise = require 'utils.simplex_noise' simplex_noise = simplex_noise.d2 -local event = require 'utils.event' +local Event = require 'utils.event' local table_insert = table.insert local math_random = math.random -local map_functions = require 'tools.map_functions' local function get_noise(name, pos) local seed = game.surfaces[1].map_gen_settings.seed @@ -23,7 +22,7 @@ local function get_noise(name, pos) noise[3] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) seed = seed + noise_seed_add noise[4] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed) - local noise = noise[1] + noise[2] * 0.3 + noise[3] * 0.2 + noise[4] * 0.1 + noise = noise[1] + noise[2] * 0.3 + noise[3] * 0.2 + noise[4] * 0.1 --noise = noise * 0.5 return noise end @@ -97,7 +96,6 @@ local function on_chunk_generated(event) end end -event.add(defines.events.on_entity_died, on_entity_died) -event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction) -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_chunk_generated, on_chunk_generated) +Event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_chunk_generated, on_chunk_generated) diff --git a/maps/blue_beach.lua b/maps/blue_beach.lua index 98f09602..9156d744 100644 --- a/maps/blue_beach.lua +++ b/maps/blue_beach.lua @@ -11,21 +11,6 @@ local WD = require 'modules.wave_defense.table' require 'modules.wave_defense.main' local math_random = math.random -local simplex_noise = require 'utils.simplex_noise'.d2 - -local function get_noise(name, pos) - local seed = game.surfaces[1].map_gen_settings.seed - local noise_seed_add = 25000 - seed = seed + noise_seed_add - if name == 'sands' then - local noise = {} - noise[1] = simplex_noise(pos.x * 0.016, pos.y * 0.012, seed) - seed = seed + noise_seed_add - noise[2] = simplex_noise(pos.x * 0.064, pos.y * 0.048, seed) - local noise = noise[1] + noise[2] * 0.1 - return noise - end -end local landfill_drops = { ['small-biter'] = 1, @@ -44,13 +29,6 @@ local landfill_drops = { ['behemoth-worm-turret'] = 64 } -local turrets = { - [1] = 'small-worm-turret', - [2] = 'medium-worm-turret', - [3] = 'big-worm-turret', - [4] = 'behemoth-worm-turret' -} - local tile_coords = {} for x = 0, 31, 1 do for y = 0, 31, 1 do @@ -70,7 +48,7 @@ local function north_side(surface, left_top) return end - for a = 1, math_random(3, 5), 1 do + for _ = 1, math_random(3, 5), 1 do local coord_modifier = tile_coords[math_random(1, #tile_coords)] local pos = {left_top.x + coord_modifier[1], left_top.y + coord_modifier[2]} local name = 'biter-spawner' diff --git a/maps/cave_miner.lua b/maps/cave_miner.lua index 4e5a8fe5..0eccd3d7 100644 --- a/maps/cave_miner.lua +++ b/maps/cave_miner.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- Cave Miner -- mewmew made this -- require 'modules.rocks_heal_over_time' diff --git a/maps/cave_miner_changelog.txt b/maps/cave_miner_changelog.txt deleted file mode 100644 index 2e4963a4..00000000 --- a/maps/cave_miner_changelog.txt +++ /dev/null @@ -1,115 +0,0 @@ -0.21 -Ore bonus yield limited at the maximum biter difficulty. - -0.20 -a big part of the lootboxes are now hidden within the rocks - -0.19 -markets are now also fish bank terminals -fish can not be deconstructed anymore - -0.18 -cargo wagons, tanks and cars can now only detonate with less than 150 health - -0.17 -explosives are now a new game mechanic -loot rebalances -ore yield balance - -0.16 -oil should no longer clutter -increased rock destruction performance (maybe) -rocks now heal over time - -0.15 -players in vehicles no longer get hungry -faster mining speed but lower ore yield for more exploration -new fully staged chest loot - -0.14 -hunger over time reduced -reduced worms -ore vein spawn fix - -0.13 -biter attack events frequency reduced -players in vehicles are safe from random biter spawns -hunger gain from passing time reduced - -0.12 -reduced ore spill from rock destruction to reduce lagspike -ore veins are usually bigger now and can appear earlier -biters have a bit more damage against rocks -market adjustments -readded worms in main tunnels -crude oil is allowed to spawn a bit closer -access to the lakes and labyrinth areas should be a bit wider now -damage against huge rocks has been increased -biter spawn interval adjustments - -0.11 -mining speed buff -ore veins are more common - -0.10 -difficulty adjustments -spawn fixes - -0.09 -ore veins are more common with more yield -added info panel -added more worms -added extra bases in main mine shafts -adjusted running speed modifier -adjusted biter attack events -modified chest loot tables -mining trees now makes you earn fish - -0.08 -rock "labyrinth" biome -periodic biter attack events, the mines have become more dangerous -custom spawn trees - -0.07 -small chance that rocks might reveal an ore vein -rocks now always drop stone -players are now getting hungry - -0.06 -added stats gui -mining productivity research will now upgrade your backpack to ease your mining -fishing is more enjoyable now -rebalanced oil spots -spawn inventory loadout changes - -0.05 -biter & worm generation is now completely custom -biters claws now have a hard time to dig through the solid rock -secret shops spawn now in lake biomes -mining productivity research boosts cave rock mining speed for triple the value - -0.04 -biters no longer instantly surround the player - -0.03 -market nerf -darkness buff -mining productivity research now applies to cave rock mining -lakes now have fish -added cave treasure - -0.02 -space cleared around enemy spawners -fish market adjustments -maximum ore spill variable (rest gets inserted directly) -biters now also pop out of destroyed rocks -adjustments to ore chances -noise adjustments -different enemies now spawn the deeper you dig -enemy spawn pool redone -darkness is now a hazard, stay near lamps for survival -caves are now permanently dark -added lake biomes - -0.01 -diggy diggy hole diff --git a/maps/cave_miner_kaboomsticks.lua b/maps/cave_miner_kaboomsticks.lua index a2459606..11836579 100644 --- a/maps/cave_miner_kaboomsticks.lua +++ b/maps/cave_miner_kaboomsticks.lua @@ -1,7 +1,7 @@ --This will add a new game mechanic so that containers with explosives actually go boom when they get damaged. --Made by MewMew -local event = require 'utils.event' +local Event = require 'utils.event' local damage_per_explosive = 100 local empty_tile_damage_decay = 100 @@ -1752,14 +1752,13 @@ local function on_entity_damaged(event) end end -local function on_tick(event) +local function on_tick() if global.explosion_schedule then local tick = game.tick local explosion_schedule_is_alive = false for explosion_index = 1, #global.explosion_schedule, 1 do if #global.explosion_schedule[explosion_index] > 0 then explosion_schedule_is_alive = true - local surface = game.surfaces[global.explosion_schedule[explosion_index].surface] for radius = 1, #global.explosion_schedule[explosion_index], 1 do if global.explosion_schedule[explosion_index][radius].trigger_tick == tick then for tile_index = 1, #global.explosion_schedule[explosion_index][radius], 1 do @@ -1783,5 +1782,5 @@ local function on_tick(event) end end -event.add(defines.events.on_entity_damaged, on_entity_damaged) -event.add(defines.events.on_tick, on_tick) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_tick, on_tick) diff --git a/maps/choppy.lua b/maps/choppy.lua index 1ff3302a..09e6966e 100644 --- a/maps/choppy.lua +++ b/maps/choppy.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --choppy-- mewmew made this -- require 'modules.dynamic_landfill' diff --git a/maps/choppy_dx.lua b/maps/choppy_dx.lua index b9826d82..193e8e62 100644 --- a/maps/choppy_dx.lua +++ b/maps/choppy_dx.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --choppy-- mewmew made this -- --neko barons attempt to mix up map gen-- diff --git a/maps/cratewood_forest.lua b/maps/cratewood_forest.lua index 2a51565a..968c118e 100644 --- a/maps/cratewood_forest.lua +++ b/maps/cratewood_forest.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local simplex_noise = require 'utils.simplex_noise'.d2 require 'modules.satellite_score' diff --git a/maps/crossing.lua b/maps/crossing.lua index 36237f28..5bdcdd75 100644 --- a/maps/crossing.lua +++ b/maps/crossing.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- crossing -- by mewmew -- local event = require 'utils.event' diff --git a/maps/cube.lua b/maps/cube.lua index a24af197..f2d69756 100644 --- a/maps/cube.lua +++ b/maps/cube.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- cuuuubee local event = require 'utils.event' diff --git a/maps/deep_jungle.lua b/maps/deep_jungle.lua index 9da52768..375ec5d9 100644 --- a/maps/deep_jungle.lua +++ b/maps/deep_jungle.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --deep jungle-- mewmew made this -- require 'modules.no_deconstruction_of_neutral_entities' require 'modules.spawners_contain_biters' diff --git a/maps/deep_jungle_old.lua b/maps/deep_jungle_old.lua index 0c1a3c9a..259ffea9 100644 --- a/maps/deep_jungle_old.lua +++ b/maps/deep_jungle_old.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --deep jungle-- mewmew made this -- local map_functions = require 'tools.map_functions' local simplex_noise = require 'utils.simplex_noise' diff --git a/maps/desert_oasis.lua b/maps/desert_oasis.lua index 022e162c..b43e7cb7 100644 --- a/maps/desert_oasis.lua +++ b/maps/desert_oasis.lua @@ -1,3 +1,4 @@ +--luacheck: ignore require 'modules.satellite_score' require 'modules.thirst' diff --git a/maps/hedge_maze.lua b/maps/hedge_maze.lua index 2372ada2..b828c303 100644 --- a/maps/hedge_maze.lua +++ b/maps/hedge_maze.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- forest maze from mewmew require 'modules.satellite_score' diff --git a/maps/hunger_games_map_intro.lua b/maps/hunger_games_map_intro.lua index d5026a5d..5185f62a 100644 --- a/maps/hunger_games_map_intro.lua +++ b/maps/hunger_games_map_intro.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local main_caption = ' --Hunger Games Mode-- ' diff --git a/maps/junkyard.lua b/maps/junkyard.lua index 3a241768..db08f616 100644 --- a/maps/junkyard.lua +++ b/maps/junkyard.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --junkyard-- mewmew made this -- require 'modules.dynamic_landfill' diff --git a/maps/labyrinth.lua b/maps/labyrinth.lua index 8dfa9f6a..997893d6 100644 --- a/maps/labyrinth.lua +++ b/maps/labyrinth.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --labyrinth-- mewmew made this -- require 'maps.labyrinth_map_intro' require 'modules.teleporters' diff --git a/maps/labyrinth_changelog.txt b/maps/labyrinth_changelog.txt deleted file mode 100644 index e617f583..00000000 --- a/maps/labyrinth_changelog.txt +++ /dev/null @@ -1,12 +0,0 @@ -0.03 -biters will spawn weighted -drops from enemies will stop more soon -infinity chests have been nerfed -more ore patches - -0.02 -anti-turret creep things - -0.01 -loot table adjustments -the dungeon inhabitants will now try to swarm to the entrance sometimes diff --git a/maps/labyrinth_map_intro.lua b/maps/labyrinth_map_intro.lua index 81349279..856ccfa7 100644 --- a/maps/labyrinth_map_intro.lua +++ b/maps/labyrinth_map_intro.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local main_caption = ' --Labyrinth-- ' diff --git a/maps/lost.lua b/maps/lost.lua index 6ffcb49a..c9ba4b33 100644 --- a/maps/lost.lua +++ b/maps/lost.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --lost-- mewmew made this -- require 'modules.landfill_reveals_nauvis' diff --git a/maps/lost_desert.lua b/maps/lost_desert.lua index eb5ef4cf..4f53f4f2 100644 --- a/maps/lost_desert.lua +++ b/maps/lost_desert.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --lost desert-- mewmew made this -- require 'modules.rocks_broken_paint_tiles' diff --git a/maps/maze_challenge.lua b/maps/maze_challenge.lua index 9dacfb34..c73fcb5b 100644 --- a/maps/maze_challenge.lua +++ b/maps/maze_challenge.lua @@ -1,3 +1,4 @@ +--luacheck: ignore require 'functions.maze' local event = require 'utils.event' diff --git a/maps/mixed_railworld.lua b/maps/mixed_railworld.lua index b907e414..fb34a766 100644 --- a/maps/mixed_railworld.lua +++ b/maps/mixed_railworld.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' require 'modules.spawners_contain_acid' diff --git a/maps/mountain_fortress.lua b/maps/mountain_fortress.lua index b548ce5e..f6594039 100644 --- a/maps/mountain_fortress.lua +++ b/maps/mountain_fortress.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- mountain digger fortress -- by mewmew -- require 'modules.rpg' diff --git a/maps/mountain_fortress_v3/commands.lua b/maps/mountain_fortress_v3/commands.lua index 15d164b9..a6a96e51 100644 --- a/maps/mountain_fortress_v3/commands.lua +++ b/maps/mountain_fortress_v3/commands.lua @@ -125,7 +125,7 @@ commands.add_command( commands.add_command( 'disable_biters', 'Usable only for admins - sets the queue speed of this map!', - function(cmd) + function() local player = game.player if not player and player.valid then diff --git a/maps/mountain_fortress_v3/generate.lua b/maps/mountain_fortress_v3/generate.lua index c7789db4..45eb70ed 100644 --- a/maps/mountain_fortress_v3/generate.lua +++ b/maps/mountain_fortress_v3/generate.lua @@ -578,8 +578,6 @@ local function on_chunk(event) end if force_chunk then do_chunk(event) - elseif event.tick == 0 then - --do_chunk(event) else schedule_chunk(event) end diff --git a/maps/mountain_fortress_v3/highscore.lua b/maps/mountain_fortress_v3/highscore.lua index 1ca5bd39..015f5a66 100644 --- a/maps/mountain_fortress_v3/highscore.lua +++ b/maps/mountain_fortress_v3/highscore.lua @@ -430,58 +430,58 @@ local function add_global_stats(frame) local t = frame.add {type = 'table', column_count = 6} - local l = t.add {type = 'label', caption = 'Rockets: '} - l.style.font = 'default-game' - l.style.font_color = {r = 175, g = 75, b = 255} - l.style.minimal_width = 100 + local rocket_label = t.add {type = 'label', caption = 'Rockets: '} + rocket_label.style.font = 'default-game' + rocket_label.style.font_color = {r = 175, g = 75, b = 255} + rocket_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = score.rockets_launched} - l.style.font = 'heading-2' - l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} - l.style.minimal_width = 100 + local launched_rockets_label = t.add {type = 'label', caption = score.rockets_launched} + launched_rockets_label.style.font = 'heading-2' + launched_rockets_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} + launched_rockets_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = 'Dead bugs: '} - l.style.font = 'default-game' - l.style.font_color = {r = 0.90, g = 0.3, b = 0.3} - l.style.minimal_width = 100 + local dead_bugs_label = t.add {type = 'label', caption = 'Dead bugs: '} + dead_bugs_label.style.font = 'default-game' + dead_bugs_label.style.font_color = {r = 0.90, g = 0.3, b = 0.3} + dead_bugs_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = score.biters_killed} - l.style.font = 'heading-2' - l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} - l.style.minimal_width = 100 + local biters_killed_label = t.add {type = 'label', caption = score.biters_killed} + biters_killed_label.style.font = 'heading-2' + biters_killed_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} + biters_killed_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = 'Breached zones: '} - l.style.font = 'default-game' - l.style.font_color = {r = 0, g = 128, b = 0} - l.style.minimal_width = 100 + local breached_zones_label = t.add {type = 'label', caption = 'Breached zones: '} + breached_zones_label.style.font = 'default-game' + breached_zones_label.style.font_color = {r = 0, g = 128, b = 0} + breached_zones_label.style.minimal_width = 100 local zone = score.breached_zone - 1 if score.breached_zone == 0 then zone = 0 end - local l = t.add {type = 'label', caption = zone} - l.style.font = 'heading-2' - l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} - l.style.minimal_width = 100 + local zone_label = t.add {type = 'label', caption = zone} + zone_label.style.font = 'heading-2' + zone_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} + zone_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = 'Highest wave: '} - l.style.font = 'default-game' - l.style.font_color = {r = 128, g = 128, b = 0.9} - l.style.minimal_width = 100 + local highest_wave_label = t.add {type = 'label', caption = 'Highest wave: '} + highest_wave_label.style.font = 'default-game' + highest_wave_label.style.font_color = {r = 128, g = 128, b = 0.9} + highest_wave_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = score.wave_number} - l.style.font = 'heading-2' - l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} - l.style.minimal_width = 100 + local wave_number_label = t.add {type = 'label', caption = score.wave_number} + wave_number_label.style.font = 'heading-2' + wave_number_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} + wave_number_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = 'Last run total time: '} - l.style.font = 'default-game' - l.style.font_color = {r = 0.9, g = 128, b = 128} - l.style.minimal_width = 100 + local last_total_label = t.add {type = 'label', caption = 'Last run total time: '} + last_total_label.style.font = 'default-game' + last_total_label.style.font_color = {r = 0.9, g = 128, b = 128} + last_total_label.style.minimal_width = 100 - local l = t.add {type = 'label', caption = Core.format_time(score.total_time)} - l.style.font = 'heading-2' - l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} - l.style.minimal_width = 100 + local format_time_label = t.add {type = 'label', caption = Core.format_time(score.total_time)} + format_time_label.style.font = 'heading-2' + format_time_label.style.font_color = {r = 0.9, g = 0.9, b = 0.9} + format_time_label.style.minimal_width = 100 end local show_score = (function(player, frame) @@ -560,7 +560,7 @@ local show_score = (function(player, frame) } ) scroll_pane.style.maximal_height = 400 - local t = scroll_pane.add {type = 'table', column_count = 5} + t = scroll_pane.add {type = 'table', column_count = 5} -- Score entries for _, entry in pairs(score_list) do @@ -585,7 +585,7 @@ local show_score = (function(player, frame) local b = entry.built_entities > 0 and entry.built_entities or 'Not MVP' local m = entry.mined_entities > 0 and entry.mined_entities or 'Not MVP' - local line = { + line = { {caption = entry.name, color = special_color}, {caption = tostring(k)}, {caption = tostring(d)}, diff --git a/maps/mountain_race/main.lua b/maps/mountain_race/main.lua index b245c230..e5a9488d 100644 --- a/maps/mountain_race/main.lua +++ b/maps/mountain_race/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore require 'modules.biters_yield_ore' require 'modules.rocks_yield_ore_veins' diff --git a/maps/mountain_race/team.lua b/maps/mountain_race/team.lua index 381cda92..29bb4c5f 100644 --- a/maps/mountain_race/team.lua +++ b/maps/mountain_race/team.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local math_random = math.random diff --git a/maps/mountain_race/terrain.lua b/maps/mountain_race/terrain.lua index 7465b91f..551ea830 100644 --- a/maps/mountain_race/terrain.lua +++ b/maps/mountain_race/terrain.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local math_random = math.random local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main' diff --git a/maps/native_war/gui.lua b/maps/native_war/gui.lua index e6b82a3f..5607ef2c 100644 --- a/maps/native_war/gui.lua +++ b/maps/native_war/gui.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local Team = require 'maps.native_war.team' local XP = require 'maps.native_war.xp' diff --git a/maps/native_war/init.lua b/maps/native_war/init.lua index 2bfbada9..3ffd6acf 100644 --- a/maps/native_war/init.lua +++ b/maps/native_war/init.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} function Public.settings() diff --git a/maps/native_war/main.lua b/maps/native_war/main.lua index 699a8f38..0646f6a4 100644 --- a/maps/native_war/main.lua +++ b/maps/native_war/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore require 'modules.biter_reanimator' require 'maps.native_war.share_chat' require 'maps.native_war.mineable_wreckage_yields_scrap' diff --git a/maps/native_war/map_info.lua b/maps/native_war/map_info.lua index bc371938..d8446760 100644 --- a/maps/native_war/map_info.lua +++ b/maps/native_war/map_info.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local function create_map_intro_button(player) diff --git a/maps/native_war/mineable_wreckage_yields_scrap.lua b/maps/native_war/mineable_wreckage_yields_scrap.lua index b599b990..cf184cbb 100644 --- a/maps/native_war/mineable_wreckage_yields_scrap.lua +++ b/maps/native_war/mineable_wreckage_yields_scrap.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --mineable-wreckage yields scrap -- by mewmew local mining_chance_weights = { diff --git a/maps/native_war/share_chat.lua b/maps/native_war/share_chat.lua index 7aa79af8..35776291 100644 --- a/maps/native_war/share_chat.lua +++ b/maps/native_war/share_chat.lua @@ -1,3 +1,4 @@ +--luacheck: ignore ----------share chat with spectator force------------------- local function on_console_chat(event) if not event.message then diff --git a/maps/native_war/team.lua b/maps/native_war/team.lua index ca8fe189..11e4df5d 100644 --- a/maps/native_war/team.lua +++ b/maps/native_war/team.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local math_random = math.random diff --git a/maps/native_war/team_manager.lua b/maps/native_war/team_manager.lua index 632e845a..c5fe442b 100644 --- a/maps/native_war/team_manager.lua +++ b/maps/native_war/team_manager.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local wait_messages = { diff --git a/maps/native_war/terrain.lua b/maps/native_war/terrain.lua index 6714b7dd..cbef8c86 100644 --- a/maps/native_war/terrain.lua +++ b/maps/native_war/terrain.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local math_abs = math.abs local math_random = math.random local Map_functions = require 'tools.map_functions' diff --git a/maps/native_war/xp.lua b/maps/native_war/xp.lua index e5395084..1632b728 100644 --- a/maps/native_war/xp.lua +++ b/maps/native_war/xp.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local math_random = math.random local Global = require 'utils.global' local visuals_delay = 1800 diff --git a/maps/nightfall.lua b/maps/nightfall.lua index 0f21f3ad..e1b3957f 100644 --- a/maps/nightfall.lua +++ b/maps/nightfall.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- nightfall -- by mewmew -- local event = require 'utils.event' diff --git a/maps/nightfall_map_intro.lua b/maps/nightfall_map_intro.lua index f486df68..9dd6e693 100644 --- a/maps/nightfall_map_intro.lua +++ b/maps/nightfall_map_intro.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local main_caption = ' --Nightfall-- ' diff --git a/maps/overgrowth.lua b/maps/overgrowth.lua index aa70f166..01a3518e 100644 --- a/maps/overgrowth.lua +++ b/maps/overgrowth.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --overgrowth-- by mewmew -- require 'modules.dynamic_landfill' diff --git a/maps/overgrowth_map_info.lua b/maps/overgrowth_map_info.lua index e8ec24a6..348f145f 100644 --- a/maps/overgrowth_map_info.lua +++ b/maps/overgrowth_map_info.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local info = diff --git a/maps/pitch_black/difficulty.lua b/maps/pitch_black/difficulty.lua index b01d6913..b7bbfd80 100644 --- a/maps/pitch_black/difficulty.lua +++ b/maps/pitch_black/difficulty.lua @@ -1,7 +1,5 @@ local Public = {} -local math_abs = math.abs - local score_values = { ['small-spitter'] = 1, ['small-biter'] = 1, @@ -19,7 +17,7 @@ local score_values = { ['spitter-spawner'] = 16 } -function Public.set_daytime_difficulty(surface, tick) +function Public.set_daytime_difficulty(surface) local daytime = surface.daytime if daytime < 0.30 then surface.peaceful_mode = true diff --git a/maps/pitch_black/gui.lua b/maps/pitch_black/gui.lua index ae5d7b0a..2c3d5c4b 100644 --- a/maps/pitch_black/gui.lua +++ b/maps/pitch_black/gui.lua @@ -17,7 +17,7 @@ local function create_score_gui(player) element.style.minimal_width = 56 element.tooltip = tooltip - local element = t.add({type = 'label', caption = 0}) + element = t.add({type = 'label', caption = 0}) element.style.font = 'heading-1' element.style.font_color = {100, 0, 255} element.style.horizontal_align = 'left' diff --git a/maps/planet_prison/mod/common.lua b/maps/planet_prison/mod/common.lua index 377f2063..88768d99 100644 --- a/maps/planet_prison/mod/common.lua +++ b/maps/planet_prison/mod/common.lua @@ -526,8 +526,8 @@ Public.get_convex_hull = function(_vertices) vertices[3] } local point - for i = 4, #vertices do - point = vertices[i] + for ii = 4, #vertices do + point = vertices[ii] while #stack > 1 and convex_hull_turn(point, rev(stack, 1), rev(stack)) >= 0 do remove(stack) diff --git a/maps/quarters.lua b/maps/quarters.lua index b359b885..b7b26296 100644 --- a/maps/quarters.lua +++ b/maps/quarters.lua @@ -1,3 +1,4 @@ +--luacheck: ignore require 'modules.mineable_wreckage_yields_scrap' require 'modules.wave_defense.main' local Map = require 'modules.map_info' diff --git a/maps/railway_troopers/main.lua b/maps/railway_troopers/main.lua index a610a3c5..485d3bfc 100644 --- a/maps/railway_troopers/main.lua +++ b/maps/railway_troopers/main.lua @@ -5,9 +5,6 @@ require 'modules.biters_yield_ore' local math_random = math.random local math_floor = math.floor local table_insert = table.insert -local table_remove = table.remove -local math_sqrt = math.sqrt -local math_round = math.round local math_abs = math.abs local map_height = 96 @@ -149,7 +146,7 @@ local function draw_east_side(surface, left_top) entity.get_inventory(defines.inventory.cargo_wagon).insert({name = 'grenade', count = 32}) entity.get_inventory(defines.inventory.cargo_wagon).insert({name = 'pistol', count = 10}) entity.get_inventory(defines.inventory.cargo_wagon).insert({name = 'rail', count = 100}) - local entity = surface.create_entity({name = 'locomotive', position = {-18, 0}, force = 'player', direction = 2}) + entity = surface.create_entity({name = 'locomotive', position = {-18, 0}, force = 'player', direction = 2}) entity.get_inventory(defines.inventory.fuel).insert({name = 'wood', count = 25}) end end diff --git a/maps/railway_troopers_v2/main.lua b/maps/railway_troopers_v2/main.lua index 25f48958..fd6ff5b7 100644 --- a/maps/railway_troopers_v2/main.lua +++ b/maps/railway_troopers_v2/main.lua @@ -20,10 +20,6 @@ local map_height = 64 local math_random = math.random local math_floor = math.floor -local table_insert = table.insert -local table_remove = table.remove -local math_sqrt = math.sqrt -local math_round = math.round local math_abs = math.abs local function place_spawn_entities(surface) @@ -42,7 +38,7 @@ local function place_spawn_entities(surface) entity.get_inventory(defines.inventory.cargo_wagon).insert({name = 'rail', count = 200}) Immersive_cargo_wagons.register_wagon(entity) - local entity = surface.create_entity({name = 'locomotive', position = {-18, 0}, force = 'player', direction = 2}) + entity = surface.create_entity({name = 'locomotive', position = {-18, 0}, force = 'player', direction = 2}) entity.get_inventory(defines.inventory.fuel).insert({name = 'wood', count = 25}) Immersive_cargo_wagons.register_wagon(entity) end @@ -52,7 +48,6 @@ local function treasure_chest(surface, position) budget = budget * math_random(25, 175) * 0.01 if math_random(1, 200) == 1 then budget = budget * 10 - container_name = 'crash-site-chest-' .. math_random(1, 2) end budget = math_floor(budget) + 1 @@ -64,8 +59,6 @@ local function treasure_chest(surface, position) container.minable = false end -local infini_ores = {'iron-ore', 'iron-ore', 'copper-ore', 'coal', 'stone'} - local function on_player_joined_game(event) local surface = game.surfaces['railway_troopers'] local player = game.players[event.player_index] @@ -289,7 +282,7 @@ local function on_init() surface.delete_chunk({chunk.x, chunk.y}) end - local map_gen_settings = { + local new_map_gen_settings = { ['water'] = 0.50, ['starting_area'] = 0.60, terrain_segmentation = 20, @@ -305,7 +298,7 @@ local function on_init() ['enemy-base'] = {frequency = 256, size = 2, richness = 1} } } - game.create_surface('railway_troopers', map_gen_settings) + game.create_surface('railway_troopers', new_map_gen_settings) global.reset_railway_troopers = 2 @@ -317,6 +310,5 @@ Event.on_init(on_init) Event.add(defines.events.on_tick, on_tick) Event.add(defines.events.on_research_finished, on_research_finished) Event.add(defines.events.on_entity_died, on_entity_died) -Event.add(defines.events.on_entity_spawned, on_entity_spawned) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_chunk_generated, on_chunk_generated) diff --git a/maps/rainbow_road.lua b/maps/rainbow_road.lua index 7e0d984b..d54e0c9e 100644 --- a/maps/rainbow_road.lua +++ b/maps/rainbow_road.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local simplex_noise = require 'utils.simplex_noise'.d2 local rainbow_colors = require 'tools.rainbow_colors' diff --git a/maps/refactor-io.lua b/maps/refactor-io.lua index 660764af..1e22f904 100644 --- a/maps/refactor-io.lua +++ b/maps/refactor-io.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- Refactor-io -- made by mewmew and p.p require 'modules.satellite_score' diff --git a/maps/rivers.lua b/maps/rivers.lua index 8fa8820e..ee6ced38 100644 --- a/maps/rivers.lua +++ b/maps/rivers.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --rivers-- mewmew made this -- require 'modules.satellite_score' diff --git a/maps/rocky_waste.lua b/maps/rocky_waste.lua index 438f1218..724800e3 100644 --- a/maps/rocky_waste.lua +++ b/maps/rocky_waste.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local simplex_noise = require 'utils.simplex_noise'.d2 require 'modules.satellite_score' diff --git a/maps/spaghettorio.lua b/maps/spaghettorio.lua index 9255298e..746b8557 100644 --- a/maps/spaghettorio.lua +++ b/maps/spaghettorio.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --spaghettorio-- mewmew made this -- inspired by redlabel local simplex_noise = require 'utils.simplex_noise' diff --git a/maps/spiral_troopers.lua b/maps/spiral_troopers.lua index 6efbdc29..a5d062b2 100644 --- a/maps/spiral_troopers.lua +++ b/maps/spiral_troopers.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --spiral troopers-- mewmew wrote this -- inspired from kyte local event = require 'utils.event' diff --git a/maps/spooky_forest.lua b/maps/spooky_forest.lua index 9980088d..46174b2e 100644 --- a/maps/spooky_forest.lua +++ b/maps/spooky_forest.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- spooky forest -- by mewmew -- require 'modules.trees_randomly_die' diff --git a/maps/stone_maze/1x1_rooms.lua b/maps/stone_maze/1x1_rooms.lua index 46b8726c..542c4f72 100644 --- a/maps/stone_maze/1x1_rooms.lua +++ b/maps/stone_maze/1x1_rooms.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Basic_markets = require 'functions.basic_markets' local Biter_pets = require 'modules.biter_pets' local get_noise = require 'maps.stone_maze.noise' diff --git a/maps/stone_maze/2x2_rooms.lua b/maps/stone_maze/2x2_rooms.lua index 9fd9e3ce..420631d1 100644 --- a/maps/stone_maze/2x2_rooms.lua +++ b/maps/stone_maze/2x2_rooms.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Basic_markets = require 'functions.basic_markets' local get_noise = require 'maps.stone_maze.noise' diff --git a/maps/stone_maze/3x3_rooms.lua b/maps/stone_maze/3x3_rooms.lua index 2c24d5ed..e9ab5118 100644 --- a/maps/stone_maze/3x3_rooms.lua +++ b/maps/stone_maze/3x3_rooms.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local room = {} room.empty = function(surface, cell_left_top, direction) diff --git a/maps/stone_maze/global_functions.lua b/maps/stone_maze/global_functions.lua index 6697afbb..4f298efe 100644 --- a/maps/stone_maze/global_functions.lua +++ b/maps/stone_maze/global_functions.lua @@ -1,3 +1,4 @@ +--luacheck: ignore function get_biter() local max_chance = 0 for i = 1, 4, 1 do diff --git a/maps/stone_maze/main.lua b/maps/stone_maze/main.lua index 2a8ac1c4..184f4bd4 100644 --- a/maps/stone_maze/main.lua +++ b/maps/stone_maze/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --optionals require 'modules.satellite_score' require 'modules.dangerous_goods' diff --git a/maps/stoneblock.lua b/maps/stoneblock.lua index ad7b950f..84088b40 100644 --- a/maps/stoneblock.lua +++ b/maps/stoneblock.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- digging thingie -- by mewmew -- require 'modules.satellite_score' diff --git a/maps/tank_battles.lua b/maps/tank_battles.lua index 016045ff..c6488ab6 100644 --- a/maps/tank_battles.lua +++ b/maps/tank_battles.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --tank battles (royale)-- mewmew made this -- local event = require 'utils.event' diff --git a/maps/tank_battles_old.lua b/maps/tank_battles_old.lua index 8c69c1f5..c62a4c3e 100644 --- a/maps/tank_battles_old.lua +++ b/maps/tank_battles_old.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --tank battles (royale)-- mewmew made this -- local event = require 'utils.event' diff --git a/maps/tank_conquest/tank_conquest.lua b/maps/tank_conquest/tank_conquest.lua index 9b4d51ba..6a14b259 100644 --- a/maps/tank_conquest/tank_conquest.lua +++ b/maps/tank_conquest/tank_conquest.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- factorio scenario -- tank conquest -- xalpha made this -- local blueprint_poi_base_json = require 'maps.tank_conquest.blueprint_poi_base_json' diff --git a/maps/territorial_control.lua b/maps/territorial_control.lua index 3eb21d8b..f2cb7588 100644 --- a/maps/territorial_control.lua +++ b/maps/territorial_control.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- territorial control by Gerkiz local Map = require 'modules.map_info' diff --git a/maps/tetris/main.lua b/maps/tetris/main.lua index 81b3146d..c9f1aca5 100644 --- a/maps/tetris/main.lua +++ b/maps/tetris/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --tetris by mewmew --18x10 gb diff --git a/maps/tetris/unused.lua b/maps/tetris/unused.lua index 5980f865..41f07631 100644 --- a/maps/tetris/unused.lua +++ b/maps/tetris/unused.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local function is_position_inside_playfield(position) if position.x > playfield_area.right_bottom.x then return false diff --git a/maps/wave_defense.lua b/maps/wave_defense.lua index 585d8598..9c5f2fe1 100644 --- a/maps/wave_defense.lua +++ b/maps/wave_defense.lua @@ -25,7 +25,7 @@ local function on_player_joined_game(event) end end -local function on_player_left_game(event) +local function on_player_left_game() set_difficulty() end diff --git a/maps/wave_of_death/WoD.lua b/maps/wave_of_death/WoD.lua index 2175441e..aae62ebf 100644 --- a/maps/wave_of_death/WoD.lua +++ b/maps/wave_of_death/WoD.lua @@ -1,3 +1,4 @@ +--luacheck: ignore -- Map by Kyte & MewMew require 'maps.wave_of_death.intro' diff --git a/maps/wave_of_death/ai.lua b/maps/wave_of_death/ai.lua index b678b789..1fa9f28e 100644 --- a/maps/wave_of_death/ai.lua +++ b/maps/wave_of_death/ai.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local biter_waves = require 'maps.wave_of_death.biter_waves' local ai = {} diff --git a/maps/wave_of_death/game_status.lua b/maps/wave_of_death/game_status.lua index e9054918..9491d106 100644 --- a/maps/wave_of_death/game_status.lua +++ b/maps/wave_of_death/game_status.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local game_status = {} local Server = require 'utils.server' diff --git a/maps/wave_of_death/init.lua b/maps/wave_of_death/init.lua index 83506810..2e4bb587 100644 --- a/maps/wave_of_death/init.lua +++ b/maps/wave_of_death/init.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local function init_surface() local map_gen_settings = {} map_gen_settings.water = '0' diff --git a/maps/wave_of_death/intro.lua b/maps/wave_of_death/intro.lua index 4e881998..2fea1cb8 100644 --- a/maps/wave_of_death/intro.lua +++ b/maps/wave_of_death/intro.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local info = diff --git a/maps/wave_of_death/spectate.lua b/maps/wave_of_death/spectate.lua index 250c3bb8..651872d0 100644 --- a/maps/wave_of_death/spectate.lua +++ b/maps/wave_of_death/spectate.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local function spectate_button() end diff --git a/maps/wave_of_death/terrain.lua b/maps/wave_of_death/terrain.lua index 17e88cea..8bfaebe9 100644 --- a/maps/wave_of_death/terrain.lua +++ b/maps/wave_of_death/terrain.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local simplex_noise = require 'utils.simplex_noise'.d2 local math_random = math.random local wod_logo_tiles = require 'maps.wave_of_death.logo' diff --git a/modules/admins_operate_biters.lua b/modules/admins_operate_biters.lua index cb2a3e97..ce1fc459 100644 --- a/modules/admins_operate_biters.lua +++ b/modules/admins_operate_biters.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local math_random = math.random local math_floor = math.floor diff --git a/modules/area_unlocked_on_rotated_entity.lua b/modules/area_unlocked_on_rotated_entity.lua index 8a0802c2..de968326 100644 --- a/modules/area_unlocked_on_rotated_entity.lua +++ b/modules/area_unlocked_on_rotated_entity.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --unlocks areas when the entity at the position is rotated --define the entities by position like this: -- global.level_unlocks = { diff --git a/modules/autodecon_when_depleted.lua b/modules/autodecon_when_depleted.lua index a2b10dae..c4ec773c 100644 --- a/modules/autodecon_when_depleted.lua +++ b/modules/autodecon_when_depleted.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local function is_depleted(drill, entity) local position = drill.position diff --git a/modules/autohotbar.lua b/modules/autohotbar.lua index 3317914b..d58ac4d8 100644 --- a/modules/autohotbar.lua +++ b/modules/autohotbar.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local event = require 'utils.event' local function get_empty_hotbar_slot(player) diff --git a/modules/backpack_research.lua b/modules/backpack_research.lua index 8dc06363..d16c08a6 100644 --- a/modules/backpack_research.lua +++ b/modules/backpack_research.lua @@ -1,9 +1,9 @@ -- backpack research -- researching mining efficiency increases your backpack capacity (inventory slots) -local event = require 'utils.event' +local Event = require 'utils.event' local function on_research_finished(event) event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 100 end -event.add(defines.events.on_research_finished, on_research_finished) +Event.add(defines.events.on_research_finished, on_research_finished) diff --git a/modules/ban_drop.lua b/modules/ban_drop.lua index afef2bcb..186061e7 100644 --- a/modules/ban_drop.lua +++ b/modules/ban_drop.lua @@ -22,7 +22,6 @@ end local function on_player_banned(event) local player = game.players[event.player_index] - local position = player.position drop_inventory(player, player.get_inventory(defines.inventory.character_main)) drop_inventory(player, player.get_inventory(defines.inventory.character_guns)) drop_inventory(player, player.get_inventory(defines.inventory.character_ammo)) diff --git a/modules/biter_evasion_hp_increaser.lua b/modules/biter_evasion_hp_increaser.lua index e4ff6871..55b39597 100644 --- a/modules/biter_evasion_hp_increaser.lua +++ b/modules/biter_evasion_hp_increaser.lua @@ -1,7 +1,7 @@ -- biters and their buildings gain pseudo hp increase through the means of evasion mechanics -- by mewmew -- use global.biter_evasion_health_increase_factor to modify their health -local event = require 'utils.event' +local Event = require 'utils.event' local random_max = 1000000 local types = { ['unit'] = true, @@ -36,5 +36,5 @@ local function on_init() global.biter_evasion_health_increase_factor = 1 end -event.on_init(on_init) -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.on_init(on_init) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/biter_health_booster.lua b/modules/biter_health_booster.lua index 6e973bce..eb8e39e0 100644 --- a/modules/biter_health_booster.lua +++ b/modules/biter_health_booster.lua @@ -26,7 +26,7 @@ local function clean_table() local units_to_delete = {} --Mark all health boost entries for deletion - for key, health in pairs(global.biter_health_boost_units) do + for key, _ in pairs(global.biter_health_boost_units) do units_to_delete[key] = true end diff --git a/modules/biter_noms_you.lua b/modules/biter_noms_you.lua index c8cc7617..f31d75f2 100644 --- a/modules/biter_noms_you.lua +++ b/modules/biter_noms_you.lua @@ -1,6 +1,6 @@ --biters make comic like text sounds when they damage something -- mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local strings = { @@ -69,4 +69,4 @@ local function on_entity_damaged(event) end end -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/biter_pets.lua b/modules/biter_pets.lua index 4b27581d..3b7d4155 100644 --- a/modules/biter_pets.lua +++ b/modules/biter_pets.lua @@ -17,7 +17,7 @@ end local function floaty_hearts(entity, c) local position = {x = entity.position.x - 0.75, y = entity.position.y - 1} local b = 1.35 - for a = 1, c, 1 do + for _ = 1, c, 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) @@ -117,12 +117,11 @@ function Public.tame_unit_for_closest_player(unit) return end - for i = 2, #valid_players, 1 do - local player = valid_players[i + 1] - if player.position.x ^ 2 + player.position.y ^ 2 < nearest_player.position.x ^ 2 + nearest_player.position.y ^ 2 then - nearest_player = spawner - end - end + -- for i = 2, #valid_players, 1 do + -- local player = valid_players[i + 1] + -- if player.position.x ^ 2 + player.position.y ^ 2 < nearest_player.position.x ^ 2 + nearest_player.position.y ^ 2 then + -- end + -- end Public.biter_pets_tame_unit(nearest_player, unit, true) end @@ -189,13 +188,13 @@ local function on_player_dropped_item(event) end end -local function on_init(event) +local function on_init() global.biter_pets = {} end -local event = require 'utils.event' -event.on_init(on_init) -event.add(defines.events.on_player_dropped_item, on_player_dropped_item) -event.add(defines.events.on_player_changed_position, on_player_changed_position) +local Event = require 'utils.event' +Event.on_init(on_init) +Event.add(defines.events.on_player_dropped_item, on_player_dropped_item) +Event.add(defines.events.on_player_changed_position, on_player_changed_position) return Public diff --git a/modules/biter_player_count_difficulty.lua b/modules/biter_player_count_difficulty.lua index 29ebd160..d9e94d24 100644 --- a/modules/biter_player_count_difficulty.lua +++ b/modules/biter_player_count_difficulty.lua @@ -1,6 +1,6 @@ -- biters gain strength scaling with player amount in the game -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local function refresh_difficulty() global.connected_players = #game.connected_players @@ -34,14 +34,14 @@ local function on_entity_damaged(event) event.entity.health = event.entity.health + event.final_damage_amount end -local function on_player_joined_game(event) +local function on_player_joined_game() refresh_difficulty() end -local function on_player_left_game(event) +local function on_player_left_game() refresh_difficulty() end -event.add(defines.events.on_player_left_game, on_player_left_game) -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_player_left_game, on_player_left_game) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/biters_attack_moving_players.lua b/modules/biters_attack_moving_players.lua index 1d743054..5a926864 100644 --- a/modules/biters_attack_moving_players.lua +++ b/modules/biters_attack_moving_players.lua @@ -1,6 +1,6 @@ --moving players attract biters from far away -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local function on_player_changed_position(event) @@ -34,9 +34,9 @@ local function on_player_changed_position(event) global.biters_attack_moving_players_last_action_tick = game.tick end -local function on_init(event) +local function on_init() global.biters_attack_moving_players_last_action_tick = 0 end -event.add(defines.events.on_player_changed_position, on_player_changed_position) -event.on_init(on_init) +Event.add(defines.events.on_player_changed_position, on_player_changed_position) +Event.on_init(on_init) diff --git a/modules/biters_avoid_damage.lua b/modules/biters_avoid_damage.lua index 5c40c89b..be4d5005 100644 --- a/modules/biters_avoid_damage.lua +++ b/modules/biters_avoid_damage.lua @@ -1,6 +1,6 @@ -- enemy biters have pseudo double hp -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local function on_entity_damaged(event) if not event.entity.valid then @@ -18,4 +18,4 @@ local function on_entity_damaged(event) event.entity.health = event.entity.health + event.final_damage_amount end -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/biters_double_damage.lua b/modules/biters_double_damage.lua index 3050224b..ad6921e3 100644 --- a/modules/biters_double_damage.lua +++ b/modules/biters_double_damage.lua @@ -1,6 +1,6 @@ -local event = require 'utils.event' +local Event = require 'utils.event' -local function on_player_joined_game(event) +local function on_player_joined_game() game.forces.enemy.set_ammo_damage_modifier('melee', 1) game.forces.enemy.set_ammo_damage_modifier('biological', 1) game.forces.enemy.set_ammo_damage_modifier('artillery-shell', 0.5) @@ -8,4 +8,4 @@ local function on_player_joined_game(event) game.forces.enemy.set_ammo_damage_modifier('laser-turret', 0.5) end -event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/modules/burden.lua b/modules/burden.lua index d2af16fd..5927b84f 100644 --- a/modules/burden.lua +++ b/modules/burden.lua @@ -54,11 +54,11 @@ local function check_burden(event) end end -local function on_init(event) +local function on_init() script.on_event(defines.events.on_player_main_inventory_changed, check_burden) end -local function on_load(event) +local function on_load() script.on_event(defines.events.on_player_main_inventory_changed, check_burden) end diff --git a/modules/charging_station.lua b/modules/charging_station.lua index 284485e5..23e4324d 100644 --- a/modules/charging_station.lua +++ b/modules/charging_station.lua @@ -71,7 +71,7 @@ local function charge(player) end end -local function on_player_joined_game(event) +local function on_player_joined_game() draw_charging_gui() end diff --git a/modules/comfylatron.lua b/modules/comfylatron.lua index dc1d8ec5..813f6201 100644 --- a/modules/comfylatron.lua +++ b/modules/comfylatron.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local function shuffle(tbl) @@ -508,5 +508,5 @@ local function on_tick() end end -event.add(defines.events.on_entity_damaged, on_entity_damaged) -event.add(defines.events.on_tick, on_tick) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_tick, on_tick) diff --git a/modules/custom_death_messages.lua b/modules/custom_death_messages.lua index 3032c2ba..a682797f 100644 --- a/modules/custom_death_messages.lua +++ b/modules/custom_death_messages.lua @@ -1,7 +1,6 @@ -- prints death messages to all forces with custom texts -- by mewmew -local event = require 'utils.event' -local math_random = math.random +local Event = require 'utils.event' local message_color = {r = 0.9, g = 0.9, b = 0.9} local messages = { @@ -76,4 +75,4 @@ local function on_player_died(event) end end -event.add(defines.events.on_player_died, on_player_died) +Event.add(defines.events.on_player_died, on_player_died) diff --git a/modules/dangerous_nights.lua b/modules/dangerous_nights.lua index 6166b74f..60c131d5 100644 --- a/modules/dangerous_nights.lua +++ b/modules/dangerous_nights.lua @@ -1,6 +1,6 @@ -- nighttime is dangerous, stay near your lamps -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local unearthing_worm = require 'functions.unearthing_worm' local unearthing_biters = require 'functions.unearthing_biters' @@ -74,4 +74,4 @@ local function on_player_changed_position(event) end end -event.add(defines.events.on_player_changed_position, on_player_changed_position) +Event.add(defines.events.on_player_changed_position, on_player_changed_position) diff --git a/modules/difficulty_vote.lua b/modules/difficulty_vote.lua index 1b8b1600..376cff0b 100644 --- a/modules/difficulty_vote.lua +++ b/modules/difficulty_vote.lua @@ -171,7 +171,7 @@ local function poll_difficulty(player) b.visible = false end end - local b = frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) + frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) local b = frame.add( { diff --git a/modules/difficulty_vote_by_amount.lua b/modules/difficulty_vote_by_amount.lua index 991f458c..b54eabaf 100644 --- a/modules/difficulty_vote_by_amount.lua +++ b/modules/difficulty_vote_by_amount.lua @@ -162,7 +162,7 @@ local function poll_difficulty(player) b.style.minimal_width = 160 b.tooltip = this.tooltip[i] end - local b = frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) + frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) local b = frame.add( { diff --git a/modules/dynamic_landfill.lua b/modules/dynamic_landfill.lua index 17328526..38ea0771 100644 --- a/modules/dynamic_landfill.lua +++ b/modules/dynamic_landfill.lua @@ -1,7 +1,7 @@ -- changes placed landfill tiles, adapting the new tile to adjecant tiles -- by mewmew -local regenerate_decoratives = true -local event = require 'utils.event' +local regenerate_decoratives_value = true +local Event = require 'utils.event' local math_random = math.random local table_insert = table.insert local water_tile_whitelist = { @@ -103,7 +103,7 @@ local function on_player_built_tile(event) for _, placed_tile in pairs(event.tiles) do if water_tile_whitelist[placed_tile.old_tile.name] then place_fitting_tile(placed_tile.position, surface, event.tiles) - if regenerate_decoratives then + if regenerate_decoratives_value then if math_random(1, 5) == 1 then regenerate_decoratives(surface, placed_tile.position) end @@ -130,5 +130,5 @@ local function on_robot_built_tile(event) end end -event.add(defines.events.on_player_built_tile, on_player_built_tile) -event.add(defines.events.on_robot_built_tile, on_robot_built_tile) +Event.add(defines.events.on_player_built_tile, on_player_built_tile) +Event.add(defines.events.on_robot_built_tile, on_robot_built_tile) diff --git a/modules/dynamic_player_spawn.lua b/modules/dynamic_player_spawn.lua index 25b8252e..62a980aa 100644 --- a/modules/dynamic_player_spawn.lua +++ b/modules/dynamic_player_spawn.lua @@ -1,6 +1,6 @@ -- this automatically sets player's force spawn point to where a lot of buildings are -local event = require 'utils.event' +local Event = require 'utils.event' local valid_types = {'boiler', 'furnace', 'generator', 'offshore-pump', 'lab', 'assembling-machine'} @@ -15,4 +15,4 @@ local function on_built_entity(event) end end -event.add(defines.events.on_built_entity, on_built_entity) +Event.add(defines.events.on_built_entity, on_built_entity) diff --git a/modules/evolution_extended.lua b/modules/evolution_extended.lua index a203688d..1d7b0200 100644 --- a/modules/evolution_extended.lua +++ b/modules/evolution_extended.lua @@ -2,7 +2,7 @@ require 'modules.biter_evasion_hp_increaser' -local event = require 'utils.event' +local Event = require 'utils.event' local simplex_noise = require 'utils.simplex_noise'.d2 local gui_refreshrate = 900 @@ -91,15 +91,14 @@ local function tick() global.color_counter = global.color_counter + 1 end -local function on_init(event) +local function on_init() global.evolution_factor = 0 global.color_counter = 0 - local hours_to_max_evo = 24 local ticks_to_max_evo = 12 * 60 * 60 * 60 global.tick_gain = math.round((1 / ticks_to_max_evo) * gui_refreshrate, 8) end -event.add(defines.events.on_entity_died, on_entity_died) -event.on_nth_tick(gui_refreshrate, tick) -event.on_init(on_init) +Event.add(defines.events.on_entity_died, on_entity_died) +Event.on_nth_tick(gui_refreshrate, tick) +Event.on_init(on_init) diff --git a/modules/explosive_biters.lua b/modules/explosive_biters.lua index f436feb1..6578208d 100644 --- a/modules/explosive_biters.lua +++ b/modules/explosive_biters.lua @@ -1,6 +1,6 @@ -- biters explode -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local biter_values = { ['medium-biter'] = {'blood-explosion-big', 20, 1.5}, @@ -42,4 +42,4 @@ local function on_entity_died(event) end end -event.add(defines.events.on_entity_died, on_entity_died) +Event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/explosive_player_respawn.lua b/modules/explosive_player_respawn.lua index 847b33b2..678c4d35 100644 --- a/modules/explosive_player_respawn.lua +++ b/modules/explosive_player_respawn.lua @@ -1,5 +1,5 @@ -- clear the player respawn from enemies with a kaboom -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local function damage_entities_in_radius(surface, position, radius) local entities_to_damage = surface.find_entities_filtered({area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}}) @@ -17,4 +17,4 @@ local function on_player_respawned(event) damage_entities_in_radius(player.surface, player.position, 11) end -event.add(defines.events.on_player_respawned, on_player_respawned) +Event.add(defines.events.on_player_respawned, on_player_respawned) diff --git a/modules/explosives_2.lua b/modules/explosives_2.lua index 08e14bfc..af657beb 100644 --- a/modules/explosives_2.lua +++ b/modules/explosives_2.lua @@ -1,7 +1,9 @@ -local Public = {} - +local Event = require 'utils.event' local Global = require 'utils.global' + +local Public = {} local explosives = {} + Global.register( explosives, function(tbl) @@ -149,7 +151,7 @@ local function process_explosion(instance) return true end -function spawn_explosion(surface, position, amount) +local function spawn_explosion(surface, position, amount) if not explosives.instances then explosives.instances = {} end @@ -219,7 +221,6 @@ local function on_init() explosives.destructible_tiles = {} end -local Event = require 'utils.event' Event.on_init(on_init) Event.on_nth_tick(speed, on_tick) Event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/explosives_are_explosive.lua b/modules/explosives_are_explosive.lua index 9f980431..f85c465a 100644 --- a/modules/explosives_are_explosive.lua +++ b/modules/explosives_are_explosive.lua @@ -1,7 +1,7 @@ --This will add a new game mechanic so that containers with explosives actually go boom when they get damaged. --Made by MewMew -local event = require 'utils.event' +local Event = require 'utils.event' local damage_per_explosive = 100 local empty_tile_damage_decay = 100 @@ -1768,14 +1768,13 @@ local function on_entity_damaged(event) end end -local function on_tick(event) +local function on_tick() if global.explosion_schedule then local tick = game.tick local explosion_schedule_is_alive = false for explosion_index = 1, #global.explosion_schedule, 1 do if #global.explosion_schedule[explosion_index] > 0 then explosion_schedule_is_alive = true - local surface = game.surfaces[global.explosion_schedule[explosion_index].surface] for radius = 1, #global.explosion_schedule[explosion_index], 1 do if global.explosion_schedule[explosion_index][radius].trigger_tick == tick then for tile_index = 1, #global.explosion_schedule[explosion_index][radius], 1 do @@ -1799,5 +1798,5 @@ local function on_tick(event) end end -event.add(defines.events.on_entity_damaged, on_entity_damaged) -event.add(defines.events.on_tick, on_tick) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_tick, on_tick) diff --git a/modules/fjei/functions.lua b/modules/fjei/functions.lua index 582676c0..bb54fd53 100644 --- a/modules/fjei/functions.lua +++ b/modules/fjei/functions.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local table_insert = table.insert local string_find = string.find diff --git a/modules/fjei/gui.lua b/modules/fjei/gui.lua index dc6e0e5a..f414b8ab 100644 --- a/modules/fjei/gui.lua +++ b/modules/fjei/gui.lua @@ -1,7 +1,7 @@ +--luacheck: ignore local Functions = require 'modules.fjei.functions' local math_ceil = math.ceil local math_abs = math.abs -local string_find = string.find local table_remove = table.remove local table_insert = table.insert local main_window_width = 228 @@ -139,7 +139,7 @@ local function add_choose_elem_button(element, name, is_recipe) end local function add_sprite_icon(element, name, is_recipe, use_localised_name) - local sprite_type = false + local sprite_type if is_recipe then sprite_type = 'recipe' else diff --git a/modules/fjei/main.lua b/modules/fjei/main.lua index b762acda..ffd56536 100644 --- a/modules/fjei/main.lua +++ b/modules/fjei/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --[[ FJEI - "Factorio Just enough items" A comfy recipe browser - MewMew diff --git a/modules/flashlight_toggle_button.lua b/modules/flashlight_toggle_button.lua index 3a8c013a..276c2190 100644 --- a/modules/flashlight_toggle_button.lua +++ b/modules/flashlight_toggle_button.lua @@ -1,6 +1,6 @@ -- toggle your flashlight -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local message_color = {r = 200, g = 200, b = 0} local function on_gui_click(event) @@ -64,6 +64,6 @@ local function on_player_joined_game(event) b.style.bottom_padding = 2 end -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_player_respawned, on_player_respawned) -event.add(defines.events.on_gui_click, on_gui_click) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_player_respawned, on_player_respawned) +Event.add(defines.events.on_gui_click, on_gui_click) diff --git a/modules/floaty_chat.lua b/modules/floaty_chat.lua index 902eebac..3146ed48 100644 --- a/modules/floaty_chat.lua +++ b/modules/floaty_chat.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local function on_console_chat(event) if not event.message then @@ -53,9 +53,9 @@ local function on_console_chat(event) } end -local function on_init(event) +local function on_init() global.player_floaty_chat = {} end -event.on_init(on_init) -event.add(defines.events.on_console_chat, on_console_chat) +Event.on_init(on_init) +Event.add(defines.events.on_console_chat, on_console_chat) diff --git a/modules/fluids_are_explosive.lua b/modules/fluids_are_explosive.lua index ada65de2..34855276 100644 --- a/modules/fluids_are_explosive.lua +++ b/modules/fluids_are_explosive.lua @@ -1,7 +1,7 @@ --This will add a new game mechanic so that containers with certain fluids explode when they get damaged or are destroyed. --Made by MewMew -local event = require 'utils.event' +local Event = require 'utils.event' local empty_tile_damage_decay = 50 local out_of_map_tile_health = 1500 @@ -947,14 +947,13 @@ local function on_entity_damaged(event) end end -local function on_tick(event) +local function on_tick() if global.fluid_explosion_schedule then local tick = game.tick local explosion_schedule_is_alive = false for explosion_index = 1, #global.fluid_explosion_schedule, 1 do if #global.fluid_explosion_schedule[explosion_index] > 0 then explosion_schedule_is_alive = true - local surface = game.surfaces[global.fluid_explosion_schedule[explosion_index].surface] for radius = 1, #global.fluid_explosion_schedule[explosion_index], 1 do if global.fluid_explosion_schedule[explosion_index][radius].trigger_tick == tick then for tile_index = 1, #global.fluid_explosion_schedule[explosion_index][radius], 1 do @@ -978,5 +977,5 @@ local function on_tick(event) end end -event.add(defines.events.on_entity_damaged, on_entity_damaged) -event.add(defines.events.on_tick, on_tick) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_tick, on_tick) diff --git a/modules/force_health_booster.lua b/modules/force_health_booster.lua index a803b0e3..fd22c1ed 100644 --- a/modules/force_health_booster.lua +++ b/modules/force_health_booster.lua @@ -32,7 +32,7 @@ function Public.set_health_modifier(force_index, modifier) end function Public.reset_tables() - for k, v in pairs(fhb) do + for k, _ in pairs(fhb) do fhb[k] = nil end end diff --git a/modules/global_chat_toggle.lua b/modules/global_chat_toggle.lua index 20d9588c..94f9b388 100644 --- a/modules/global_chat_toggle.lua +++ b/modules/global_chat_toggle.lua @@ -83,7 +83,6 @@ local function on_console_chat(event) end local Event = require 'utils.event' -Event.on_init(on_init) Event.add(defines.events.on_console_chat, on_console_chat) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_gui_click, on_gui_click) diff --git a/modules/hidden_dimension/main.lua b/modules/hidden_dimension/main.lua index 3490cd2c..7bd68b92 100644 --- a/modules/hidden_dimension/main.lua +++ b/modules/hidden_dimension/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Event = require 'utils.event' local HDT = require 'modules.hidden_dimension.table' diff --git a/modules/hunger.lua b/modules/hunger.lua index 2d973c1b..425e85fa 100644 --- a/modules/hunger.lua +++ b/modules/hunger.lua @@ -2,7 +2,6 @@ require 'player_modifiers' -local math_random = math.random local P = require 'player_modifiers' local starve_messages = {' ran out of foodstamps.', ' starved.', ' should not have skipped breakfast today.'} @@ -101,7 +100,7 @@ local function update_hunger_gui(player) player.gui.top['hunger_frame'].style.font_color = player_hunger_color_list[global.player_hunger[player.name]] end -function hunger_update(player, food_value) +local function hunger_update(player, food_value) local player_modifiers = P.get_table() if not player.character then return diff --git a/modules/hunger_games.lua b/modules/hunger_games.lua index 3486e6b8..0490bb81 100644 --- a/modules/hunger_games.lua +++ b/modules/hunger_games.lua @@ -6,10 +6,9 @@ require 'modules.custom_death_messages' require 'maps.hunger_games_map_intro' require 'modules.dynamic_player_spawn' -local Score = require 'comfy_panel.score' --require "maps.modules.hunger_games_balance" -local event = require 'utils.event' +local Event = require 'utils.event' local message_color = {r = 0.98, g = 0.66, b = 0.22} local function anarchy_gui_button(player) @@ -65,7 +64,7 @@ local function anarchy_gui(player) scroll_pane.style.maximal_height = total_height - 50 scroll_pane.style.minimal_height = total_height - 50 - local t = scroll_pane.add({type = 'table', name = 'groups_table', column_count = 4}) + t = scroll_pane.add({type = 'table', name = 'groups_table', column_count = 4}) for _, h in pairs(headings) do local l = t.add({type = 'label', caption = ''}) l.style.minimal_width = h[2] @@ -82,7 +81,7 @@ local function anarchy_gui(player) l.style.font_color = group.color l.style.single_line = false - local l = t.add({type = 'label', caption = group.description}) + l = t.add({type = 'label', caption = group.description}) l.style.top_padding = 16 l.style.bottom_padding = 16 l.style.minimal_width = description_width @@ -94,7 +93,7 @@ local function anarchy_gui(player) for _, member in pairs(group.members) do local p = game.players[member] if p.connected then - local l = tt.add({type = 'label', caption = tostring(p.name)}) + l = tt.add({type = 'label', caption = tostring(p.name)}) local color = {r = p.color.r * 0.6 + 0.4, g = p.color.g * 0.6 + 0.4, b = p.color.b * 0.6 + 0.4, a = 1} l.style.font_color = color l.style.maximal_width = members_width * 2 @@ -104,24 +103,24 @@ local function anarchy_gui(player) for _, member in pairs(group.members) do local p = game.players[member] if not p.connected then - local l = tt.add({type = 'label', caption = tostring(p.name)}) + l = tt.add({type = 'label', caption = tostring(p.name)}) local color = {r = 0.59, g = 0.59, b = 0.59, a = 1} l.style.font_color = color l.style.maximal_width = members_width * 2 end end - local tt = t.add({type = 'table', name = group.name, column_count = 1}) + tt = t.add({type = 'table', name = group.name, column_count = 1}) if not group.members[player.name] then - local b = tt.add({type = 'button', caption = 'Join'}) + b = tt.add({type = 'button', caption = 'Join'}) b.style.font = 'default-bold' b.style.minimal_width = actions_width b.style.maximal_width = actions_width end if group.members[player.name] then - local b = tt.add({type = 'button', caption = 'Leave'}) + b = tt.add({type = 'button', caption = 'Leave'}) b.style.font = 'default-bold' b.style.minimal_width = actions_width b.style.maximal_width = actions_width @@ -129,12 +128,12 @@ local function anarchy_gui(player) end local frame2 = frame.add({type = 'frame', name = 'frame2'}) - local t = frame2.add({type = 'table', name = 'group_table', column_count = 3}) + t = frame2.add({type = 'table', name = 'group_table', column_count = 3}) local textfield = t.add({type = 'textfield', name = 'new_group_name', text = 'Name'}) textfield.style.minimal_width = group_name_width - local textfield = t.add({type = 'textfield', name = 'new_group_description', text = 'Description'}) + textfield = t.add({type = 'textfield', name = 'new_group_description', text = 'Description'}) textfield.style.minimal_width = description_width + members_width * member_columns - local b = t.add({type = 'button', name = 'create_new_group', caption = 'Create'}) + b = t.add({type = 'button', name = 'create_new_group', caption = 'Create'}) b.style.minimal_width = actions_width * 2 - 12 b.style.font = 'default-bold' end @@ -148,7 +147,7 @@ local function refresh_gui() anarchy_gui(p) - local frame = p.gui.left['anarchy_group_frame'] + frame = p.gui.left['anarchy_group_frame'] frame.frame2.group_table.new_group_name.text = new_group_name frame.frame2.group_table.new_group_description.text = new_group_description end @@ -270,7 +269,7 @@ local function new_group(frame, player) color = {r = color.r * 0.6 + 0.4, g = color.g * 0.6 + 0.4, b = color.b * 0.6 + 0.4, a = 1} global.alliance_groups[new_group_name] = {name = new_group_name, color = color, description = new_group_description, members = {[tostring(player.name)] = player.index}} - local color = {r = player.color.r * 0.7 + 0.3, g = player.color.g * 0.7 + 0.3, b = player.color.b * 0.7 + 0.3, a = 1} + color = {r = player.color.r * 0.7 + 0.3, g = player.color.g * 0.7 + 0.3, b = player.color.b * 0.7 + 0.3, a = 1} game.print(tostring(player.name) .. ' has founded a new group!', color) game.print('>> ' .. new_group_name, {r = 0.98, g = 0.66, b = 0.22}) game.print(new_group_description, {r = 0.85, g = 0.85, b = 0.85}) @@ -473,8 +472,7 @@ local function on_console_chat(event) end end - local color = {} - color = player.color + local color = player.color color.r = color.r * 0.6 + 0.35 color.g = color.g * 0.6 + 0.35 color.b = color.b * 0.6 + 0.35 @@ -493,7 +491,7 @@ local function on_player_respawned(event) local player = game.players[event.player_index] player.insert {name = 'iron-plate', count = 8} end - +--[[ local function on_built_entity(event) local get_score = Score.get_table().score_table local entity = event.created_entity @@ -516,11 +514,10 @@ local function on_built_entity(event) end end entity.destroy() -end - ---event.add(defines.events.on_built_entity, on_built_entity) ---event.add(defines.events.on_player_died, on_player_died) -event.add(defines.events.on_player_respawned, on_player_respawned) -event.add(defines.events.on_console_chat, on_console_chat) -event.add(defines.events.on_gui_click, on_gui_click) -event.add(defines.events.on_player_joined_game, on_player_joined_game) +end ]] +--Event.add(defines.events.on_built_entity, on_built_entity) +--Event.add(defines.events.on_player_died, on_player_died) +Event.add(defines.events.on_player_respawned, on_player_respawned) +Event.add(defines.events.on_console_chat, on_console_chat) +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/modules/hunger_games_balance.lua b/modules/hunger_games_balance.lua index defe73ee..236e4f81 100644 --- a/modules/hunger_games_balance.lua +++ b/modules/hunger_games_balance.lua @@ -1,22 +1,5 @@ --Hunger games balance things by Gerkiz -- -local event = require 'utils.event' - -local player_ammo_starting_modifiers = { - ['artillery-shell'] = -0.75, - ['biological'] = -0.5, - ['bullet'] = -0.25, - ['cannon-shell'] = -0.75, - ['capsule'] = -0.5, - ['beam'] = -0.5, - ['laser'] = -0.5, - ['electric'] = -0.5, - ['flamethrower'] = -0.75, - ['grenade'] = -0.5, - ['landmine'] = -0.33, - ['melee'] = 2, - ['rocket'] = -0.75, - ['shotgun-shell'] = -0.20 -} +local Event = require 'utils.event' local player_gun_speed_modifiers = { ['artillery-shell'] = -0.75, @@ -91,17 +74,7 @@ local enemy_ammo_evolution_modifiers = { --['shotgun-shell'] = 1 } -function init_player_weapon_damage(force) - for k, v in pairs(player_ammo_starting_modifiers) do - force.set_ammo_damage_modifier(k, v) - end - - for k, v in pairs(player_gun_speed_modifiers) do - force.set_gun_speed_modifier(k, v) - end -end - -function init_enemy_weapon_damage() +local function init_enemy_weapon_damage() local e_force = game.forces['enemy'] for k, v in pairs(enemy_ammo_starting_modifiers) do @@ -160,6 +133,6 @@ local function research_finished(event) end end -event.on_init(init_enemy_weapon_damage) -event.on_nth_tick(18000, enemy_weapon_damage) -event.add(defines.events.on_research_finished, research_finished) +Event.on_init(init_enemy_weapon_damage) +Event.on_nth_tick(18000, enemy_weapon_damage) +Event.add(defines.events.on_research_finished, research_finished) diff --git a/modules/immersive_cargo_wagons/functions.lua b/modules/immersive_cargo_wagons/functions.lua index 5afe42db..1c5f161f 100644 --- a/modules/immersive_cargo_wagons/functions.lua +++ b/modules/immersive_cargo_wagons/functions.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local Constants = require 'modules.immersive_cargo_wagons.constants' diff --git a/modules/immersive_cargo_wagons/main.lua b/modules/immersive_cargo_wagons/main.lua index b5fbe1f6..9cc6446d 100644 --- a/modules/immersive_cargo_wagons/main.lua +++ b/modules/immersive_cargo_wagons/main.lua @@ -3,8 +3,6 @@ local Event = require 'utils.event' local Functions = require 'modules.immersive_cargo_wagons.functions' local Public = {} -local math_round = math.round - local icw = {} Global.register( icw, @@ -21,7 +19,7 @@ function Public.reset() end end end - for k, v in pairs(icw) do + for k, _ in pairs(icw) do icw[k] = nil end icw.doors = {} @@ -148,7 +146,7 @@ local function on_player_died(event) Functions.kill_minimap(game.players[event.player_index]) end -local function on_train_created(event) +local function on_train_created() Functions.request_reconstruction(icw) end diff --git a/modules/landfill_reveals_nauvis.lua b/modules/landfill_reveals_nauvis.lua index b52fe750..56992798 100644 --- a/modules/landfill_reveals_nauvis.lua +++ b/modules/landfill_reveals_nauvis.lua @@ -1,10 +1,6 @@ -- placing landfill in another surface will reveal nauvis -- by mewmew -local regenerate_decoratives = true - -local event = require 'utils.event' -local math_random = math.random -local table_insert = table.insert +local Event = require 'utils.event' local water_tile_whitelist = { ['water'] = true, ['deepwater'] = true, @@ -12,15 +8,6 @@ local water_tile_whitelist = { ['deepwater-green'] = true } -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 function get_chunk_position(position) local chunk_position = {} position.x = math.floor(position.x) @@ -99,7 +86,7 @@ local function generate_chunks(position) nauvis.force_generate_chunk_requests() end -local function process_tile(surface, position, old_tile, inventory) +local function process_tile(surface, position, old_tile) local nauvis = game.surfaces.nauvis generate_chunks(position) local new_tile = nauvis.get_tile(position) @@ -113,7 +100,7 @@ local function process_tile(surface, position, old_tile, inventory) for _, e in pairs(nauvis.find_entities_filtered({area = area})) do place_entity(surface, e) end - local area = {{position.x - 1, position.y - 1}, {position.x + 0.999, position.y + 0.999}} + area = {{position.x - 1, position.y - 1}, {position.x + 0.999, position.y + 0.999}} for _, d in pairs(nauvis.find_decoratives_filtered {area = area}) do surface.create_decoratives {check_collision = true, decoratives = {{amount = d.amount, position = d.position, name = d.decorative.name}}} end @@ -141,5 +128,5 @@ local function on_robot_built_tile(event) reveal(event.robot.surface, event.tiles, event.robot.get_inventory(defines.inventory.robot_cargo)) end -event.add(defines.events.on_robot_built_tile, on_robot_built_tile) -event.add(defines.events.on_player_built_tile, on_player_built_tile) +Event.add(defines.events.on_robot_built_tile, on_robot_built_tile) +Event.add(defines.events.on_player_built_tile, on_player_built_tile) diff --git a/modules/launch_fish_to_win.lua b/modules/launch_fish_to_win.lua index 860c5962..c42c0bda 100644 --- a/modules/launch_fish_to_win.lua +++ b/modules/launch_fish_to_win.lua @@ -148,13 +148,13 @@ local function fish_in_space_gui(player) progressbar.style.maximal_width = 100 progressbar.style.top_padding = 10 - local label = frame.add({type = 'label', caption = global.fish_in_space .. '/' .. tostring(global.catplanet_goals[i + 1].goal)}) + label = frame.add({type = 'label', caption = global.fish_in_space .. '/' .. tostring(global.catplanet_goals[i + 1].goal)}) label.style.font_color = {r = 0.33, g = 0.66, b = 0.9} if global.catplanet_goals[i].rank then - local label = frame.add({type = 'label', caption = ' ~Rank~'}) + label = frame.add({type = 'label', caption = ' ~Rank~'}) label.style.font_color = {r = 0.75, g = 0.75, b = 0.75} - local label = frame.add({type = 'label', caption = global.catplanet_goals[i].rank}) + label = frame.add({type = 'label', caption = global.catplanet_goals[i].rank}) label.style.font = 'default-bold' label.style.font_color = global.catplanet_goals[i].color end diff --git a/modules/manual_mining_booster.lua b/modules/manual_mining_booster.lua index 98f7e494..c94d8fda 100644 --- a/modules/manual_mining_booster.lua +++ b/modules/manual_mining_booster.lua @@ -1,6 +1,6 @@ --manually mining continuously will speed it up -local event = require 'utils.event' +local Event = require 'utils.event' local valid_entities = { ['rock-big'] = true, @@ -44,10 +44,10 @@ local function tick() end end -local function on_init(event) +local function on_init() global.manual_mining_booster = {} end -event.add(defines.events.on_player_mined_entity, on_player_mined_entity) -event.on_nth_tick(60, tick) -event.on_init(on_init) +Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +Event.on_nth_tick(60, tick) +Event.on_init(on_init) diff --git a/modules/map_info.lua b/modules/map_info.lua index bc324285..50c0b105 100644 --- a/modules/map_info.lua +++ b/modules/map_info.lua @@ -25,7 +25,7 @@ function Public.Pop_info() return map_info end -local create_map_intro = (function(player, frame) +local create_map_intro = (function(_, frame) frame.clear() frame.style.padding = 4 frame.style.margin = 0 diff --git a/modules/market_friendly_fire_protection.lua b/modules/market_friendly_fire_protection.lua index 18f44e52..83bdea51 100644 --- a/modules/market_friendly_fire_protection.lua +++ b/modules/market_friendly_fire_protection.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local function on_entity_damaged(event) if event.entity.name ~= 'market' then @@ -13,4 +13,4 @@ local function on_entity_damaged(event) return true end -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/mineable_wreckage_yields_ores.lua b/modules/mineable_wreckage_yields_ores.lua index 710f3e53..81b58f56 100644 --- a/modules/mineable_wreckage_yields_ores.lua +++ b/modules/mineable_wreckage_yields_ores.lua @@ -17,14 +17,6 @@ local weights = { {'uranium-ore', 2} } -local texts = { - ['iron-ore'] = {'Iron ore', {r = 200, g = 200, b = 180}}, - ['copper-ore'] = {'Copper ore', {r = 221, g = 133, b = 6}}, - ['uranium-ore'] = {'Uranium ore', {r = 50, g = 250, b = 50}}, - ['coal'] = {'Coal', {r = 0, g = 0, b = 0}}, - ['stone'] = {'Stone', {r = 200, g = 160, b = 30}} -} - local particles = { ['iron-ore'] = 'iron-ore-particle', ['copper-ore'] = 'copper-ore-particle', @@ -35,7 +27,7 @@ local particles = { local ore_raffle = {} for _, t in pairs(weights) do - for x = 1, t[2], 1 do + for _ = 1, t[2], 1 do insert(ore_raffle, t[1]) end end diff --git a/modules/mineable_wreckage_yields_scrap.lua b/modules/mineable_wreckage_yields_scrap.lua index 52057f68..4b5fab18 100644 --- a/modules/mineable_wreckage_yields_scrap.lua +++ b/modules/mineable_wreckage_yields_scrap.lua @@ -106,7 +106,7 @@ local scrap_yield_amounts = { local scrap_raffle = {} for _, t in pairs(mining_chance_weights) do - for x = 1, t.chance, 1 do + for _ = 1, t.chance, 1 do table.insert(scrap_raffle, t.name) end end diff --git a/modules/no_blueprint_library.lua b/modules/no_blueprint_library.lua index 03b8a474..3cb7c0a4 100644 --- a/modules/no_blueprint_library.lua +++ b/modules/no_blueprint_library.lua @@ -1,9 +1,9 @@ -local event = require 'utils.event' +local Event = require 'utils.event' -local function on_player_joined_game(event) +local function on_player_joined_game() game.permissions.get_group('Default').set_allows_action(defines.input_action.grab_blueprint_record, false) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint_string, false) game.permissions.get_group('Default').set_allows_action(defines.input_action.import_blueprint, false) end -event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/modules/no_handcrafting.lua b/modules/no_handcrafting.lua index 969f192a..47d1d516 100644 --- a/modules/no_handcrafting.lua +++ b/modules/no_handcrafting.lua @@ -5,7 +5,7 @@ local function disable_recipe(recipe, force) force.set_hand_crafting_disabled_for_recipe(recipe.name, 1) end -local function on_player_joined_game(event) +local function on_player_joined_game() if game.tick == 0 then local surface = game.surfaces[1] @@ -18,9 +18,9 @@ local function on_player_joined_game(event) power_pole.minable = true local assembler = surface.create_entity({name = 'assembling-machine-2', position = {x = -4, y = -1}, force = 'player'}) - e.destructible = false - e.minable = false - e.operable = true + assembler.destructible = false + assembler.minable = false + assembler.operable = true end end @@ -34,6 +34,5 @@ local function on_pre_player_crafted_item(event) end local Event = require 'utils.event' -Event.on_init(on_init) Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_pre_player_crafted_item, on_pre_player_crafted_item) diff --git a/modules/no_robots.lua b/modules/no_robots.lua index 0f129a7c..2f448477 100644 --- a/modules/no_robots.lua +++ b/modules/no_robots.lua @@ -1,6 +1,6 @@ -local event = require 'utils.event' +local Event = require 'utils.event' -local function on_player_joined_game(event) +local function on_player_joined_game() game.forces['player'].technologies['logistic-system'].enabled = false game.forces['player'].technologies['construction-robotics'].enabled = false game.forces['player'].technologies['logistic-robotics'].enabled = false @@ -27,4 +27,4 @@ local function on_player_joined_game(event) game.forces['player'].technologies['worker-robots-speed-6'].enabled = false end -event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/modules/ores_are_mixed.lua b/modules/ores_are_mixed.lua index f32a2253..c334b323 100644 --- a/modules/ores_are_mixed.lua +++ b/modules/ores_are_mixed.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local simplex_noise = require 'utils.simplex_noise'.d2 local ore_raffle = { 'iron-ore', @@ -29,4 +29,4 @@ local function on_chunk_generated(event) end end -event.add(defines.events.on_chunk_generated, on_chunk_generated) +Event.add(defines.events.on_chunk_generated, on_chunk_generated) diff --git a/modules/players_trample_paths.lua b/modules/players_trample_paths.lua index 0b881599..c08ef5f8 100644 --- a/modules/players_trample_paths.lua +++ b/modules/players_trample_paths.lua @@ -1,6 +1,6 @@ -- players trample paths, tiles change as players walk around -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local blacklisted_tiles = { @@ -64,4 +64,4 @@ local function on_player_changed_position(event) player.surface.set_tiles({{name = new_tile, position = tile.position}}, true) end -event.add(defines.events.on_player_changed_position, on_player_changed_position) +Event.add(defines.events.on_player_changed_position, on_player_changed_position) diff --git a/modules/railgun_enhancer.lua b/modules/railgun_enhancer.lua index 31048ff0..dcc04734 100644 --- a/modules/railgun_enhancer.lua +++ b/modules/railgun_enhancer.lua @@ -1,7 +1,7 @@ -- improves the damage of the railgun and adds visual effects -- by mewmew -- laser turret research will increase it´s damage even further -- -local event = require 'utils.event' +local Event = require 'utils.event' local damage_min = 400 local damage_max = 800 local math_random = math.random @@ -15,7 +15,7 @@ local biological_target_types = { ['unit-spawner'] = true } -local function create_visuals(source_entity, target_entity) +local function create_visuals(_, target_entity) if not additional_visual_effects then return end @@ -112,4 +112,4 @@ local function on_entity_damaged(event) event.entity.damage(damage, player.force, 'physical') end -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/restrictive_fluid_mining.lua b/modules/restrictive_fluid_mining.lua index 06746a88..4bcabe7a 100644 --- a/modules/restrictive_fluid_mining.lua +++ b/modules/restrictive_fluid_mining.lua @@ -1,6 +1,6 @@ -- restricts mining of fluid filled entities -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local message_color = {r = 255, g = 150, b = 0} @@ -86,5 +86,5 @@ local function on_robot_mined_entity(event) restrict_fluid_mining(event) end -event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity) -event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +Event.add(defines.events.on_robot_mined_entity, on_robot_mined_entity) +Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) diff --git a/modules/rewards.lua b/modules/rewards.lua index 32df3651..660cab9c 100644 --- a/modules/rewards.lua +++ b/modules/rewards.lua @@ -106,44 +106,43 @@ local function show_rewards(player) if global.rewards[player.name].level then str = tostring(current_level) end - local l = t.add {type = 'label', caption = str} + l = t.add {type = 'label', caption = str} l.style.font = 'default-bold' l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} l.style.minimal_width = 123 - local t = frame.add {type = 'table', column_count = 1} + t = frame.add {type = 'table', column_count = 1} - local l = t.add {type = 'label', caption = 'Progress to Next Level: '} + l = t.add {type = 'label', caption = 'Progress to Next Level: '} l.style.font = 'default-bold' l.style.font_color = {r = 244, g = 212, b = 66} l.style.minimal_width = 123 - local t = frame.add {type = 'table', column_count = 1} - + t = frame.add {type = 'table', column_count = 1} + local value if kill_score then value = ((kill_score - min_score) / (floor(next_level_score) - min_score)) end - local l = t.add {type = 'progressbar', value = value} + l = t.add {type = 'progressbar', value = value} l.style.font = 'default-bold' l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} l.style.minimal_width = 123 - local t = frame.add {type = 'table', column_count = 1} + t = frame.add {type = 'table', column_count = 1} - local l = t.add {type = 'label', caption = 'Next Reward: '} + l = t.add {type = 'label', caption = 'Next Reward: '} l.style.font = 'default-bold' l.style.font_color = {r = 244, g = 212, b = 66} l.style.minimal_width = 123 - local t = frame.add {type = 'table', column_count = 1} + t = frame.add {type = 'table', column_count = 1} - local leveled_list = {} for _, v in pairs(rewards_loot[next_level]) do - local str = '0' + str = '0' if global.rewards[player.name].level then str = tostring(v.count .. ' ' .. v.text) end - local l = t.add {type = 'label', caption = str} + l = t.add {type = 'label', caption = str} l.style.font = 'default-bold' l.style.font_color = {r = 0.9, g = 0.9, b = 0.9} l.style.minimal_width = 123 @@ -183,7 +182,7 @@ local callback = end for i = 1, #data.pos_list, 1 do if data.pos_list[i].distance >= data.run then - local splash = data.surface.create_entity({name = 'water-splash', position = data.pos_list[i].position}) + data.surface.create_entity({name = 'water-splash', position = data.pos_list[i].position}) end end end @@ -197,14 +196,13 @@ local function reward_messages(data) return end local print_text = '' - local text_effect = - player.surface.create_entity( + + 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 - local text_effect = - player.surface.create_entity( + 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 @@ -248,16 +246,14 @@ local function kill_rewards(event) local inserted_count = pinsert {name = item.name, count = item.count} -- Check if player inventory is full, store remaining rewards in table if (item.count - inserted_count) > 0 then - local queue_pos = #global.inventory_queue[player.name].items surface.spill_item_stack(center_position, {name = item.name, count = (item.count - inserted_count)}, true) player.print('[WARNING] Inventory Full, Rewards Dropped', {r = 1.0, g = 0.0, b = 0.0}) end end -- Creates the level up effect in a radius for i = 1, 5, 1 do - local area = {} local pos_list = {} - area = {left_top = {x = (center_position.x - i), y = (center_position.y - i)}, right_bottom = {x = (center_position.x + i + 1), y = (center_position.y + i + 1)}} + local area = {left_top = {x = (center_position.x - i), y = (center_position.y - i)}, right_bottom = {x = (center_position.x + i + 1), y = (center_position.y + i + 1)}} for _, t in pairs(surface.find_tiles_filtered {area = area}) do local distance = floor(sqrt((center_position.x - t.position.x) ^ 2 + (center_position.y - t.position.y) ^ 2)) if (distance <= i) then diff --git a/modules/rocket_launch_always_yields_science.lua b/modules/rocket_launch_always_yields_science.lua index d0aae50b..79646c66 100644 --- a/modules/rocket_launch_always_yields_science.lua +++ b/modules/rocket_launch_always_yields_science.lua @@ -1,6 +1,6 @@ -- rocket launch always yields space science -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local function on_rocket_launched(event) local rocket_inventory = event.rocket.get_inventory(defines.inventory.rocket) @@ -11,4 +11,4 @@ local function on_rocket_launched(event) rocket_silo_inventory.insert({name = 'space-science-pack', count = 1000}) end -event.add(defines.events.on_rocket_launched, on_rocket_launched) +Event.add(defines.events.on_rocket_launched, on_rocket_launched) diff --git a/modules/rocks_heal_over_time.lua b/modules/rocks_heal_over_time.lua index 6d37d734..ef8541a5 100644 --- a/modules/rocks_heal_over_time.lua +++ b/modules/rocks_heal_over_time.lua @@ -1,4 +1,5 @@ -- rocks and other entities heal over time -- by mewmew +local Event = require 'utils.event' local entity_whitelist = { ['rock-big'] = true, @@ -38,17 +39,16 @@ local function on_entity_damaged(event) global.entities_regenerate_health[tostring(event.entity.position.x) .. '_' .. tostring(event.entity.position.y)] = {last_damage = game.tick, entity = event.entity} end -local function tick(event) +local function tick() for key, entity in pairs(global.entities_regenerate_health) do process_entity(entity, key) end end -local function on_init(event) +local function on_init() global.entities_regenerate_health = {} end -local event = require 'utils.event' -event.on_nth_tick(1800, tick) -event.on_init(on_init) -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.on_nth_tick(1800, tick) +Event.on_init(on_init) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/rocks_yield_coins.lua b/modules/rocks_yield_coins.lua index eabd6ae5..dd7f3568 100644 --- a/modules/rocks_yield_coins.lua +++ b/modules/rocks_yield_coins.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local coin_yield = { ['rock-big'] = 3, @@ -16,4 +16,4 @@ local function on_player_mined_entity(event) end end -event.add(defines.events.on_player_mined_entity, on_player_mined_entity) +Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) diff --git a/modules/rocks_yield_ore.lua b/modules/rocks_yield_ore.lua index 27bd3a3b..d4feeb83 100644 --- a/modules/rocks_yield_ore.lua +++ b/modules/rocks_yield_ore.lua @@ -46,7 +46,7 @@ end local function set_raffle() global.rocks_yield_ore['raffle'] = {} for _, t in pairs(get_chances()) do - for x = 1, t[2], 1 do + for _ = 1, t[2], 1 do table.insert(global.rocks_yield_ore['raffle'], t[1]) end end @@ -184,7 +184,7 @@ local function on_entity_died(event) global.rocks_yield_ore['ores_mined'] = global.rocks_yield_ore['ores_mined'] + count surface.spill_item_stack(pos, {name = ore, count = count}, true) - local count = math_random(1, 3) + count = math_random(1, 3) global.rocks_yield_ore['ores_mined'] = global.rocks_yield_ore['ores_mined'] + count surface.spill_item_stack(pos, {name = 'stone', count = math_random(1, 3)}, true) diff --git a/modules/rocks_yield_ore_veins.lua b/modules/rocks_yield_ore_veins.lua index 95770a2c..f86c75e7 100644 --- a/modules/rocks_yield_ore_veins.lua +++ b/modules/rocks_yield_ore_veins.lua @@ -40,7 +40,7 @@ end local function set_raffle() global.rocks_yield_ore_veins.raffle = {} for _, t in pairs(get_chances()) do - for x = 1, t[2], 1 do + for _ = 1, t[2], 1 do table.insert(global.rocks_yield_ore_veins.raffle, t[1]) end end diff --git a/modules/rpg.lua b/modules/rpg.lua index c0ab8954..240ead54 100644 --- a/modules/rpg.lua +++ b/modules/rpg.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --[[ Character Experience Gain RPG by MewMew diff --git a/modules/satellite_score.lua b/modules/satellite_score.lua index 1dc439a8..720f2065 100644 --- a/modules/satellite_score.lua +++ b/modules/satellite_score.lua @@ -1,6 +1,6 @@ -- level up ranks with launching satellites -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local Server = require 'utils.server' local function get_rank() @@ -21,7 +21,7 @@ local function satellite_score_toggle_button(player) button.style.minimal_width = 38 button.style.padding = 1 end - +--[[ local function level_up_popup(player) local reward = global.satellite_score[get_rank()] if player.gui.center['level_up_popup'] then @@ -35,8 +35,7 @@ local function level_up_popup(player) button.style.minimal_width = string.len(reward.msg) * 7 button.style.font = 'default-listbox' button.style.font_color = {r = 0.77, g = 0.77, b = 0.77} -end - +end ]] local function satellites_in_space_gui(player) --if global.satellites_in_space == 0 then return end local i = get_rank() @@ -58,13 +57,13 @@ local function satellites_in_space_gui(player) progressbar.style.maximal_width = 100 progressbar.style.top_padding = 10 - local label = frame.add({type = 'label', caption = global.satellites_in_space .. '/' .. tostring(global.satellite_score[i + 1].goal)}) + label = frame.add({type = 'label', caption = global.satellites_in_space .. '/' .. tostring(global.satellite_score[i + 1].goal)}) label.style.font_color = {r = 0.33, g = 0.66, b = 0.9} if global.satellite_score[i].rank then - local label = frame.add({type = 'label', caption = ' ~Rank~'}) + label = frame.add({type = 'label', caption = ' ~Rank~'}) label.style.font_color = {r = 0.75, g = 0.75, b = 0.75} - local label = frame.add({type = 'label', caption = global.satellite_score[i].rank}) + label = frame.add({type = 'label', caption = global.satellite_score[i].rank}) label.style.font = 'default-bold' label.style.font_color = global.satellite_score[i].color end @@ -162,6 +161,6 @@ local function on_gui_click(event) end end -event.add(defines.events.on_gui_click, on_gui_click) -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_rocket_launched, on_rocket_launched) +Event.add(defines.events.on_gui_click, on_gui_click) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_rocket_launched, on_rocket_launched) diff --git a/modules/scramble_ores.lua b/modules/scramble_ores.lua index 1d1b53e5..78e92252 100644 --- a/modules/scramble_ores.lua +++ b/modules/scramble_ores.lua @@ -1,9 +1,9 @@ -local event = require 'utils.event' +local Event = require 'utils.event' -DIVERSITY_QUOTA = 0.20 -EXEMPT_AREA = 200 --This is the radius of the starting area that can't be affected. -STONE_BYPRODUCT = false --Delete patches of stone. Stone only appears as a byproduct. -STONE_BYPRODUCT_RATIO = 0.25 --If math.random() is between DIVERSITY_QUOTA and this, it's stone. +local diversity = 0.20 +local exempt_area = 200 --This is the radius of the starting area that can't be affected. +local stone_byproduct = false --Delete patches of stone. Stone only appears as a byproduct. +local stone_ratio = 0.25 --If math.random() is between diversity and this, it's stone. --Build a table of potential ores to pick from. Uranium is exempt from popping up randomly. local function init() @@ -18,16 +18,16 @@ end local function scramble(event) local ores = event.surface.find_entities_filtered {type = 'resource', area = event.area} for k, v in pairs(ores) do - if math.abs(v.position.x) > EXEMPT_AREA or math.abs(v.position.y) > EXEMPT_AREA then + if math.abs(v.position.x) > exempt_area or math.abs(v.position.y) > exempt_area then if v.prototype.resource_category == 'basic-solid' then local random = math.random() - if v.name == 'stone' and STONE_BYPRODUCT then + if v.name == 'stone' and stone_byproduct then v.destroy() - elseif random < DIVERSITY_QUOTA then --Replace! + elseif random < diversity then --Replace! local refugee = global.diverse_ores[math.random(#global.diverse_ores)] event.surface.create_entity {name = refugee, position = v.position, amount = v.amount} v.destroy() - elseif STONE_BYPRODUCT and random < STONE_BYPRODUCT_RATIO then --Replace with stone! + elseif stone_byproduct and random < stone_ratio then --Replace with stone! event.surface.create_entity {name = 'stone', position = v.position, amount = v.amount} v.destroy() end @@ -35,5 +35,6 @@ local function scramble(event) end end end -event.on_init(init) -event.add(defines.events.on_chunk_generated, scramble) + +Event.on_init(init) +Event.add(defines.events.on_chunk_generated, scramble) diff --git a/modules/scrap_towny_ffa/biters.lua b/modules/scrap_towny_ffa/biters.lua index 6a0c583f..73bd4c3c 100644 --- a/modules/scrap_towny_ffa/biters.lua +++ b/modules/scrap_towny_ffa/biters.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local math_random = math.random local math_floor = math.floor diff --git a/modules/scrap_towny_ffa/building.lua b/modules/scrap_towny_ffa/building.lua index e70df9e7..4263b2ea 100644 --- a/modules/scrap_towny_ffa/building.lua +++ b/modules/scrap_towny_ffa/building.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local Table = require 'modules.scrap_towny_ffa.table' diff --git a/modules/scrap_towny_ffa/spawn.lua b/modules/scrap_towny_ffa/spawn.lua index 78f530cc..8e4e3955 100644 --- a/modules/scrap_towny_ffa/spawn.lua +++ b/modules/scrap_towny_ffa/spawn.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local table_size = table.size diff --git a/modules/scrap_towny_ffa/team.lua b/modules/scrap_towny_ffa/team.lua index dcfe068a..52a5f0f3 100644 --- a/modules/scrap_towny_ffa/team.lua +++ b/modules/scrap_towny_ffa/team.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local table_size = table.size diff --git a/modules/scrap_towny_ffa/towny_balance.lua b/modules/scrap_towny_ffa/towny_balance.lua index c1821433..39f86d13 100644 --- a/modules/scrap_towny_ffa/towny_balance.lua +++ b/modules/scrap_towny_ffa/towny_balance.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --Towny balance things by Gerkiz -- local player_ammo_starting_modifiers = { diff --git a/modules/shopping_chests.lua b/modules/shopping_chests.lua index e46bf7ea..da4935a2 100644 --- a/modules/shopping_chests.lua +++ b/modules/shopping_chests.lua @@ -1,3 +1,5 @@ +local Public = {} + local shop_list = { ['coal'] = 1, ['copper-ore'] = 1, @@ -11,7 +13,7 @@ local shop_list = { ['wood'] = 0.75 } -function create_shopping_chest(surface, position, destructible) +function Public.create_shopping_chest(surface, position, destructible) local entity = surface.create_entity({name = 'logistic-chest-requester', position = position, force = 'shopping_chests'}) entity.minable = false if not destructible then @@ -19,7 +21,7 @@ function create_shopping_chest(surface, position, destructible) end end -function create_dump_chest(surface, position, destructible) +function Public.create_dump_chest(surface, position, destructible) local entity = surface.create_entity({name = 'logistic-chest-passive-provider', position = position, force = 'shopping_chests'}) entity.minable = false if not destructible then @@ -73,16 +75,16 @@ local function process_shopping_chest(k, chest) chest.surface.create_entity({name = 'flying-text', position = chest.position, text = '-' .. spent_credits .. ' ø', color = {r = 200, g = 160, b = 30}}) end -local function process_dump_chest(k, chest) +local function process_dump_chest(key, chest) if not chest.valid then - global.dump_chests[k] = nil + global.dump_chests[key] = nil return end local inventory = chest.get_inventory(defines.inventory.chest) if inventory.is_empty() then return end - for k, price in pairs(shop_list) do + for k, _ in pairs(shop_list) do local removed = inventory.remove(k) if removed > 0 then local gain = removed * shop_list[k] @@ -173,7 +175,9 @@ local function on_init() game.forces.shopping_chests.set_friend('player', true) end -local event = require 'utils.event' -event.add(defines.events.on_gui_opened, on_gui_opened) -event.on_nth_tick(120, tick) -event.on_init(on_init) +local Event = require 'utils.event' +Event.add(defines.events.on_gui_opened, on_gui_opened) +Event.on_nth_tick(120, tick) +Event.on_init(on_init) + +return Public diff --git a/modules/show_health.lua b/modules/show_health.lua index 378cf1db..53c883ad 100644 --- a/modules/show_health.lua +++ b/modules/show_health.lua @@ -1,6 +1,6 @@ -local event = require 'utils.event' -local game = require 'utils.game' -event.add( +local Event = require 'utils.event' + +Event.add( defines.events.on_entity_damaged, function(event) local entity = event.entity diff --git a/modules/simple_tags.lua b/modules/simple_tags.lua index cb65a275..fd808ced 100644 --- a/modules/simple_tags.lua +++ b/modules/simple_tags.lua @@ -56,7 +56,7 @@ local function draw_screen_gui(player) return end - local frame = + frame = player.gui.screen.add( { type = 'frame', diff --git a/modules/spaghett_challenge.lua b/modules/spaghett_challenge.lua index 1fc12f12..699eb569 100644 --- a/modules/spaghett_challenge.lua +++ b/modules/spaghett_challenge.lua @@ -1,13 +1,12 @@ -- too many same entities close together will explode -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random require 'utils.table' local search_radius = 6 local explosions = {'explosion', 'explosion', 'explosion', 'explosion', 'explosion', 'explosion', 'medium-explosion', 'uranium-cannon-explosion', 'uranium-cannon-explosion'} -local default_limit = 2 local entity_limits = { ['transport-belt'] = search_radius * 2 + 1, ['pipe'] = search_radius * 2 + 2, @@ -120,7 +119,6 @@ local function spaghett(surface, entity, inventory, player) global.last_spaghett_error[player.index] = 0 end if game.tick - global.last_spaghett_error[player.index] > 30 then - local gb = math.random(0, 150) surface.create_entity( { name = 'flying-text', @@ -148,7 +146,7 @@ local function on_robot_built_entity(event) spaghett(event.robot.surface, event.created_entity, event.robot.get_inventory(defines.inventory.robot_cargo)) end -function on_player_created(event) +local function on_player_created(event) local force = game.players[event.player_index].force force.technologies['logistic-system'].enabled = false force.technologies['construction-robotics'].enabled = false @@ -176,7 +174,7 @@ function on_player_created(event) force.technologies['worker-robots-speed-6'].enabled = false end -event.add(defines.events.on_player_created, on_player_created) -event.add(defines.events.on_robot_built_entity, on_robot_built_entity) -event.add(defines.events.on_built_entity, on_built_entity) -event.add(defines.events.on_player_rotated_entity, on_player_rotated_entity) +Event.add(defines.events.on_player_created, on_player_created) +Event.add(defines.events.on_robot_built_entity, on_robot_built_entity) +Event.add(defines.events.on_built_entity, on_built_entity) +Event.add(defines.events.on_player_rotated_entity, on_player_rotated_entity) diff --git a/modules/spawners_contain_acid.lua b/modules/spawners_contain_acid.lua index 0f5d4d5b..a4b1c005 100644 --- a/modules/spawners_contain_acid.lua +++ b/modules/spawners_contain_acid.lua @@ -1,5 +1,4 @@ -local event = require 'utils.event' -local math_random = math.random +local Event = require 'utils.event' local radius = 16 local targets = {} @@ -34,4 +33,4 @@ local function on_entity_died(event) end end -event.add(defines.events.on_entity_died, on_entity_died) +Event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/spitters_spit_biters.lua b/modules/spitters_spit_biters.lua index 7cc5bb20..20ab34aa 100644 --- a/modules/spitters_spit_biters.lua +++ b/modules/spitters_spit_biters.lua @@ -1,6 +1,6 @@ -- spitters spit biters, because why not -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local radius = 3 local max_biters_in_radius = 3 @@ -30,4 +30,4 @@ local function on_entity_damaged(event) end end -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/splice.lua b/modules/splice.lua index 5117bec9..261289a1 100644 --- a/modules/splice.lua +++ b/modules/splice.lua @@ -1,6 +1,6 @@ -- biter splicing -- global.splice_modifier can be increased for increased difficulty -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local biter_fragmentation = { ['medium-biter'] = {'small-biter', 1}, @@ -21,7 +21,7 @@ local function on_entity_died(event) if amount < 1 then return end - for x = 1, amount, 1 do + for _ = 1, amount, 1 do local p = entity.surface.find_non_colliding_position(biter_fragmentation[entity.name][1], entity.position, 3, 0.5) if p then entity.surface.create_entity({name = biter_fragmentation[entity.name][1], position = p}) @@ -30,4 +30,4 @@ local function on_entity_died(event) end end -event.add(defines.events.on_entity_died, on_entity_died) +Event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/splice_double.lua b/modules/splice_double.lua index 5b95a918..6ee1bae7 100644 --- a/modules/splice_double.lua +++ b/modules/splice_double.lua @@ -1,6 +1,6 @@ -- biters splice into two -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local biter_fragmentation = { ['medium-biter'] = 'small-biter', @@ -14,7 +14,7 @@ local function on_entity_died(event) end if biter_fragmentation[event.entity.name] then local entity = event.entity - for x = 1, 2, 1 do + for _ = 1, 2, 1 do local p = entity.surface.find_non_colliding_position(biter_fragmentation[entity.name], entity.position, 3, 0.5) if p then entity.surface.create_entity({name = biter_fragmentation[entity.name], position = p}) @@ -24,4 +24,4 @@ local function on_entity_died(event) end end -event.add(defines.events.on_entity_died, on_entity_died) +Event.add(defines.events.on_entity_died, on_entity_died) diff --git a/modules/surrounded_by_worms.lua b/modules/surrounded_by_worms.lua index 5dd9ba87..b370495b 100644 --- a/modules/surrounded_by_worms.lua +++ b/modules/surrounded_by_worms.lua @@ -2,7 +2,7 @@ -- global.average_worm_amount_per_chunk sets the average amount of worms -- (default = 1) -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local turrets = { [1] = 'small-worm-turret', @@ -40,7 +40,7 @@ local function on_chunk_generated(event) end local worm_amount = math_random(math.floor(global.average_worm_amount_per_chunk * 0.5), math.ceil(global.average_worm_amount_per_chunk * 1.5)) - for a = 1, worm_amount, 1 do + for _ = 1, worm_amount, 1 do local coord_modifier = tile_coords[math_random(1, #tile_coords)] local pos = {left_top.x + coord_modifier[1], left_top.y + coord_modifier[2]} local name = turrets[math_random(1, highest_worm_tier)] @@ -51,4 +51,4 @@ local function on_chunk_generated(event) end end -event.add(defines.events.on_chunk_generated, on_chunk_generated) +Event.add(defines.events.on_chunk_generated, on_chunk_generated) diff --git a/modules/team_teleport.lua b/modules/team_teleport.lua index 8f6782d0..db10978e 100644 --- a/modules/team_teleport.lua +++ b/modules/team_teleport.lua @@ -250,10 +250,10 @@ local function create_teleport_gui(player) l.style.font = 'heading-2' l.style.minimal_width = 120 - local l = t.add({type = 'label', caption = ' Distance: '}) + l = t.add({type = 'label', caption = ' Distance: '}) l.style.font = 'heading-2' - local l = t.add({type = 'label', caption = tostring(k.distance)}) + l = t.add({type = 'label', caption = tostring(k.distance)}) l.style.font_color = {r = 0.66, g = 0.66, b = 0.99} l.style.font = 'heading-2' l.style.minimal_width = 100 diff --git a/modules/teleporters.lua b/modules/teleporters.lua index db5ec392..7076871e 100644 --- a/modules/teleporters.lua +++ b/modules/teleporters.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local key_item = 'computer' local blacklisted_tiles = {'out-of-map', 'water', 'deepwater', 'water-green', 'lab-white', 'lab-dark-1'} local teleporter_names = { @@ -83,7 +83,7 @@ local teleporter_names = { } local charged_accumulators_required = 8 -function get_power_status(teleporter_index, drain_power) +local function get_power_status(teleporter_index, drain_power) local surface = game.surfaces[global.teleporters[teleporter_index].surface] local a = { left_top = {x = global.teleporters[teleporter_index].position.x - 5, y = global.teleporters[teleporter_index].position.y - 5}, @@ -140,7 +140,7 @@ local function gui_teleporter(player, visited_teleporter_index) local l = t.add({type = 'label', caption = ' '}) l.style.font_color = {r = 0.35, g = 0.5, b = 1} l.style.font = 'heading-1' - local l = t.add({type = 'label', caption = global.teleporters[visited_teleporter_index].name, name = visited_teleporter_index}) + l = t.add({type = 'label', caption = global.teleporters[visited_teleporter_index].name, name = visited_teleporter_index}) l.style.font_color = {r = 0.77, g = 0.77, b = 0.77} l.style.font = 'default-bold' l.style.top_padding = 4 @@ -172,7 +172,7 @@ local function gui_teleporter(player, visited_teleporter_index) local surface = game.surfaces[global.teleporters[x].surface] local tile = surface.get_tile(global.teleporters[x].position) if x ~= visited_teleporter_index and tile.name == 'lab-white' then - local t = scroll_pane.add({type = 'table', column_count = 2}) + t = scroll_pane.add({type = 'table', column_count = 2}) local b = t.add({type = 'button', caption = '> ' .. global.teleporters[x].name .. ' <', name = 'teleporter_' .. x}) b.style.minimal_width = 250 @@ -183,7 +183,7 @@ local function gui_teleporter(player, visited_teleporter_index) local tt = t.add({type = 'table', column_count = 2}) - local l = tt.add({type = 'label', caption = global.teleporters[x].surface .. ': '}) + l = tt.add({type = 'label', caption = global.teleporters[x].surface .. ': '}) l.style.font_color = {r = 0.22, g = 0.88, b = 0.44} l.style.font = 'default-bold' l.style.minimal_width = 65 @@ -191,14 +191,14 @@ local function gui_teleporter(player, visited_teleporter_index) l.style.bottom_padding = 0 l.style.left_padding = 8 - local l = tt.add({type = 'label', caption = 'X: ' .. tostring(global.teleporters[x].position.x) .. ' Y: ' .. tostring(global.teleporters[x].position.y)}) + l = tt.add({type = 'label', caption = 'X: ' .. tostring(global.teleporters[x].position.x) .. ' Y: ' .. tostring(global.teleporters[x].position.y)}) l.style.font = 'default' l.style.font_color = {r = 0.77, g = 0.77, b = 0.77} l.style.minimal_width = 100 l.style.top_padding = 0 l.style.bottom_padding = 0 - local l = tt.add({type = 'label', caption = 'Distance: '}) + l = tt.add({type = 'label', caption = 'Distance: '}) l.style.font_color = {r = 0.22, g = 0.88, b = 0.44} l.style.font = 'default-bold' l.style.minimal_width = 65 @@ -206,7 +206,7 @@ local function gui_teleporter(player, visited_teleporter_index) l.style.bottom_padding = 0 l.style.left_padding = 8 - local l = + l = tt.add( { type = 'label', @@ -222,7 +222,7 @@ local function gui_teleporter(player, visited_teleporter_index) l.style.bottom_padding = 0 if #global.teleporters > 2 and x ~= 1 then - local l = scroll_pane.add({type = 'label', caption = '-----------------------------------------------------------------'}) + l = scroll_pane.add({type = 'label', caption = '-----------------------------------------------------------------'}) l.style.font_color = {r = 0.77, g = 0.77, b = 0.77} l.style.font = 'default' l.style.top_padding = 0 @@ -356,7 +356,7 @@ local function on_gui_click(event) end end -event.add(defines.events.on_player_changed_position, on_player_changed_position) -event.add(defines.events.on_player_dropped_item, on_player_dropped_item) -event.add(defines.events.on_player_main_inventory_changed, on_player_main_inventory_changed) -event.add(defines.events.on_gui_click, on_gui_click) +Event.add(defines.events.on_player_changed_position, on_player_changed_position) +Event.add(defines.events.on_player_dropped_item, on_player_dropped_item) +Event.add(defines.events.on_player_main_inventory_changed, on_player_main_inventory_changed) +Event.add(defines.events.on_gui_click, on_gui_click) diff --git a/modules/teleporting_worms.lua b/modules/teleporting_worms.lua index 0007e8d4..42ca818f 100644 --- a/modules/teleporting_worms.lua +++ b/modules/teleporting_worms.lua @@ -1,7 +1,6 @@ -- worms will teleport to where they shoot -- by mewmew -local event = require 'utils.event' -local math_random = math.random +local Event = require 'utils.event' local function on_entity_damaged(event) if not event.cause then @@ -29,4 +28,4 @@ local function on_entity_damaged(event) cause.destroy() end -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.add(defines.events.on_entity_damaged, on_entity_damaged) diff --git a/modules/the_floor_is_lava.lua b/modules/the_floor_is_lava.lua index 98c6af4f..a650f955 100644 --- a/modules/the_floor_is_lava.lua +++ b/modules/the_floor_is_lava.lua @@ -1,6 +1,6 @@ -- stepping or driving on anything other than concrete or stone-path will melt you into molten state -- by mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local immune_tiles = { ['concrete'] = true, @@ -64,7 +64,7 @@ end --process_player(player) --end -local function tick(event) +local function tick() for _, p in pairs(game.connected_players) do process_player(p) end @@ -78,6 +78,6 @@ local function on_player_joined_game(event) end end -event.on_nth_tick(5, tick) ---event.add(defines.events.on_player_changed_position, on_player_changed_position) -event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.on_nth_tick(5, tick) +--Event.add(defines.events.on_player_changed_position, on_player_changed_position) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/modules/towny/biters.lua b/modules/towny/biters.lua index 290616bd..f8b2a0cf 100644 --- a/modules/towny/biters.lua +++ b/modules/towny/biters.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local Table = require 'modules.towny.table' local math_random = math.random diff --git a/modules/towny/info.lua b/modules/towny/info.lua index 2d277606..68c2f4bd 100644 --- a/modules/towny/info.lua +++ b/modules/towny/info.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local Table = require 'modules.towny.table' diff --git a/modules/towny/main.lua b/modules/towny/main.lua index 9d3fa1f6..16f329be 100644 --- a/modules/towny/main.lua +++ b/modules/towny/main.lua @@ -1,3 +1,4 @@ +--luacheck: ignore --[[ Exchange Strings: diff --git a/modules/towny/market.lua b/modules/towny/market.lua index a5a0d9b2..3e3f8bc6 100644 --- a/modules/towny/market.lua +++ b/modules/towny/market.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Town_center = require 'modules.towny.town_center' local Table = require 'modules.towny.table' local Public = {} diff --git a/modules/towny/team.lua b/modules/towny/team.lua index 5c8659f0..55aaad1a 100644 --- a/modules/towny/team.lua +++ b/modules/towny/team.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Public = {} local Table = require 'modules.towny.table' diff --git a/modules/towny/town_center.lua b/modules/towny/town_center.lua index ea2d0003..aa602b40 100644 --- a/modules/towny/town_center.lua +++ b/modules/towny/town_center.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local Team = require 'modules.towny.team' local Table = require 'modules.towny.table' local Public = {} diff --git a/modules/trees_grow.lua b/modules/trees_grow.lua index c50b612e..15070368 100644 --- a/modules/trees_grow.lua +++ b/modules/trees_grow.lua @@ -1,6 +1,6 @@ -- trees multiply -- mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local math_random = math.random local Difficulty = require 'modules.difficulty_vote' @@ -29,13 +29,12 @@ local blacklist = { } local function coord_string(x, y) - str = tostring(x) .. '_' + local str = tostring(x) .. '_' str = str .. tostring(y) return str end -local function get_chunk(surface) - local Diff = Difficulty.get() +local function get_chunk() if #global.trees_grow_chunk_raffle == 0 then return false end @@ -80,7 +79,7 @@ local function grow_trees(surface) if Diff.difficulty_vote_index then m = Diff.difficulty_vote_index end - for a = 1, math_random(m, math.ceil(m * 1.5)), 1 do + for _ = 1, math_random(m, math.ceil(m * 1.5)), 1 do local tree = trees[math_random(1, #trees)] if not blacklist[tree.name] then local vector = vectors[math_random(1, #vectors)] @@ -116,20 +115,20 @@ local function on_chunk_charted(event) global.trees_grow_chunk_position[str] = {x = position.x, y = position.y} end -local function tick(event) +local function tick() if not game.connected_players[1] then return end local surface = game.connected_players[1].surface - for a = 1, 32, 1 do + for _ = 1, 32, 1 do if grow_trees(surface) then break end end end -local function on_init(event) +local function on_init() global.trees_grow_chunk_next_visit = {} global.trees_grow_chunk_raffle = {} global.trees_grow_chunk_position = {} @@ -138,6 +137,6 @@ local function on_init(event) global.trees_grow_chunks_charted_counter = 0 end -event.on_init(on_init) -event.on_nth_tick(1, tick) -event.add(defines.events.on_chunk_charted, on_chunk_charted) +Event.on_init(on_init) +Event.on_nth_tick(1, tick) +Event.add(defines.events.on_chunk_charted, on_chunk_charted) diff --git a/modules/trees_randomly_die.lua b/modules/trees_randomly_die.lua index 7c3da145..08c825ab 100644 --- a/modules/trees_randomly_die.lua +++ b/modules/trees_randomly_die.lua @@ -1,6 +1,6 @@ -- trees get randomly hit by lightning strikes -- mewmew -local event = require 'utils.event' +local Event = require 'utils.event' local Difficulty = require 'modules.difficulty_vote' local math_random = math.random @@ -74,7 +74,7 @@ local function create_particles(surface, name, position, amount) end local r = 128 -local function get_random_area(surface) +local function get_random_area() local p = game.players[math_random(1, #game.players)].position if not p then return @@ -96,7 +96,7 @@ end local function tick() local Diff = Difficulty.get() - local r = 48 + r = 48 if Diff.difficulty_vote_index then r = difficulties_votes[Diff.difficulty_vote_index] end @@ -104,12 +104,11 @@ local function tick() return end local surface = game.players[1].surface - for a = 1, 8, 1 do + for _ = 1, 8, 1 do if kill_random_tree(surface) then return end end end -event.on_nth_tick(60, tick) -event.add(defines.events.on_entity_damaged, on_entity_damaged) +Event.on_nth_tick(60, tick) diff --git a/modules/wave_defense/gui.lua b/modules/wave_defense/gui.lua index 5e41ebce..396a2e98 100644 --- a/modules/wave_defense/gui.lua +++ b/modules/wave_defense/gui.lua @@ -10,11 +10,11 @@ local function create_gui(player) label.style.font = 'default-bold' label.style.font_color = {r = 0.33, g = 0.66, b = 0.9} - local label = frame.add({type = 'label', caption = ' ', name = 'wave_number'}) - label.style.font_color = {r = 0.88, g = 0.88, b = 0.88} - label.style.font = 'default-bold' - label.style.right_padding = 4 - label.style.font_color = {r = 0.33, g = 0.66, b = 0.9} + local wave_number_label = frame.add({type = 'label', caption = ' ', name = 'wave_number'}) + wave_number_label.style.font_color = {r = 0.88, g = 0.88, b = 0.88} + wave_number_label.style.font = 'default-bold' + wave_number_label.style.right_padding = 4 + wave_number_label.style.font_color = {r = 0.33, g = 0.66, b = 0.9} local progressbar = frame.add({type = 'progressbar', name = 'progressbar', value = 0}) local experimental = get_game_version() @@ -34,21 +34,21 @@ local function create_gui(player) line.style.left_padding = 4 line.style.right_padding = 4 - local label = frame.add({type = 'label', caption = ' ', name = 'threat', tooltip = {'wave_defense.tooltip_1'}}) - label.style.font = 'default-bold' - label.style.left_padding = 4 - label.style.font_color = {r = 150, g = 0, b = 255} + local threat_label = frame.add({type = 'label', caption = ' ', name = 'threat', tooltip = {'wave_defense.tooltip_1'}}) + threat_label.style.font = 'default-bold' + threat_label.style.left_padding = 4 + threat_label.style.font_color = {r = 150, g = 0, b = 255} - local label = frame.add({type = 'label', caption = ' ', name = 'threat_value', tooltip = {'wave_defense.tooltip_1'}}) - label.style.font = 'default-bold' - label.style.right_padding = 1 - label.style.minimal_width = 10 - label.style.font_color = {r = 150, g = 0, b = 255} + local threat_value_label = frame.add({type = 'label', caption = ' ', name = 'threat_value', tooltip = {'wave_defense.tooltip_1'}}) + threat_value_label.style.font = 'default-bold' + threat_value_label.style.right_padding = 1 + threat_value_label.style.minimal_width = 10 + threat_value_label.style.font_color = {r = 150, g = 0, b = 255} - local label = frame.add({type = 'label', caption = ' ', name = 'threat_gains', tooltip = {'wave_defense.tooltip_2'}}) - label.style.font = 'default' - label.style.left_padding = 1 - label.style.right_padding = 1 + local threat_gains_label = frame.add({type = 'label', caption = ' ', name = 'threat_gains', tooltip = {'wave_defense.tooltip_2'}}) + threat_gains_label.style.font = 'default' + threat_gains_label.style.left_padding = 1 + threat_gains_label.style.right_padding = 1 end --display threat gain/loss per minute during last 15 minutes diff --git a/modules/wave_defense/main.lua b/modules/wave_defense/main.lua index 4247675b..3ea63e8d 100644 --- a/modules/wave_defense/main.lua +++ b/modules/wave_defense/main.lua @@ -727,11 +727,11 @@ local function get_main_command(group) } if obstacles then shuffle_distance(obstacles, old_position) - for i = 1, #obstacles, 1 do - if obstacles[i].valid then + for ii = 1, #obstacles, 1 do + if obstacles[ii].valid then commands[#commands + 1] = { type = defines.command.attack, - target = obstacles[i], + target = obstacles[ii], distraction = defines.distraction.by_anything } end diff --git a/terrain_layouts/scrap_01.lua b/terrain_layouts/scrap_01.lua index 63fa5d4a..92a190ba 100644 --- a/terrain_layouts/scrap_01.lua +++ b/terrain_layouts/scrap_01.lua @@ -136,7 +136,7 @@ local scrap_yield_amounts = { local scrap_raffle = {} for _, t in pairs(mining_chance_weights) do - for x = 1, t.chance, 1 do + for _ = 1, t.chance, 1 do table.insert(scrap_raffle, t.name) end end @@ -156,7 +156,7 @@ local function place_scrap(surface, position) local e = surface.create_entity({name = scrap_entities[math_random(1, scrap_entities_index)], position = position, force = 'neutral'}) local i = e.get_inventory(defines.inventory.chest) if i then - for x = 1, math_random(6, 18), 1 do + for _ = 1, math_random(6, 18), 1 do local loot = scrap_raffle[math_random(1, size_of_scrap_raffle)] i.insert({name = loot, count = math_floor(scrap_yield_amounts[loot] * math_random(5, 35) * 0.1) + 1}) diff --git a/terrain_layouts/scrap_02.lua b/terrain_layouts/scrap_02.lua index 8cf497d0..48c50a93 100644 --- a/terrain_layouts/scrap_02.lua +++ b/terrain_layouts/scrap_02.lua @@ -53,30 +53,6 @@ local function is_scrap(name) return false end -local scrap_entities = { - 'crash-site-assembling-machine-1-broken', - 'crash-site-assembling-machine-2-broken', - 'crash-site-lab-broken', - 'medium-ship-wreck', - 'small-ship-wreck', - 'crash-site-chest-1', - 'crash-site-chest-2', - 'crash-site-chest-1', - 'crash-site-chest-2', - 'crash-site-chest-1', - 'crash-site-chest-2', - 'big-ship-wreck-1', - 'big-ship-wreck-2', - 'big-ship-wreck-3', - 'big-ship-wreck-1', - 'big-ship-wreck-2', - 'big-ship-wreck-3', - 'big-ship-wreck-1', - 'big-ship-wreck-2', - 'big-ship-wreck-3' -} -local scrap_entities_index = #scrap_entities - local mining_chance_weights = { {name = 'iron-plate', chance = 1000}, {name = 'iron-gear-wheel', chance = 750}, @@ -183,7 +159,7 @@ local scrap_yield_amounts = { local scrap_raffle = {} for _, t in pairs(mining_chance_weights) do - for x = 1, t.chance, 1 do + for _ = 1, t.chance, 1 do table.insert(scrap_raffle, t.name) end end @@ -203,7 +179,7 @@ local function place_scrap(surface, position) local e = surface.create_entity({name = scraps_inv[math_random(1, #scraps_inv)], position = position, force = 'neutral'}) local i = e.get_inventory(defines.inventory.chest) if i then - for x = 1, math_random(6, 18), 1 do + for _ = 1, math_random(6, 18), 1 do local loot = scrap_raffle[math_random(1, size_of_scrap_raffle)] i.insert({name = loot, count = math_floor(scrap_yield_amounts[loot] * math_random(5, 35) * 0.1) + 1}) diff --git a/terrain_layouts/tree_01.lua b/terrain_layouts/tree_01.lua index dd83474f..5c0be7db 100644 --- a/terrain_layouts/tree_01.lua +++ b/terrain_layouts/tree_01.lua @@ -1,19 +1,11 @@ -local math_abs = math.abs local math_floor = math.floor -local math_sqrt = math.sqrt -local math_round = math.round local math_random = math.random -local table_shuffle_table = table.shuffle_table local table_insert = table.insert local table_remove = table.remove -require 'functions.noise_vector_path' +local NoiseVector = require 'functions.noise_vector_path' -local function pos_to_key(position) - return tostring(position.x .. '_' .. position.y) -end - -local function get_vector(position) +local function get_vector() local x = 1000 - math_random(0, 2000) local y = -1000 + math_random(0, 1100) @@ -43,7 +35,7 @@ local function draw_branch(surface, key) return end - local tiles = noise_vector_tile_path(surface, 'green-refined-concrete', position, vector, size * 4, size * 0.25) + local tiles = NoiseVector.noise_vector_tile_path(surface, 'green-refined-concrete', position, vector, size * 4, size * 0.25) for i = #tiles - math_random(0, 3), #tiles, 1 do table_insert( diff --git a/terrain_layouts/winter.lua b/terrain_layouts/winter.lua index 251251d1..875b33a3 100644 --- a/terrain_layouts/winter.lua +++ b/terrain_layouts/winter.lua @@ -1,8 +1,10 @@ +local Event = require 'utils.event' + local colors = {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}} local function add_light(e) local color = colors[math.random(1, 3)] - local light_nr = - rendering.draw_light( + + rendering.draw_light( { sprite = 'utility/light_small', orientation = 1, @@ -20,11 +22,6 @@ end local function on_chunk_generated(event) local surface = event.surface - local seed = surface.map_gen_settings.seed - local left_top_x = event.area.left_top.x - local left_top_y = event.area.left_top.y - local set_tiles = surface.set_tiles - local get_tile = surface.get_tile local entities = surface.find_entities_filtered({type = {'simple-entity', 'tree', 'fish'}, area = event.area}) if #entities > 1 then @@ -56,9 +53,5 @@ local function on_init() surface.freeze_daytime = true end -local Event = require 'utils.event' Event.on_init(on_init) Event.add(defines.events.on_chunk_generated, on_chunk_generated) -Event.add(defines.events.on_player_joined_game, on_player_joined_game) -Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) -Event.add(defines.events.on_entity_died, on_entity_died) diff --git a/tools/cheat_mode.lua b/tools/cheat_mode.lua index 4b8104a5..7885f54b 100644 --- a/tools/cheat_mode.lua +++ b/tools/cheat_mode.lua @@ -1,4 +1,4 @@ -function cheat_mode() +local function cheat_mode() local surface = game.players[1].surface game.player.cheat_mode = true game.players[1].insert({name = 'power-armor-mk2'}) @@ -28,3 +28,5 @@ function cheat_mode() local chart = 128 game.forces['player'].chart(surface, {lefttop = {x = chart * -1, y = chart * -1}, rightbottom = {x = chart, y = chart}}) end + +return cheat_mode() diff --git a/tools/map_functions.lua b/tools/map_functions.lua index 7d79f408..286baa26 100644 --- a/tools/map_functions.lua +++ b/tools/map_functions.lua @@ -16,7 +16,6 @@ end f.draw_noise_tile_ring = function(surface, position, name, radius_min, radius_max) local modifier_1 = math_random(2, 5) * 0.01 local seed = game.surfaces[1].map_gen_settings.seed - local tiles = {} for y = radius_max * -2, radius_max * 2, 1 do for x = radius_max * -2, radius_max * 2, 1 do @@ -35,7 +34,6 @@ f.draw_noise_entity_ring = function(surface, position, name, force, radius_min, local modifier_1 = 1 / (radius_max * 2) local modifier_2 = 1 / (radius_max * 0.5) local seed = game.surfaces[1].map_gen_settings.seed - local tiles = {} for y = radius_max * -2, radius_max * 2, 1 do for x = radius_max * -2, radius_max * 2, 1 do @@ -215,7 +213,6 @@ f.draw_oil_circle = function(position, name, surface, radius, richness) if not richness then return end - local math_random = math.random local count = 0 local max_count = 0 while count < radius and max_count < 100000 do @@ -254,7 +251,6 @@ f.draw_smoothed_out_ore_circle = function(position, name, surface, radius, richn if not richness then return end - local math_random = math.random local noise_seed_add = 25000 local richness_part = richness / radius for y = radius * -2, radius * 2, 1 do @@ -292,7 +288,6 @@ f.draw_crazy_smoothed_out_ore_circle = function(position, name, surface, radius, if not richness then return end - local math_random = math.random local noise_seed_add = 25000 local richness_part = richness / radius for y = radius * -1, radius, 1 do @@ -316,10 +311,9 @@ end f.create_cluster = function(name, pos, size, surface, spread, resource_amount) local p = {x = pos.x, y = pos.y} - local math_random = math.random local original_pos = {x = pos.x, y = pos.y} - local entity_has_been_placed = false - for z = 1, size, 1 do + local entity_has_been_placed + for _ = 1, size, 1 do entity_has_been_placed = false local y = 1 if spread then @@ -329,7 +323,7 @@ f.create_cluster = function(name, pos, size, surface, spread, resource_amount) modifier_raffle = shuffle(modifier_raffle) for x = 1, 8, 1 do local m = modifier_raffle[x] - local pos = {x = p.x + m[1], y = p.y + m[2]} + pos = {x = p.x + m[1], y = p.y + m[2]} if resource_amount then if surface.can_place_entity({name = name, position = pos, amount = resource_amount}) then surface.create_entity {name = name, position = pos, amount = resource_amount} diff --git a/tools/map_intro.lua b/tools/map_intro.lua index d5118054..e094ed07 100644 --- a/tools/map_intro.lua +++ b/tools/map_intro.lua @@ -1,4 +1,4 @@ -local event = require 'utils.event' +local Event = require 'utils.event' local main_caption = ' --Cave Miner-- ' local sub_caption = ' *diggy diggy hole* ' @@ -26,7 +26,7 @@ local function create_map_intro(player) l.style.top_padding = 6 l.style.bottom_padding = 6 - local l = tt.add {type = 'label', caption = sub_caption} + l = tt.add {type = 'label', caption = sub_caption} l.style.font = 'default' l.style.font_color = {r = 0.99, g = 0.99, b = 0.2} l.style.minimal_width = 280 @@ -40,9 +40,9 @@ local function create_map_intro(player) b.style.right_padding = 4 b.style.bottom_padding = 2 - local tt = t.add {type = 'table', column_count = 1} - local frame = t.add {type = 'frame'} - local l = frame.add {type = 'label', caption = info} + t.add {type = 'table', column_count = 1} + frame = t.add {type = 'frame'} + l = frame.add {type = 'label', caption = info} l.style.single_line = false l.style.font_color = {r = 0.95, g = 0.95, b = 0.95} end @@ -70,5 +70,5 @@ local function on_gui_click(event) end end -event.add(defines.events.on_player_joined_game, on_player_joined_game) -event.add(defines.events.on_gui_click, on_gui_click) +Event.add(defines.events.on_player_joined_game, on_player_joined_game) +Event.add(defines.events.on_gui_click, on_gui_click) diff --git a/tools/map_pregen.lua b/tools/map_pregen.lua index 5fba7b09..99460a70 100644 --- a/tools/map_pregen.lua +++ b/tools/map_pregen.lua @@ -1,6 +1,6 @@ -local event = require 'utils.event' +local Event = require 'utils.event' -local function on_tick(event) +local function on_tick() if global.map_pregeneration_is_active then if game.tick % 600 == 0 then local r = 1 @@ -20,7 +20,7 @@ local function on_tick(event) end end -function map_pregen(chunk_radius) +local function map_pregen(chunk_radius) if chunk_radius then global.chunk_radius = chunk_radius else @@ -35,4 +35,6 @@ function map_pregen(chunk_radius) global.map_pregeneration_is_active = true end -event.add(defines.events.on_tick, on_tick) +Event.add(defines.events.on_tick, on_tick) + +return map_pregen diff --git a/utils/core.lua b/utils/core.lua index 798e2e44..e82758fb 100644 --- a/utils/core.lua +++ b/utils/core.lua @@ -224,49 +224,49 @@ end --- Takes msg and prints it to all players. Also prints to the log and discord -- @param msg The message to print --- @param warning_prefix The name of the module/warning -function Public.action_warning(warning_prefix, msg) +-- @param warning_prefixes The name of the module/warning +function Public.action_warning(warning_prefixes, msg) game.print(prefix .. msg, Color.yellow) - msg = format('%s %s', warning_prefix, msg) + msg = format('%s %s', warning_prefixes, msg) print(msg) Server.to_discord_bold(msg) end --- Takes msg and prints it to all players. Also prints to the log and discord -- @param msg The message to print --- @param warning_prefix The name of the module/warning -function Public.action_warning_embed(warning_prefix, msg) +-- @param warning_prefixes The name of the module/warning +function Public.action_warning_embed(warning_prefixes, msg) game.print(prefix .. msg, Color.yellow) - msg = format('%s %s', warning_prefix, msg) + msg = format('%s %s', warning_prefixes, msg) print(msg) Server.to_discord_embed(msg) end --- Takes msg and prints it to the log and discord. -- @param msg The message to print --- @param warning_prefix The name of the module/warning -function Public.action_to_discord(warning_prefix, msg) - msg = format('%s %s', warning_prefix, msg) +-- @param warning_prefixes The name of the module/warning +function Public.action_to_discord(warning_prefixes, msg) + msg = format('%s %s', warning_prefixes, msg) print(msg) Server.to_discord_bold(msg) end --- Takes msg and prints it to all players except provided player. Also prints to the log and discord -- @param msg The message to print --- @param warning_prefix The name of the module/warning +-- @param warning_prefixes The name of the module/warning -- @param player the player not to send the message to -function Public.silent_action_warning(warning_prefix, msg, player) +function Public.silent_action_warning(warning_prefixes, msg, player) Public.print_except(prefix .. msg, player, Color.yellow) - msg = format('%s %s', warning_prefix, msg) + msg = format('%s %s', warning_prefixes, msg) print(msg) Server.to_discord_bold(msg) end --- Takes msg and logs it. -- @param msg The message to print --- @param warning_prefix The name of the module/warning -function Public.log_msg(warning_prefix, msg) - msg = format('%s %s', warning_prefix, msg) +-- @param warning_prefixes The name of the module/warning +function Public.log_msg(warning_prefixes, msg) + msg = format('%s %s', warning_prefixes, msg) print(msg) end diff --git a/utils/event.lua b/utils/event.lua index 015e4d1a..a957090b 100644 --- a/utils/event.lua +++ b/utils/event.lua @@ -1,4 +1,6 @@ --- luacheck: globals script +--luacheck: ignore function_table +--luacheck: ignore function_nth_tick_table +--luacheck: globals script --- This Module allows for registering multiple handlers to the same event, overcoming the limitation of script.register. -- -- ** Event.add(event_name, handler) ** @@ -94,7 +96,6 @@ -- -- The table contains extra information that you want to pass to the handler. -- script.raise_event(event_id, {extra = 'data'}) - local EventCore = require 'utils.event_core' local Global = require 'utils.global' local Token = require 'utils.token' @@ -110,6 +111,7 @@ local stage_load = _STAGE.load local script_on_event = script.on_event local script_on_nth_tick = script.on_nth_tick local generate_event_name = script.generate_event_name + local function_table = function_table local function_nth_tick_table = function_nth_tick_table diff --git a/utils/gui.lua b/utils/gui.lua index 9da34c55..f5902038 100644 --- a/utils/gui.lua +++ b/utils/gui.lua @@ -20,7 +20,6 @@ Gui.token = end ) -local top_elements = {} local on_visible_handlers = {} local on_pre_hidden_handlers = {} @@ -184,6 +183,7 @@ local function custom_handler_factory(handlers) end end +--luacheck: ignore custom_raise local function custom_raise(handlers, element, player) local handler = handlers[element.name] if not handler then diff --git a/utils/list_utils.lua b/utils/list_utils.lua index 548d52da..71254914 100644 --- a/utils/list_utils.lua +++ b/utils/list_utils.lua @@ -1,3 +1,4 @@ +--luacheck: ignore local function assert_argument_valid(a, arg_type) arg_type = arg_type or 'table' if type(a) ~= arg_type then diff --git a/utils/one_dimensional_noise.lua b/utils/one_dimensional_noise.lua index 9feff542..717f9987 100644 --- a/utils/one_dimensional_noise.lua +++ b/utils/one_dimensional_noise.lua @@ -516,7 +516,7 @@ local heights = { 103 } -function get_noise(x, seed) +local function get_noise(x, seed) x = x + seed local index = math_floor(x % 255) + 1 local h1 = heights[index] @@ -541,7 +541,7 @@ function get_noise(x, seed) return n end -function testnoise() +local function testnoise() local surface = game.surfaces[1] local seed = math.random(1, 1000000) for x = -256, 256, 1 do @@ -554,10 +554,10 @@ function testnoise() target_offset = {0, 0}, color = {0, 255, 0}, scale = 0.88, - font = default, + -- font = default, orientation = 0.75 } end end -return get_noise +return get_noise, testnoise diff --git a/utils/perlin_noise.lua b/utils/perlin_noise.lua index c92714d1..11284eeb 100644 --- a/utils/perlin_noise.lua +++ b/utils/perlin_noise.lua @@ -58,52 +58,52 @@ end -- Gradient function finds dot product between pseudorandom gradient vector -- and the vector from input coordinate to a unit cube vertex local dot_product = { - [0x0] = function(x, y, z) + [0x0] = function(x, y) return x + y end, - [0x1] = function(x, y, z) + [0x1] = function(x, y) return -x + y end, - [0x2] = function(x, y, z) + [0x2] = function(x, y) return x - y end, - [0x3] = function(x, y, z) + [0x3] = function(x, y) return -x - y end, - [0x4] = function(x, y, z) + [0x4] = function(x, z) return x + z end, - [0x5] = function(x, y, z) + [0x5] = function(x, z) return -x + z end, - [0x6] = function(x, y, z) + [0x6] = function(x, z) return x - z end, - [0x7] = function(x, y, z) + [0x7] = function(x, z) return -x - z end, - [0x8] = function(x, y, z) + [0x8] = function(y, z) return y + z end, - [0x9] = function(x, y, z) + [0x9] = function(y, z) return -y + z end, - [0xA] = function(x, y, z) + [0xA] = function(y, z) return y - z end, - [0xB] = function(x, y, z) + [0xB] = function(y, z) return -y - z end, - [0xC] = function(x, y, z) + [0xC] = function(x, y) return y + x end, - [0xD] = function(x, y, z) + [0xD] = function(y, z) return -y + z end, - [0xE] = function(x, y, z) + [0xE] = function(x, y) return y - x end, - [0xF] = function(x, y, z) + [0xF] = function(y, z) return -y - z end } @@ -116,8 +116,8 @@ local function fade(t) return t * t * t * (t * (t * 6 - 15) + 10) end -local function lerp(t, a, b) - return a + t * (b - a) +local function lerp(t, a, bs) + return a + t * (bs - a) end -- Return range: [-1, 1] diff --git a/utils/profiler.lua b/utils/profiler.lua index 35adb1f8..1e51818e 100644 --- a/utils/profiler.lua +++ b/utils/profiler.lua @@ -75,6 +75,7 @@ commands.add_command('stopProfiler', 'Stops profiling', stopCommand) -- assert_raw(expr, ...) --end local error_raw = error +--luacheck: ignore error function error(...) Profiler.Stop(false, 'Error raised') error_raw(...) @@ -191,8 +192,8 @@ local function DumpTree(averageMs) end table_sort(sort, sort_Call) - for i = 1, #sort do - local call = sort[i] + for ii = 1, #sort do + local call = sort[ii] if line >= 19 then --Localised string can only have up to 20 parameters local newStr = {''} --So nest them! diff --git a/utils/scenariohandler.lua b/utils/scenariohandler.lua index a5687b24..dc09619b 100644 --- a/utils/scenariohandler.lua +++ b/utils/scenariohandler.lua @@ -1,4 +1,3 @@ -local Color = require 'utils.color_presets' local Server = require 'utils.server' local Global = require 'utils.globals' @@ -106,7 +105,7 @@ commands.add_command( else game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22}) end - reset_map() + -- reset_map() p('[WARNING] Game has been reset!') return end diff --git a/utils/simplex_noise.lua b/utils/simplex_noise.lua index f804c2ef..ec0b3715 100644 --- a/utils/simplex_noise.lua +++ b/utils/simplex_noise.lua @@ -291,15 +291,6 @@ local function dot2(g, x, y) return x * g[1] + y * g[2] end -local function dot(g, ...) - local v = {...} - local sum = 0 - for i = 1, #v do - sum = sum + v[i] * g[i] - end - return sum -end - local F2 = 0.5 * (math.sqrt(3.0) - 1.0) local G2 = (3.0 - math.sqrt(3.0)) / 6.0 diff --git a/utils/table.lua b/utils/table.lua index f57821e8..8d24b99b 100644 --- a/utils/table.lua +++ b/utils/table.lua @@ -169,11 +169,9 @@ end --- Returns a table with % chance values for each item of a weighted_table -- @param weighted_table of tables with items and their weights --- @param item_index of the index of items, defaults to 1 -- @param weight_index of the index of the weights, defaults to 2 -function table.get_random_weighted_chances(weighted_table, item_index, weight_index) +function table.get_random_weighted_chances(weighted_table, weight_index) local total_weight = 0 - item_index = item_index or 1 weight_index = weight_index or 2 for _, v in pairs(weighted_table) do total_weight = total_weight + v[weight_index]