Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition: export "zoneExists" #136

Merged
merged 6 commits into from
Jun 1, 2024
Merged
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
14 changes: 14 additions & 0 deletions client/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ function api.addSphereZone(data)
return lib.zones.sphere(data).id
end

---@param id number | string The ID of the zone to check. It can be either a number or a string representing the zone's index or name, respectively.
---@return boolean returns true if the zone with the specified ID exists, otherwise false.
function api.zoneExists(id)
if not Zones or (type(id) ~= 'number' and type(id) ~= 'string') then return false end

if type(id) == 'number' and Zones[id] then return true end

for key, zone in pairs(Zones) do
AnishBplayz marked this conversation as resolved.
Show resolved Hide resolved
if type(id) == 'string' and zone.name == id then return true end
end

return false
end

---@param id number | string
---@param suppressWarning boolean?
function api.removeZone(id, suppressWarning)
Expand Down