Skip to content

GetLevelLayersNear

The level’s story layers with a solid piece near a point.

Every layer with a solid piece (a wall, a fence, a door, a heap) within radius of the point, the nearest first - how to find the layer of something a mode wants gone or back; admins ask the same with /layer near [radius]. Needs the game’s tables exported with this version or later; with an older export the list is empty. The level’s few huge ground layers are not listed.

GetLevelLayersNear(x, y, z, radius)
Parameter Type
x number metres
y number metres
z number metres
radius number metres (10 when not given)

table - {{name =, near =, pieces =, distance =, on =}, ...}: the layer’s full name, how many of its pieces lie within the radius, how many it has, the nearest one’s distance, and true / false as this server switched it (nil when never switched)

-- /whatlayer: the layers around an admin, to find the one to switch
function OnPlayerCommandText(pid, cmd, args)
if cmd == "whatlayer" and IsPlayerAdmin(pid) then
local x, y, z = GetPlayerPos(pid)
for i, layer in ipairs(GetLevelLayersNear(x, y, z, 8)) do
if i > 5 then break end
SendClientMessage(pid, COLOR_WHITE, string.format("%s (%d pieces, %.1f m)", layer.name, layer.pieces, layer.distance))
end
return true
end
end

SetLevelLayer · GetLevelLayers · the Level layers group of the index