Enable stricter type checks

This commit is contained in:
Cooldude2606
2024-11-21 00:03:19 +00:00
parent 51c9356ecc
commit 99ab54da0a
11 changed files with 67 additions and 37 deletions

View File

@@ -1,18 +1,21 @@
local Commands = require("modules/exp_commands")
local config = require("modules.exp_legacy.config.personal_logistic") --- @dep config.personal-logistic
local function pl(type, target, amount)
---@param target LuaEntity | LuaPlayer
---@param amount number
local function pl(target, amount)
local c
local s
if type == "p" then
--- @cast target any Remove cast once implemented
error("Needs updating to use 2.0 logistics")
if target.object_name == "LuaPlayer" then
c = target.clear_personal_logistic_slot
s = target.set_personal_logistic_slot
elseif type == "s" then
else
c = target.clear_vehicle_logistic_slot
s = target.set_vehicle_logistic_slot
else
return
end
for _, v in pairs(config.request) do
@@ -69,15 +72,16 @@ end
Commands.new("personal-logistic", "Set Personal Logistic (-1 to cancel all) (Select spidertron to edit spidertron)")
:argument("amount", "", Commands.types.integer_range(-1, 10))
:add_aliases{ "pl" }
:add_flags{ "disabled" } -- Remove once implemented above
:register(function(player, amount)
--- @cast amount number
if player.force.technologies["logistic-robotics"].researched then
if player.selected ~= nil then
if player.selected.name == "spidertron" then
pl("s", player.selected, amount / 10)
pl(player.selected, amount / 10)
end
else
pl("p", player, amount / 10)
pl(player, amount / 10)
end
else
return Commands.status.error("Personal Logistic not researched")