diff --git a/control.lua b/control.lua index b33548c53..d5d98910d 100644 --- a/control.lua +++ b/control.lua @@ -1,3 +1,10 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + +---@class (partial) PyCoalProcessingStorage +---@field finished boolean + require "__pypostprocessing__.lib" require "scripts.wiki.wiki" @@ -85,12 +92,13 @@ end) py.on_event(defines.events.on_player_created, function(event) Wiki.events.on_player_created(event) - local player = game.get_player(event.player_index) + local player = game.get_player(event.player_index)--[[@as LuaPlayer]] if not player.valid then return end local nauvis = game.surfaces["nauvis"] if not nauvis then return end local autoplace = nauvis.map_gen_settings.autoplace_controls + ---@cast autoplace -? if not script.active_mods["PyBlock"] and autoplace.stone and autoplace.stone.richness <= 1 then player.print {"messages.warning-no-preset", {"map-gen-preset-name.py-recommended"}} @@ -135,6 +143,7 @@ end py.on_event(defines.events.on_tick, function(event) local func_list = remote.call("on_nth_tick", "query", "pycp", event.tick) + --[[@cast func_list string[] ]] for _, func in pairs(func_list) do py.mod_nth_tick_funcs[func]() end diff --git a/data-final-fixes.lua b/data-final-fixes.lua index a12650557..021ae74c4 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -1,8 +1,8 @@ if not mods.pyalternativeenergy then for _, recipe in pairs(data.raw.recipe) do - if not recipe.localised_name and recipe:has_category("combustion") and not recipe.name:find("%-biomass$") then + if not recipe.localised_name and RECIPE(recipe):has_category("combustion") and not recipe.name:find("%-biomass$") then local temp - for _, result in pairs(recipe.results) do + for _, result in pairs(recipe.results--[[@cast -?]]) do if result.name == "combustion-mixture1" then temp = result.temperature end @@ -53,7 +53,7 @@ if rpm_entity ~= 30 or rpm_items ~= 30 or overload ~= 0 then goto continue end for _, result in pairs(recipe.results) do -- This looks long, however we skip a lot of the logic with caching - local result_name = result[1] or result.name + local result_name = result.name if result_name and valid_entities[result_name] then --log("Set multiplier for " .. recipe.name .. " (" .. result_name .. ")") recipe.requester_paste_multiplier = tonumber(rpm_entity) diff --git a/data-updates.lua b/data-updates.lua index 932bd7206..5e03a90fd 100644 --- a/data-updates.lua +++ b/data-updates.lua @@ -7,14 +7,14 @@ require "prototypes/updates/entity-updates" require "prototypes/technologies/stacking-belts" require "prototypes/item-sounds" -ITEM("automation-science-pack", "tool"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/science-pack-1.png") -ITEM("automation-science-pack", "tool"):set("icon_size", 64) +ITEM("automation-science-pack"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/science-pack-1.png") +ITEM("automation-science-pack"):set("icon_size", 64) -ITEM("logistic-science-pack", "tool"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/science-pack-2.png") -ITEM("logistic-science-pack", "tool"):set("icon_size", 64) +ITEM("logistic-science-pack"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/science-pack-2.png") +ITEM("logistic-science-pack"):set("icon_size", 64) -ITEM("chemical-science-pack", "tool"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/science-pack-3.png") -ITEM("chemical-science-pack", "tool"):set("icon_size", 64) +ITEM("chemical-science-pack"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/science-pack-3.png") +ITEM("chemical-science-pack"):set("icon_size", 64) ITEM("lab"):set("icon", "__pycoalprocessinggraphics__/graphics/icons/lab-mk01.png") ITEM("lab"):set("icon_size", 64) @@ -197,9 +197,9 @@ RECIPE("beacon") :add_ingredient {type = "item", name = "intelligent-unit", amount = 1} :add_ingredient {type = "item", name = "parametric-oscilator", amount = 1} :add_ingredient {type = "item", name = "biopolymer", amount = 10} - :add_ingredient {type = "item", name = "super-alloy", amount = 10}:remove_ingredient {"steel-plate"} + :add_ingredient {type = "item", name = "super-alloy", amount = 10} :add_ingredient {type = "item", name = "tower-mk04", amount = 1} - :add_ingredient {type = "item", name = "processing-unit", amount = 5}:remove_ingredient {"electronic-circuit"}:remove_ingredient {"advanced-circuit"} + :add_ingredient {type = "item", name = "processing-unit", amount = 5} :add_ingredient {type = "item", name = "metastable-quasicrystal", amount = 1} :add_ingredient {type = "fluid", name = "r4", amount = 100} if mods.pyalternativeenergy then RECIPE("beacon"):replace_category("crafting", "crafting-with-fluid") end @@ -208,7 +208,7 @@ RECIPE("beacon-mk01") :add_ingredient {type = "item", name = "self-assembly-monolayer", amount = 1} :add_ingredient {type = "item", name = "mechanical-parts-02", amount = 1} :add_ingredient {type = "item", name = "eva", amount = 10} - :add_ingredient {type = "item", name = "stainless-steel", amount = 10}:remove_ingredient {"steel-plate"} + :add_ingredient {type = "item", name = "stainless-steel", amount = 10} :add_ingredient {type = "item", name = "tower-mk02", amount = 1} if register_cache_file ~= nil then @@ -216,5 +216,6 @@ if register_cache_file ~= nil then end if mods["dependency-graph-lib"] then + ---@diagnostic disable-next-line: inject-field data.raw.item["copper-plate"].autotech_startup = true end diff --git a/migrations/3.0.0.lua b/migrations/3.0.0.lua index 410b8bf26..86dcd73c5 100644 --- a/migrations/3.0.0.lua +++ b/migrations/3.0.0.lua @@ -1,3 +1,4 @@ +---@diagnostic disable storage.on_tick = {} -- fix rotation of fawogae plantations after fixing the graphics for _, surface in pairs(game.surfaces) do diff --git a/migrations/3.1.6.lua b/migrations/3.1.6.lua index a7d1298d3..03ba75274 100644 --- a/migrations/3.1.6.lua +++ b/migrations/3.1.6.lua @@ -1,3 +1,4 @@ +---@diagnostic disable -- one-time clear of invalid inserter data to prevent warning for the bug we just fixed for id, metadata in pairs(storage.programmable_inserters) do if not metadata.inserter.valid then diff --git a/migrations/beacon-interference.lua b/migrations/beacon-interference.lua index 7ca24cbc2..a0db3cb97 100644 --- a/migrations/beacon-interference.lua +++ b/migrations/beacon-interference.lua @@ -1,3 +1,4 @@ +---@diagnostic disable storage.beacon_interference_alerts = storage.beacon_interference_alerts or {} storage.alerts = storage.alerts or {} storage.alert_count = storage.alert_count or 0 diff --git a/migrations/explode.lua b/migrations/explode.lua index 039ca0ccb..119b76411 100644 --- a/migrations/explode.lua +++ b/migrations/explode.lua @@ -1,3 +1,4 @@ +---@diagnostic disable local killed_ninjas = 0 local remaining_ninjas = 0 for _, surface in pairs(game.surfaces) do diff --git a/migrations/pyCoalprocessing_2.0.4.lua b/migrations/pyCoalprocessing_2.0.4.lua index d1645b7eb..afe988c31 100644 --- a/migrations/pyCoalprocessing_2.0.4.lua +++ b/migrations/pyCoalprocessing_2.0.4.lua @@ -1,3 +1,4 @@ +---@diagnostic disable game.reload_script() for _, player in pairs(game.players) do diff --git a/prototypes/buildings/beacon.lua b/prototypes/buildings/beacon.lua index fe4159712..1aa9d5207 100644 --- a/prototypes/buildings/beacon.lua +++ b/prototypes/buildings/beacon.lua @@ -126,7 +126,7 @@ for i, setting in pairs(beacon_settings) do beacon.name = beacon_names[i] beacon.distribution_effectivity = settings.startup["future-beacons"].value and (0.2 * am * fm) or (0.5 * am * fm) beacon.energy_usage = 1000 * am * (fm ^ 3) .. "kW" - beacon.supply_area_distance = 64 - 16 * (am - 1) + beacon.supply_area_distance = 64 - 16 * (am - 1)--[[@as int]] if beacon.supply_area_distance < 2 then beacon.supply_area_distance = 2 end beacon.placeable_by = {item = "beacon", count = 1} beacon.localised_name = {"entity-name.new-beacon", tostring(am), tostring(fm)} @@ -152,8 +152,8 @@ data.raw.item.beacon.icon_size = 64 data.raw.item.beacon.stack_size = 20 data.raw.beacon.beacon.subgroup = data.raw.item.beacon.subgroup -data.raw.module["speed-module"].beacon_tint.primary = {0, 0.65, 1} -data.raw.module["speed-module-2"].beacon_tint.primary = {0, 0.65, 1} -data.raw.module["speed-module-3"].beacon_tint.primary = {0, 0.65, 1} +data.raw.module["speed-module"].beacon_tint--[[@cast -?]].primary = {0, 0.65, 1} +data.raw.module["speed-module-2"].beacon_tint--[[@cast -?]].primary = {0, 0.65, 1} +data.raw.module["speed-module-3"].beacon_tint--[[@cast -?]].primary = {0, 0.65, 1} TECHNOLOGY("effect-transmission"):add_prereq("diet-beacon") diff --git a/prototypes/buildings/diet-beacon.lua b/prototypes/buildings/diet-beacon.lua index 605ab3c98..22ad1d63f 100644 --- a/prototypes/buildings/diet-beacon.lua +++ b/prototypes/buildings/diet-beacon.lua @@ -144,6 +144,6 @@ for am = 5, 1, -1 do end end -data.raw.module["speed-module"].beacon_tint.primary = {0, 0.65, 1} -data.raw.module["speed-module-2"].beacon_tint.primary = {0, 0.65, 1} -data.raw.module["speed-module-3"].beacon_tint.primary = {0, 0.65, 1} +data.raw.module["speed-module"].beacon_tint--[[@cast -?]].primary = {0, 0.65, 1} +data.raw.module["speed-module-2"].beacon_tint--[[@cast -?]].primary = {0, 0.65, 1} +data.raw.module["speed-module-3"].beacon_tint--[[@cast -?]].primary = {0, 0.65, 1} diff --git a/prototypes/buildings/glassworks.lua b/prototypes/buildings/glassworks.lua index 7bf53b70a..eaa126cb3 100644 --- a/prototypes/buildings/glassworks.lua +++ b/prototypes/buildings/glassworks.lua @@ -112,7 +112,7 @@ for i = 1, 4 do } } - table.insert(graphics_set.working_visualisations, 1, { + table.insert(graphics_set.working_visualisations--[[@cast -?]], 1, { fadeout = true, animation = { filename = "__pycoalprocessinggraphics__/graphics/entity/glassworks/a1.png", diff --git a/prototypes/buildings/lab.lua b/prototypes/buildings/lab.lua index facf09e32..ca64f7ab0 100644 --- a/prototypes/buildings/lab.lua +++ b/prototypes/buildings/lab.lua @@ -14,6 +14,7 @@ ENTITY { --damaged_trigger_effect = hit_effects.entity(), tall = true, circuit_connector = circuit_connector_definitions.create_single( + ---@diagnostic disable-next-line: param-type-mismatch universal_connector_template, { variation = 26, main_offset = util.by_pixel( 53.625, -178.25), shadow_offset = util.by_pixel( 53.625, -178.25), show_shadow = true } ), @@ -136,10 +137,12 @@ if mods["DiscoScience"] then -- Remove the 3 glow layers -- We can remove only the first layer and not use the second layer in the overlay below for a less obvious effect for I = 1, 3 do - table.remove(data.raw.lab.lab.on_animation.layers, 2) + table.remove(data.raw.lab.lab.on_animation--[[@cast -?]].layers--[[@cast -?]], 2) end + ---@diagnostic disable-next-line: need-check-nil -- Overwrite on/off to the variant without blue lights embedded data.raw.lab.lab.on_animation.layers[1].filename = "__pycoalprocessinggraphics__/graphics/entity/lab-mk01/raw-bw.png" + ---@diagnostic disable-next-line: need-check-nil data.raw.lab.lab.off_animation.layers[1].filename = "__pycoalprocessinggraphics__/graphics/entity/lab-mk01/raw-bw.png" -- Overwrite the animation with ours data.raw.animation["discoscience/lab-storm"] = { diff --git a/prototypes/gui-style.lua b/prototypes/gui-style.lua index a985a2f83..6cf206162 100644 --- a/prototypes/gui-style.lua +++ b/prototypes/gui-style.lua @@ -81,8 +81,9 @@ style.py_schedule_move_button_alt = { } local graphics_set = table.deepcopy(data.raw["gui-style"].default.train_schedule_temporary_station_delete_button.default_graphical_set) --[[@as data.ElementImageSet]] -graphics_set.base.corner_size = 8 +graphics_set.base--[[@cast -?]].corner_size = 8 -- Removes black lines at right and bottom of shadow +---@cast graphics_set.shadow data.ElementImageSetLayer graphics_set.shadow.position = {467, 90} graphics_set.shadow.corner_size = 4 graphics_set.shadow.draw_type = "outer" diff --git a/prototypes/menu-simulations.lua b/prototypes/menu-simulations.lua index 7c6bd1a0a..734a47fe1 100644 --- a/prototypes/menu-simulations.lua +++ b/prototypes/menu-simulations.lua @@ -3,6 +3,7 @@ if not mods["pyindustry"] then end local menu_simulations = data.raw["utility-constants"]["default"].main_menu_simulations +---@cast menu_simulations -? -- do not work menu_simulations.nauvis_burner_city = nil diff --git a/prototypes/ores/borax.lua b/prototypes/ores/borax.lua index dafdb94ca..6784fe8db 100644 --- a/prototypes/ores/borax.lua +++ b/prototypes/ores/borax.lua @@ -1,5 +1,6 @@ local resource_autoplace = require "resource-autoplace" +---@diagnostic disable-next-line: need-check-nil data.raw.planet.nauvis.map_gen_settings.autoplace_controls["borax"] = {} data.raw.planet.nauvis.map_gen_settings.autoplace_settings.entity.settings["borax"] = {} diff --git a/prototypes/ores/niobium.lua b/prototypes/ores/niobium.lua index 6122e78ad..669a79618 100644 --- a/prototypes/ores/niobium.lua +++ b/prototypes/ores/niobium.lua @@ -1,5 +1,6 @@ local resource_autoplace = require "resource-autoplace" +---@diagnostic disable-next-line: need-check-nil data.raw.planet.nauvis.map_gen_settings.autoplace_controls["niobium"] = {} data.raw.planet.nauvis.map_gen_settings.autoplace_settings.entity.settings["niobium"] = {} diff --git a/prototypes/recipes/coal-processing-recipes.lua b/prototypes/recipes/coal-processing-recipes.lua index e8f48be97..4f5724417 100644 --- a/prototypes/recipes/coal-processing-recipes.lua +++ b/prototypes/recipes/coal-processing-recipes.lua @@ -930,7 +930,7 @@ RECIPE { {type = "item", name = "coal", amount = 1} }, energy_required = 0.5 -}:add_unlock("coal-processing-3") +}--[[@as data.RecipePrototype]]:add_unlock("coal-processing-3") RECIPE { type = "recipe", diff --git a/prototypes/recipes/fuel-canister-recipes.lua b/prototypes/recipes/fuel-canister-recipes.lua index 56b143dde..377eba226 100644 --- a/prototypes/recipes/fuel-canister-recipes.lua +++ b/prototypes/recipes/fuel-canister-recipes.lua @@ -24,10 +24,10 @@ RECIPE { for f, fluid in pairs(data.raw.fluid) do if fluid.fuel_value and not skipped_fluids[fluid.name] and fluid.auto_barrel ~= false then - local fluid_icon = table.deepcopy(fluid.icons) or {{icon = fluid.icon}} + local fluid_icon = table.deepcopy(fluid.icons) or {{icon = fluid.icon}}--[[@as data.IconData[] ]] -- Apply to each layer for _, icon in pairs(fluid_icon) do - icon.icon_size = icon.icon_size or fluid_icon.icon_size or fluid.icon_size or 64 + icon.icon_size = icon.icon_size or fluid.icon_size or 64 icon.scale = 16 / icon.icon_size -- 32 = 0.5, 64 = 0.25 end @@ -39,7 +39,7 @@ for f, fluid in pairs(data.raw.fluid) do local icons = {{icon = "__pycoalprocessinggraphics__/graphics/icons/jerry-can.png", icon_size = 64}} for _, icon in pairs(fluid_icon) do - icon.shift = icon.shift or {} + icon.shift = icon.shift or {}--[[@as data.Vector]] local x, y = icon.shift[1] or icon.shift.x or 0, icon.shift[2] or icon.shift.y or 0 icon.shift = {x, y + 2} table.insert(icons, icon) @@ -65,9 +65,9 @@ for f, fluid in pairs(data.raw.fluid) do local fuel_amount = 50 if string.match(fluid.fuel_value, "[kK]J") then - fuel_amount = math.ceil(10 / (string.match(fluid.fuel_value, "[%d%.]+") / 1000)) + fuel_amount = math.ceil(10 / (string.match(fluid.fuel_value, "[%d%.]+")--[[@as int]] / 1000)) elseif string.match(fluid.fuel_value, "[mM]J") then - fuel_amount = math.ceil(10 / (string.match(fluid.fuel_value, "[%d%.]+"))) + fuel_amount = math.ceil(10 / string.match(fluid.fuel_value, "[%d%.]+")--[[@as int]]) end RECIPE { diff --git a/prototypes/recipes/tailings-recipes.lua b/prototypes/recipes/tailings-recipes.lua index 4d480a503..819fd194a 100644 --- a/prototypes/recipes/tailings-recipes.lua +++ b/prototypes/recipes/tailings-recipes.lua @@ -25,11 +25,11 @@ local tailings_copper_iron = local tailings_borax_niobium = tailings_copper_iron:copy("tailings-borax-niobium"):add_unlock("fluid-separation") tailings_borax_niobium.localised_name = {"recipe-name.tailings-ore-extraction", {"item-name.raw-borax"}, {"item-name.niobium-ore"}, {"fluid-name.tar"}} -tailings_borax_niobium.icons[#tailings_borax_niobium.icons + 1] = {icon = "__pycoalprocessinggraphics__/graphics/icons/ores/borax-niobium.png", icon_size = 32} -tailings_borax_niobium.results[#tailings_borax_niobium.results + 1] = {type = "item", name = "raw-borax", amount = 1, independent_probability = 0.4} -tailings_borax_niobium.results[#tailings_borax_niobium.results + 1] = {type = "item", name = "niobium-ore", amount = 1, independent_probability = 0.4} +tailings_borax_niobium.icons--[[@cast -?]][#tailings_borax_niobium.icons + 1] = {icon = "__pycoalprocessinggraphics__/graphics/icons/ores/borax-niobium.png", icon_size = 32} +tailings_borax_niobium.results--[[@cast -?]][#tailings_borax_niobium.results + 1] = {type = "item", name = "raw-borax", amount = 1, independent_probability = 0.4} +tailings_borax_niobium.results--[[@cast -?]][#tailings_borax_niobium.results + 1] = {type = "item", name = "niobium-ore", amount = 1, independent_probability = 0.4} --Finally add the results to our original table (this would be so much easier when Recipe:Results is finished) -tailings_copper_iron.icons[#tailings_copper_iron.icons + 1] = {icon = "__pycoalprocessinggraphics__/graphics/icons/ores/copper-iron.png", icon_size = 32} -tailings_copper_iron.results[#tailings_copper_iron.results + 1] = {type = "item", name = "copper-ore", amount = 1, independent_probability = 0.4} -tailings_copper_iron.results[#tailings_copper_iron.results + 1] = {type = "item", name = "iron-ore", amount = 1, independent_probability = 0.4} +tailings_copper_iron.icons--[[@cast -?]][#tailings_copper_iron.icons + 1] = {icon = "__pycoalprocessinggraphics__/graphics/icons/ores/copper-iron.png", icon_size = 32} +tailings_copper_iron.results--[[@cast -?]][#tailings_copper_iron.results + 1] = {type = "item", name = "copper-ore", amount = 1, independent_probability = 0.4} +tailings_copper_iron.results--[[@cast -?]][#tailings_copper_iron.results + 1] = {type = "item", name = "iron-ore", amount = 1, independent_probability = 0.4} diff --git a/prototypes/updates/base-updates.lua b/prototypes/updates/base-updates.lua index 7913e34d9..3139267d2 100644 --- a/prototypes/updates/base-updates.lua +++ b/prototypes/updates/base-updates.lua @@ -53,14 +53,14 @@ TECHNOLOGY("rocket-silo"):add_pack("military-science-pack") TECHNOLOGY("research-speed-6"):add_pack("military-science-pack") TECHNOLOGY("logistic-system"):add_pack("military-science-pack"):add_pack("production-science-pack") TECHNOLOGY("worker-robots-speed-5"):add_pack("military-science-pack") -TECHNOLOGY("worker-robots-speed-6"):add_pack("military-science-pack").unit.count_formula = "1.5^(L-6)*1000" +TECHNOLOGY("worker-robots-speed-6"):add_pack("military-science-pack").unit--[[@as data.TechnologyUnit]].count_formula = "1.5^(L-6)*1000" TECHNOLOGY("worker-robots-storage-3"):add_pack("military-science-pack") TECHNOLOGY("personal-roboport-mk2-equipment"):add_pack("military-science-pack"):add_pack("production-science-pack") TECHNOLOGY("mining-productivity-3"):add_pack("military-science-pack") -data.raw.technology["artillery-shell-range-1"].unit.count_formula = nil +data.raw.technology["artillery-shell-range-1"].unit--[[@cast -?]].count_formula = nil -data.raw.technology.artillery.unit.ingredients = { +data.raw.technology.artillery.unit--[[@cast -?]].ingredients = { {"automation-science-pack", 1}, {"logistic-science-pack", 1}, {"chemical-science-pack", 1}, @@ -68,7 +68,7 @@ data.raw.technology.artillery.unit.ingredients = { } data.raw.technology.artillery.prerequisites = {"military"} -data.raw.technology["artillery-shell-speed-1"].unit.ingredients = { +data.raw.technology["artillery-shell-speed-1"].unit--[[@cast -?]].ingredients = { {"automation-science-pack", 1}, {"logistic-science-pack", 1}, {"chemical-science-pack", 1}, @@ -76,7 +76,7 @@ data.raw.technology["artillery-shell-speed-1"].unit.ingredients = { } data.raw.technology["artillery-shell-speed-1"].prerequisites = {"artillery"} -data.raw.technology.tank.unit.ingredients = { +data.raw.technology.tank.unit--[[@cast -?]].ingredients = { {"automation-science-pack", 1}, {"logistic-science-pack", 1}, {"chemical-science-pack", 1}, @@ -84,7 +84,7 @@ data.raw.technology.tank.unit.ingredients = { } data.raw.technology.tank.prerequisites = {} -data.raw.technology["uranium-ammo"].unit.ingredients = { +data.raw.technology["uranium-ammo"].unit--[[@cast -?]].ingredients = { {"automation-science-pack", 1}, {"logistic-science-pack", 1}, {"military-science-pack", 1}, @@ -281,12 +281,12 @@ TECHNOLOGY("automated-rail-transportation"):remove_pack("logistic-science-pack") data.raw.pump.pump.pumping_speed = data.raw.pump.pump.pumping_speed * 10 -table.insert(data.raw["technology"]["steam-power"].effects, table.remove(data.raw.technology["circuit-network"].effects, 1)) +table.insert(data.raw["technology"]["steam-power"].effects--[[@cast -?]], table.remove(data.raw.technology["circuit-network"].effects--[[@cast -?]], 1)) RECIPE("engine-unit"):replace_category("advanced-crafting", "crafting") RECIPE("selector-combinator"):remove_ingredient("advanced-circuit"):add_ingredient {type = "item", name = "electronic-circuit", amount = 5} -TECHNOLOGY("advanced-combinators").unit.ingredients = mods.pyalienlife and { +TECHNOLOGY("advanced-combinators").unit--[[@as data.TechnologyUnit]].ingredients = mods.pyalienlife and { {"automation-science-pack", 1}, {"py-science-pack-1", 1}, } or { @@ -309,8 +309,8 @@ local starting_techs = { } for _, t in pairs(starting_techs) do - t = data.raw.technology[t] - if t then t.prerequisites = {"automation-science-pack"} end + tech = data.raw.technology[t] + if tech then tech.prerequisites = {"automation-science-pack"} end ::continue:: end @@ -372,8 +372,6 @@ big_fluid_icons_for_pipes("niobium-pipe-to-ground") big_fluid_icons_for_pipes("ht-pipes") big_fluid_icons_for_pipes("ht-pipes-to-ground") -data.raw["utility-constants"]["default"].max_fluid_flow = math.max(data.raw["utility-constants"]["default"].max_fluid_flow or 0, 500) - data.raw["technology"]["efficiency-module"].prerequisites = {mods.pyalternativeenergy and "machine-components-mk02" or "productivity-module"} data.raw["technology"]["bulk-inserter"].prerequisites = {mods.pyhightech and "basic-electronics" or "chemical-science-pack"} if data.raw["technology"]["bulk-inserter-2"] then data.raw["technology"]["bulk-inserter-2"].prerequisites = {"bulk-inserter"} end diff --git a/prototypes/updates/pyindustry-updates.lua b/prototypes/updates/pyindustry-updates.lua index eee1ce49b..9f56d5f38 100644 --- a/prototypes/updates/pyindustry-updates.lua +++ b/prototypes/updates/pyindustry-updates.lua @@ -25,6 +25,6 @@ RECIPE { } }:add_unlock("py-asphalt-mk03"):add_ingredient {type = "fluid", name = "flue-gas", amount = 200}:add_ingredient {type = "item", name = "small-parts-01", amount = 10} -data.raw["container"]["py-logo-15tiles"].minable.result = "py-logo-15tiles" +data.raw["container"]["py-logo-15tiles"].minable--[[@cast -?]].result = "py-logo-15tiles" RECIPE("niobium-pipe"):remove_unlock("py-storage-tanks"):add_unlock("niobium") RECIPE("niobium-pipe-to-ground"):remove_unlock("py-storage-tanks"):add_unlock("niobium") diff --git a/scripts/beacons.lua b/scripts/beacons.lua index f46e6f282..aa78dbfaa 100644 --- a/scripts/beacons.lua +++ b/scripts/beacons.lua @@ -1,3 +1,10 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + +---@class (partial) PyCoalProcessingStorage +---@field beacon_interference_alerts table + Beacons = {} Beacons.events = {} @@ -103,7 +110,7 @@ local function disable_entity(entity) end ---@param reciever LuaEntity ----@return boolean interference +---@return boolean? interference local function beacon_check(reciever) local name = reciever.name:gsub("%-mk..+", "") if blacklist[name] ~= nil then return end @@ -186,7 +193,7 @@ local function change_frequency(entity, new_beacon_name, player_index) -- player.undo_redo_stack.remove_undo_action(index, action) -- remove old action from queue -- end -- Get new effect receivers - for _, receiver in pairs(new_entity.get_beacon_effect_receivers()) do + for _, receiver in pairs(new_entity--[[@cast -?]].get_beacon_effect_receivers()) do receivers[receiver.unit_number] = receiver end -- Check all receivers @@ -211,7 +218,7 @@ local beacon_ghosts = {} -- If a pipette is placed on top of a ghost, the AM/FM setting is lost without script intervention Beacons.events.on_pre_build = function(event) if event.build_mode ~= defines.build_mode.normal then return end - local surface = game.get_player(event.player_index).surface + local surface = game.get_player(event.player_index)--[[@cast -?]].surface local colliding_ghost = surface.find_entity("entity-ghost", event.position) beacon_ghosts[event.player_index] = colliding_ghost and our_beacons[colliding_ghost.ghost_name] and colliding_ghost.ghost_name or nil end @@ -236,7 +243,7 @@ Beacons.events.on_built = function(event) alert = beacon_check(entity) end if event.player_index and alert then - game.get_player(event.player_index).play_sound{path="utility/alert_destroyed"} + game.get_player(event.player_index)--[[@cast -?]].play_sound{path="utility/alert_destroyed"} end end diff --git a/scripts/milestones.lua b/scripts/milestones.lua index 6c48e871a..4ccfc0941 100644 --- a/scripts/milestones.lua +++ b/scripts/milestones.lua @@ -455,7 +455,7 @@ remote.add_interface("pycoalprocessing", { "-mk03", "-mk04", } - local insert_index + local insert_index = 1 for index, milestone in pairs(preset.milestones) do if milestone.name == "Flora and Fauna" and milestone.type == "group" then insert_index = index + 1 diff --git a/scripts/programmable-inserter.lua b/scripts/programmable-inserter.lua index e781fd1c5..34e8a69f5 100644 --- a/scripts/programmable-inserter.lua +++ b/scripts/programmable-inserter.lua @@ -1,3 +1,10 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + +---@class (partial) PyCoalProcessingStorage +---@field programmable_inserters table + -- save a list of all valid targets, valid inventories for that target, and associated locale key for that inventory local proxy_targets = { ["furnace"] = { @@ -137,7 +144,7 @@ end local function update_gui(entity, player_index) if not entity or (entity.type == "entity-ghost" and entity.ghost_type or entity.type) ~= "inserter" then return end if not valid(entity.unit_number) then return end - local player = game.get_player(player_index) + local player = game.get_player(player_index)--[[@as LuaPlayer]] local tags = (entity.tags or {})["py-dynamic-inserter"] @@ -276,13 +283,15 @@ end -- TODO fix upgrade events breaking it py.on_event(py.events.on_gui_opened(), function (event) - if game.get_player(event.player_index).opened_gui_type ~= defines.gui_type.entity then return end + if game.get_player(event.player_index)--[[@cast -?]].opened_gui_type ~= defines.gui_type.entity then return end update_gui(event.entity, event.player_index) end) py.on_event(defines.events.on_gui_closed, function (event) - if game.get_player(event.player_index).gui.relative["programmable-inserter-gui"] and game.get_player(event.player_index).gui.relative["programmable-inserter-gui"].visible then - game.get_player(event.player_index).gui.relative["programmable-inserter-gui"].visible = false + if game.get_player(event.player_index)--[[@cast -?]].gui.relative["programmable-inserter-gui"] and + game.get_player(event.player_index)--[[@cast -?]].gui.relative["programmable-inserter-gui"].visible + then + game.get_player(event.player_index)--[[@cast -?]].gui.relative["programmable-inserter-gui"].visible = false end end) @@ -290,7 +299,7 @@ py.on_event(defines.events.on_gui_selection_state_changed, function (event) local element = event.element if not element or element.get_mod() ~= "pycoalprocessing" or element.type ~= "drop-down" then return end - local player = game.get_player(event.player_index) + local player = game.get_player(event.player_index)--[[@as LuaPlayer]] local inserter = player.opened if not inserter then return end @@ -300,7 +309,7 @@ py.on_event(defines.events.on_gui_selection_state_changed, function (event) local tags = inserter.tags or {} tags["py-dynamic-inserter"] = tags["py-dynamic-inserter"] or {} tags["py-dynamic-inserter"][element.name .. "_inventory"] = element.selected_index ~= 1 and selection or nil - if not tags["py-dynamic-inserter"].drop_target_inventory and not tags["py-dynamic-inserter"].pickup_target_inventory then tags["py-dynamic-inserter"] = nil end + if not tags["py-dynamic-inserter"].drop_target_inventory and not tags["py-dynamic-inserter"]--[[@as table]].pickup_target_inventory then tags["py-dynamic-inserter"] = nil end inserter.tags = tags else local metadata = storage.programmable_inserters[inserter.unit_number] or { inserter = inserter } @@ -320,11 +329,11 @@ py.on_event(defines.events.on_gui_selection_state_changed, function (event) -- save the target inventory metadata[element.name .. "_inventory"] = selection -- create proxy container if required - metadata[element.name] = metadata[element.name] or inserter.surface.create_entity{ + metadata[element.name] = metadata[element.name] or inserter.surface--[[@cast -?]].create_entity{ name = "py-dynamic-inserter-target", force = inserter.force, position = inserter[element.name:sub(1, -7) .. "position"] - } + }--[[@as LuaSurface.create_entity_param]] -- set target entity inserter[element.name] = metadata[element.name] @@ -487,9 +496,9 @@ end) ---@param event EventData.on_player_setup_blueprint py.on_event(defines.events.on_player_setup_blueprint, function (event) - local blueprint = game.get_player(event.player_index).blueprint_to_setup + local blueprint = game.get_player(event.player_index)--[[@cast -?]].blueprint_to_setup--[[@as LuaItemStack?]] -- if normally invalid - if not blueprint or not blueprint.valid_for_read then blueprint = game.get_player(event.player_index).cursor_stack end + if not blueprint or not blueprint.valid_for_read then blueprint = game.get_player(event.player_index)--[[@cast -?]].cursor_stack end -- if non existant, cancel if not blueprint then return end local entities = blueprint.get_blueprint_entities() @@ -516,23 +525,32 @@ py.on_event(defines.events.on_player_setup_blueprint, function (event) end) if script.active_mods["quick-adjustable-inserters"] then + ---@diagnostic disable-next-line: undefined-field if defines.events.on_qai_inserter_vectors_changed then + ---@diagnostic disable-next-line: undefined-field, type-not-found, param-type-mismatch ---@param event EventData.on_qai_inserter_vectors_changed script.on_event(defines.events.on_qai_inserter_vectors_changed, function(event) - update_targets(event.inserter) + ---@diagnostic disable-next-line: undefined-field + update_targets(event.inserter) end) end + ---@diagnostic disable-next-line: undefined-field if defines.events.on_qai_inserter_adjustment_finished then + ---@diagnostic disable-next-line: undefined-field, type-not-found, param-type-mismatch ---@param event EventData.on_qai_inserter_adjustment_finished script.on_event(defines.events.on_qai_inserter_adjustment_finished, function(event) + ---@diagnostic disable-next-line: undefined-field update_targets(event.inserter) end) end end +---@diagnostic disable-next-line: undefined-field if script.active_mods["bobinserters"] and defines.events.on_bobs_inserter_adjusted then + ---@diagnostic disable-next-line: undefined-field script.on_event(defines.events.on_bobs_inserter_adjusted, function (event) + ---@diagnostic disable-next-line: undefined-field update_targets(event.entity) end) end \ No newline at end of file diff --git a/scripts/tailings-pond.lua b/scripts/tailings-pond.lua index b7258005a..6a0f97d7f 100644 --- a/scripts/tailings-pond.lua +++ b/scripts/tailings-pond.lua @@ -1,3 +1,11 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + +---@class (partial) PyCoalProcessingStorage +---@field tailings_ponds table +---@field tiles table + Pond = {} Pond.events = {} @@ -37,7 +45,6 @@ local gasses = { py.on_event(py.events.on_init(), function() storage.tailings_ponds = storage.tailings_ponds or {} storage.tiles = storage.tiles or {} - storage.Tiles = nil end) --Pond contains gases, lets spill them out. Only negative is this can be used as a 'gas' void so... @@ -86,7 +93,7 @@ local function set_fluid_level_image(pond) end local color if pond.entity.get_fluid(1) then - color = prototypes.fluid[pond.entity.get_fluid(1).name].base_color + color = prototypes.fluid[pond.entity.get_fluid(1)--[[@cast -?]].name].base_color end pond.sprite = rendering.draw_sprite { sprite = "tailings-pond-sprite-" .. fill_level, @@ -118,7 +125,7 @@ local function scorch_earth(pond) local surface = entity.surface --Vent Gasses - fluid = empty_pond_gas(fluid, surface, entity.position) + fluid = empty_pond_gas(fluid--[[@cast -?]], surface, entity.position) if not fluid or fluid.amount == 0 then -- totally drained pond.fluid_per = 0 entity.clear_fluid(1) @@ -142,15 +149,15 @@ local function scorch_earth(pond) if not is_water then pond.lifetime_pollution_tiles_created = (pond.lifetime_pollution_tiles_created or 0) + 1 local x, y = spiral(pond.lifetime_pollution_tiles_created) - x = math.floor(x + entity.position.x) - 1 - y = math.floor(y + entity.position.y) - 1 + x = math.floor(x + entity.position.x--[[@as number]]) - 1 + y = math.floor(y + entity.position.y--[[@as number]]) - 1 if surface.get_tile(x, y).name ~= "polluted-ground" then tiles[#tiles + 1] = {name = "polluted-ground", position = {x = x, y = y}} end end until amount < threshold_in_units -- add fluid consumed to production stats graph - entity.force.get_fluid_production_statistics(surface).on_flow(fluid.name, amount - fluid.amount) + entity.force--[[@as LuaForce]].get_fluid_production_statistics(surface).on_flow(fluid.name, amount - fluid.amount) fluid.amount = amount end @@ -158,7 +165,7 @@ local function scorch_earth(pond) --push the updated fluidbox to the entity. if fluid.amount <= 0 then entity.clear_fluid(1) - elseif fluid.amount ~= entity.get_fluid(1).amount then + elseif fluid.amount ~= entity.get_fluid(1)--[[@cast -?]].amount then fluid.amount = fluid.amount * segment_size / tanksize entity.set_fluid(1, fluid) end @@ -172,7 +179,7 @@ Pond.events.on_built = function(event) entity = entity, fluid_per = 0 } - set_fluid_level_image(pond) + set_fluid_level_image(pond--[[@as TailingsPond]]) storage.tailings_ponds[entity.unit_number] = pond end diff --git a/scripts/wiki/spreadsheet-pages.lua b/scripts/wiki/spreadsheet-pages.lua index db6f0b276..6fa5f8874 100644 --- a/scripts/wiki/spreadsheet-pages.lua +++ b/scripts/wiki/spreadsheet-pages.lua @@ -1,3 +1,7 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + local spreadsheet_row_functions = {} local floor = math.floor @@ -68,7 +72,7 @@ local function update_spreadsheet(gui, player, data, sort_by, asc) data.prefered_sorts[player.index] = {sort_by, asc} - local search_key = remote.call("pywiki", "get_page_searchbar", player).text + local search_key = remote.call("pywiki", "get_page_searchbar", player)--[[@cast -?]].text on_search(search_key, gui) end @@ -107,6 +111,12 @@ local function create_spreadsheet(gui, player, data) update_spreadsheet(gui, player, data, sort_by, asc) end +---@class (partial) PyCoalProcessingStorage +---@field fluid_spreadsheet_data table +---@field solid_fuel_spreadsheet_data table +---@field item_decay_spreadsheet_data table +---@field recipe_decay_spreadsheet_data table + remote.add_interface("pywiki_spreadsheets", { create_fluid_page = function(gui, player) create_spreadsheet(gui, player, storage.fluid_spreadsheet_data) end, create_solid_fuel_page = function(gui, player) create_spreadsheet(gui, player, storage.solid_fuel_spreadsheet_data) end, @@ -132,7 +142,7 @@ local function hue(color) local max = math.max(math.max(red, green), blue) if min == max then return 0 end - local hue = 0 + local hue = 0.0 if max == red then hue = (green - blue) / (max - min) elseif max == green then @@ -369,26 +379,28 @@ local function decay_result_builder(flow, item) if not item.valid then return end local decay_result = "" - local decay_chain = {} + local decay_chain = {}--[[@as LuaItemPrototype[] ]] local already_seen = {} local total_decay_ticks = 0 + local total_decay_ticks_string if item.spoil_to_trigger_result then flow.add {type = "label", caption = "[Trigger]"} return "trigger", item.get_spoil_ticks(), {item}, {[item.name] = true} end - local spoilage_item = item + local spoilage_item = item--[[@as LuaItemPrototype?]] while spoilage_item do table.insert(decay_chain, spoilage_item) if already_seen[spoilage_item.name] then - total_decay_ticks = "[color=255,170,0] ∞ [/color]" + total_decay_ticks_string = "[color=255,170,0] ∞ [/color]" break end total_decay_ticks = total_decay_ticks + spoilage_item.get_spoil_ticks() already_seen[spoilage_item.name] = true spoilage_item = spoilage_item.spoil_result end + total_decay_ticks_string = tostring(total_decay_ticks) local arrow_emoji = "[font=default-bold][color=255,200,200] → [/color][/font]" for i = 1, #decay_chain do local spoilage_item = decay_chain[i] @@ -400,7 +412,7 @@ local function decay_result_builder(flow, item) end end - return decay_result, total_decay_ticks, decay_chain, already_seen + return decay_result, total_decay_ticks_string, decay_chain, already_seen end spreadsheet_row_functions.decay_result_builder = decay_result_builder diff --git a/scripts/wiki/statistics-page.lua b/scripts/wiki/statistics-page.lua index dbeea95c4..b8c6f982d 100644 --- a/scripts/wiki/statistics-page.lua +++ b/scripts/wiki/statistics-page.lua @@ -63,11 +63,10 @@ for _, animal in pairs(animals) do creature_names[animal .. "-mk03"] = true creature_names[animal .. "-mk04"] = true end -animals = nil local function comma_value(n) local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$") - return left .. (num:reverse():gsub("(%d%d%d)", "%1,"):reverse()) .. right + return left .. (num--[[@cast -?]]:reverse():gsub("(%d%d%d)", "%1,"):reverse()) .. right end local floor = math.floor @@ -78,14 +77,14 @@ local function calculate_statistics(player, include_laggy_calculations) local statistics = {} statistics.hour = floor(game.tick / 60 / 60 / 60) - statistics.minute = floor(game.tick / 60 / 60) % 60 + statistics.minute = tostring(floor(game.tick / 60 / 60) % 60) if statistics.minute < 10 then statistics.minute = "0" .. statistics.minute end - statistics.second = floor(game.tick / 60) % 60 + statistics.second = tostring(floor(game.tick / 60) % 60) if statistics.second < 10 then statistics.second = "0" .. statistics.second end local daytime = surface.daytime * 24 statistics.daytime_hour = floor(daytime) - statistics.daytime_minute = floor(daytime * 60) % 60 + statistics.daytime_minute = tostring(floor(daytime * 60) % 60) if statistics.daytime_minute < 10 then statistics.daytime_minute = "0" .. statistics.daytime_minute end if statistics.daytime_hour == 24 then statistics.daytime_hour = 0 @@ -174,7 +173,7 @@ local function calculate_statistics(player, include_laggy_calculations) statistics.losses = floor(losses) statistics.kills = floor(kills) - statistics.pollution = 0 + statistics.pollution = 0.0 for _, count in pairs(game.get_pollution_statistics(surface).input_counts) do statistics.pollution = statistics.pollution + count end diff --git a/scripts/wiki/text-pages.lua b/scripts/wiki/text-pages.lua index c72781a63..48a6691ed 100644 --- a/scripts/wiki/text-pages.lua +++ b/scripts/wiki/text-pages.lua @@ -1,3 +1,12 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + +---@class (partial) PyCoalProcessingStorage +---@field wiki_pages table +---@field currently_opened_wiki_page table +---@field wiki_page_search_query table + py.on_event(py.events.on_init(), function() for _, player in pairs(game.players) do Wiki.create_pywiki_button(player) diff --git a/scripts/wiki/wiki.lua b/scripts/wiki/wiki.lua index b48686aa9..e0eab9a70 100644 --- a/scripts/wiki/wiki.lua +++ b/scripts/wiki/wiki.lua @@ -1,3 +1,7 @@ +---@namespace PyCoalProcessing +---@type PyCoalProcessingStorage +storage = storage --[[@as PyCoalProcessingStorage]] + Wiki = {} Wiki.events = {} @@ -116,10 +120,11 @@ function Wiki.close_wiki(player) local pages = Wiki.get_pages(player) if pages then - local page_data = pages.tags.contents[pages.selected_index] + local page_data = pages.tags.contents[pages.selected_index]--[[@as table]] if page_data and page_data.on_closed then - local on_closed = page_data.on_closed - remote.call(on_closed[1], on_closed[2], contents, player) + local on_closed = page_data.on_closed--[[@as table]] + ---@diagnostic disable-next-line: param-type-mismatch + remote.call(on_closed[1], on_closed[2], nil, player) end end -- https://github.com/pyanodon/pybugreports/issues/820 @@ -256,6 +261,7 @@ gui_events[defines.events.on_gui_text_changed]["py_wiki_search"] = function(even remote.call(searchable[1], searchable[2], search_query, contents, player) end +---@diagnostic disable-next-line: param-type-mismatch remote.add_interface("pywiki", { add_page = Wiki.add_page, add_section = Wiki.add_section,