Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ function CMD_RegisterCommands()

-- Reveal map
CMD_AddCommand("reveal",
"Moderators only: <size> [x,y]|[gps=x,y]|[gps=x,y,surface] -- Reveals map from a given position or the center of map. Size is in tiles. Default size 1024. Min 128, Max 8192.",
"Moderators only: [size] [surface] [x,y | gps=x,y | gps=x,y,surface] -- Reveals the map around a position. Args may be given in any order. Position defaults to your location (or map center from console); surface defaults to the named one, else your current surface. Size is in tiles. Default 1024. Min 128, Max 8192.",
function(param)
if CMD_ModsOnly(param) then
return
Expand All @@ -755,7 +755,6 @@ function CMD_RegisterCommands()
if not gx then gx, gy = str:match("%[gps=([-%d%.]+),([-%d%.]+)%]") end

local x, y = str:match("([-%d%.]+),([-%d%.]+)")
local surfname = str:match("^%s*([%w_]+)%s*$")

local tokens = {}
for token in str:gmatch("[^%s,]+") do
Expand All @@ -769,18 +768,28 @@ function CMD_RegisterCommands()
table.remove(tokens, 1)
end

-- Handle GPS
-- Surface: any leftover token that names a real surface switches
-- it. Applied independently of the center so a surface name can be
-- combined with a size and/or explicit x,y coordinates.
local surface_named = false
for _, token in ipairs(tokens) do
if game.surfaces[token] then
psurface = game.surfaces[token]
surface_named = true
end
end

-- Center: GPS wins (and may carry its own surface), then plain
-- x,y. If only a surface was named (no coordinates), center on that
-- surface's origin rather than the caller's unrelated position.
if gx and gy then
center = { x = tonumber(gx), y = tonumber(gy) }
if gsurf and game.surfaces[gsurf] then
psurface = game.surfaces[gsurf]
end
-- Handle x,y
elseif x and y then
center = { x = tonumber(x), y = tonumber(y) }
-- Handle surface name if valid
elseif surfname and game.surfaces[surfname] then
psurface = game.surfaces[surfname]
elseif surface_named then
center = { x = 0, y = 0 }
end
end
Expand Down
2 changes: 1 addition & 1 deletion version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return "661-06.27.2026-850a"
return "662-07.02.2026-849p"