mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-12 16:35:11 +09:00
Assert the remaining optional reads in exp_util and commands
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,13 +28,13 @@ end)
|
||||
--- Allow a player access to system commands, use for debug purposes only
|
||||
--- @param player_name string? The name of the player to give access to, default is the current player
|
||||
function Commands.unlock_system_commands(player_name)
|
||||
system_players[player_name or game.player.name] = true
|
||||
system_players[player_name or assert(game.player).name] = true
|
||||
end
|
||||
|
||||
--- Remove access from system commands for a player, use for debug purposes only
|
||||
--- @param player_name string? The name of the player to give access to, default is the current player
|
||||
function Commands.lock_system_commands(player_name)
|
||||
system_players[player_name or game.player.name] = nil
|
||||
system_players[player_name or assert(game.player).name] = nil
|
||||
end
|
||||
|
||||
--- Get a list of all players who have system commands unlocked
|
||||
|
||||
@@ -25,7 +25,7 @@ Commands.new("kill", { "exp-commands_kill.description" })
|
||||
if script.active_mods["space-age"] then
|
||||
other_player.surface.create_entity{ name = "lightning", position = { other_player.position.x, other_player.position.y - 16 }, target = other_player.character }
|
||||
end
|
||||
other_player.character.die()
|
||||
assert(other_player.character).die()
|
||||
else
|
||||
return Commands.status.unauthorised{ "exp-commands_kill.lower-role" }
|
||||
end
|
||||
|
||||
@@ -319,15 +319,15 @@ function ExpUtil.extract_time_units(ticks, units)
|
||||
|
||||
-- Remove units that are not requested
|
||||
if not units.days then
|
||||
rtn.hours = rtn.hours + rtn.days * 24
|
||||
rtn.hours = assert(rtn.hours) + assert(rtn.days) * 24
|
||||
rtn.days = nil
|
||||
end
|
||||
if not units.hours then
|
||||
rtn.minutes = rtn.minutes + rtn.hours * 60
|
||||
rtn.minutes = assert(rtn.minutes) + assert(rtn.hours) * 60
|
||||
rtn.hours = nil
|
||||
end
|
||||
if not units.minutes then
|
||||
rtn.seconds = rtn.seconds + rtn.minutes * 60
|
||||
rtn.seconds = assert(rtn.seconds) + assert(rtn.minutes) * 60
|
||||
rtn.minutes = nil
|
||||
end
|
||||
if not units.seconds then
|
||||
@@ -487,7 +487,7 @@ function ExpUtil.get_storage_for_stack(options)
|
||||
-- Find a valid entity from the search results
|
||||
local current, count, entities = cache.current, cache.count, cache.entities
|
||||
for i = 1, cache.count do
|
||||
local entity = entities[((current + i - 1) % count) + 1]
|
||||
local entity = assert(entities[((current + i - 1) % count) + 1])
|
||||
if entity.can_insert(item) then
|
||||
cache.current = current + 1
|
||||
return entity
|
||||
@@ -551,7 +551,7 @@ function ExpUtil.move_items_to_surface(options)
|
||||
options.item = item
|
||||
entity = ExpUtil.get_storage_for_stack(options)
|
||||
entity.insert(options.item)
|
||||
options.item.clear()
|
||||
assert(options.item).clear()
|
||||
end
|
||||
end
|
||||
return entity
|
||||
@@ -603,7 +603,8 @@ end
|
||||
--- @param n number
|
||||
--- @return string
|
||||
function ExpUtil.comma_value(n) -- credit http://richard.warburton.it
|
||||
local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$")
|
||||
local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$")
|
||||
assert(left and num and right)
|
||||
return left .. (num:reverse():gsub("(%d%d%d)", "%1, "):reverse()) .. right
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user