No more warnings

This commit is contained in:
Cooldude2606
2024-09-28 03:46:14 +01:00
parent 32a8ba8f3a
commit 3145f7e904
43 changed files with 215 additions and 177 deletions

View File

@@ -39,7 +39,7 @@ Commands.new_command("admin-marker", { "expcom-admin-marker.description" }, "Tog
--- Listen for new map markers being added, add admin marker if done by player in admin mode
Event.add(defines.events.on_chart_tag_added, function(event)
if not event.player_index then return end
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
if not admins[player.name] then return end
local tag = event.tag
markers[tag.force.name .. tag.tag_number] = true
@@ -49,7 +49,7 @@ end)
--- Listen for players leaving the game, leave admin mode to avoid unexpected admin markers
Event.add(defines.events.on_player_left_game, function(event)
if not event.player_index then return end
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
admins[player.name] = nil
end)
@@ -58,7 +58,7 @@ local function maintain_tag(event)
local tag = event.tag
if not event.player_index then return end
if not markers[tag.force.name .. tag.tag_number] then return end
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
if player.admin then
-- Player is admin, tell them it was an admin marker
Commands.print({ "expcom-admin-marker.edit" }, nil, player)

View File

@@ -33,7 +33,7 @@ end
--- when an area is selected to add protection to the area
Selection.on_selection(SelectionArtyArea, function(event)
local area = aabb_align_expand(event.area)
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
if player == nil then
return

View File

@@ -63,7 +63,7 @@ Commands.new_command("connect", { "expcom-connect.description" }, "Connect to an
server_id = new_server_id
end
Async(request_connection, player, server_id, true)
request_connection_async(player, server_id, true)
end)
--- Connect a player to a different server

View File

@@ -27,6 +27,7 @@ Commands.new_command("search-help", { "expcom-chelp.description" }, "Searches fo
local player_index = player and player.index or 0
-- if keyword is a number then treat it as page number
if tonumber(keyword) then
--- @diagnostic disable-next-line: param-type-mismatch
page = math.floor(tonumber(keyword))
keyword = ""
end

View File

@@ -88,6 +88,7 @@ Commands.new_command("interface", { "expcom-interface.description" }, "Sends an
-- Compile the invocation with the custom _env value
local invocation_func, compile_error = load(invocation, "interface", nil, _env)
if compile_error then return Commands.error(compile_error) end
--- @cast invocation_func -nil
-- Run the invocation
local success, rtn = pcall(invocation_func)

View File

@@ -28,9 +28,9 @@ local function aabb_point_enclosed(point, aabb)
end
--- Test if an aabb is inside another aabb
local function aabb_area_enclosed(aabbOne, aabbTwo)
return aabb_point_enclosed(aabbOne.left_top, aabbTwo)
and aabb_point_enclosed(aabbOne.right_bottom, aabbTwo)
local function aabb_area_enclosed(aabb_one, aabb_two)
return aabb_point_enclosed(aabb_one.left_top, aabb_two)
and aabb_point_enclosed(aabb_one.right_bottom, aabb_two)
end
--- Align an aabb to the grid by expanding it
@@ -89,8 +89,8 @@ end
--- Remove a render object for a player
local function remove_render(player, key)
local render = renders[player.index][key]
if render and rendering.is_valid(render) then rendering.destroy(render) end
local render = renders[player.index][key] --[[@as LuaRenderObject]]
if render and render.valid then render.destroy() end
renders[player.index][key] = nil
end
@@ -122,7 +122,7 @@ Commands.new_command("protect-area", { "expcom-protection.description-pa" }, "To
--- When an area is selected to add protection to entities
Selection.on_selection(SelectionProtectEntity, function(event)
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
for _, entity in ipairs(event.entities) do
EntityProtection.add_entity(entity)
show_protected_entity(player, entity)
@@ -133,7 +133,7 @@ end)
--- When an area is selected to remove protection from entities
Selection.on_alt_selection(SelectionProtectEntity, function(event)
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
for _, entity in ipairs(event.entities) do
EntityProtection.remove_entity(entity)
remove_render(player, get_entity_key(entity))
@@ -146,7 +146,7 @@ end)
Selection.on_selection(SelectionProtectArea, function(event)
local area = aabb_align_expand(event.area)
local areas = EntityProtection.get_areas(event.surface)
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
for _, next_area in pairs(areas) do
if aabb_area_enclosed(area, next_area) then
return player.print{ "expcom-protection.already-protected" }
@@ -162,7 +162,7 @@ end)
Selection.on_alt_selection(SelectionProtectArea, function(event)
local area = aabb_align_expand(event.area)
local areas = EntityProtection.get_areas(event.surface)
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
for _, next_area in pairs(areas) do
if aabb_area_enclosed(next_area, area) then
EntityProtection.remove_area(event.surface, next_area)
@@ -175,7 +175,7 @@ end)
--- When selection starts show all protected entities and protected areas
Event.add(Selection.events.on_player_selection_start, function(event)
if event.selection ~= SelectionProtectEntity and event.selection ~= SelectionProtectArea then return end
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
local surface = player.surface
renders[player.index] = {}
-- Show protected entities
@@ -206,8 +206,8 @@ end)
--- When selection ends hide protected entities and protected areas
Event.add(Selection.events.on_player_selection_end, function(event)
if event.selection ~= SelectionProtectEntity and event.selection ~= SelectionProtectArea then return end
for _, id in pairs(renders[event.player_index]) do
if rendering.is_valid(id) then rendering.destroy(id) end
for _, render in pairs(renders[event.player_index]) do
if render.valid then render.destroy() end
end
renders[event.player_index] = nil

View File

@@ -35,7 +35,7 @@ Commands.new_command("waterfill", { "expcom-waterfill.description" }, "Change ti
--- When an area is selected to add protection to the area
Selection.on_selection(SelectionConvertArea, function(event)
local area = aabb_align_expand(event.area)
local player = game.get_player(event.player_index)
local player = game.players[event.player_index]
if not player then
return