mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-08-13 00:45: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
|
--- 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
|
--- @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)
|
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
|
end
|
||||||
|
|
||||||
--- Remove access from system commands for a player, use for debug purposes only
|
--- 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
|
--- @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)
|
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
|
end
|
||||||
|
|
||||||
--- Get a list of all players who have system commands unlocked
|
--- 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
|
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 }
|
other_player.surface.create_entity{ name = "lightning", position = { other_player.position.x, other_player.position.y - 16 }, target = other_player.character }
|
||||||
end
|
end
|
||||||
other_player.character.die()
|
assert(other_player.character).die()
|
||||||
else
|
else
|
||||||
return Commands.status.unauthorised{ "exp-commands_kill.lower-role" }
|
return Commands.status.unauthorised{ "exp-commands_kill.lower-role" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -319,15 +319,15 @@ function ExpUtil.extract_time_units(ticks, units)
|
|||||||
|
|
||||||
-- Remove units that are not requested
|
-- Remove units that are not requested
|
||||||
if not units.days then
|
if not units.days then
|
||||||
rtn.hours = rtn.hours + rtn.days * 24
|
rtn.hours = assert(rtn.hours) + assert(rtn.days) * 24
|
||||||
rtn.days = nil
|
rtn.days = nil
|
||||||
end
|
end
|
||||||
if not units.hours then
|
if not units.hours then
|
||||||
rtn.minutes = rtn.minutes + rtn.hours * 60
|
rtn.minutes = assert(rtn.minutes) + assert(rtn.hours) * 60
|
||||||
rtn.hours = nil
|
rtn.hours = nil
|
||||||
end
|
end
|
||||||
if not units.minutes then
|
if not units.minutes then
|
||||||
rtn.seconds = rtn.seconds + rtn.minutes * 60
|
rtn.seconds = assert(rtn.seconds) + assert(rtn.minutes) * 60
|
||||||
rtn.minutes = nil
|
rtn.minutes = nil
|
||||||
end
|
end
|
||||||
if not units.seconds then
|
if not units.seconds then
|
||||||
@@ -487,7 +487,7 @@ function ExpUtil.get_storage_for_stack(options)
|
|||||||
-- Find a valid entity from the search results
|
-- Find a valid entity from the search results
|
||||||
local current, count, entities = cache.current, cache.count, cache.entities
|
local current, count, entities = cache.current, cache.count, cache.entities
|
||||||
for i = 1, cache.count do
|
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
|
if entity.can_insert(item) then
|
||||||
cache.current = current + 1
|
cache.current = current + 1
|
||||||
return entity
|
return entity
|
||||||
@@ -551,7 +551,7 @@ function ExpUtil.move_items_to_surface(options)
|
|||||||
options.item = item
|
options.item = item
|
||||||
entity = ExpUtil.get_storage_for_stack(options)
|
entity = ExpUtil.get_storage_for_stack(options)
|
||||||
entity.insert(options.item)
|
entity.insert(options.item)
|
||||||
options.item.clear()
|
assert(options.item).clear()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return entity
|
return entity
|
||||||
@@ -603,7 +603,8 @@ end
|
|||||||
--- @param n number
|
--- @param n number
|
||||||
--- @return string
|
--- @return string
|
||||||
function ExpUtil.comma_value(n) -- credit http://richard.warburton.it
|
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
|
return left .. (num:reverse():gsub("(%d%d%d)", "%1, "):reverse()) .. right
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user