From f836850768ac49e15963e5a2edc36e97d63a5acb Mon Sep 17 00:00:00 2001 From: MarcelineVQ Date: Sat, 7 Mar 2026 14:23:52 -0800 Subject: [PATCH] Separate UI feedback from public Lua API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Public functions (WorldMarker, ClearWorldMarker) no longer show chat messages — return values indicate status. New WorldMarkers.UI_WorldMarker and UI_ClearWorldMarker wrappers provide user-facing feedback for slash commands and keybindings. Update README with new API signatures. --- DLL_README.md | 5 ++-- src/markers/addon/Bindings.xml | 12 ++++---- src/markers/addon/WorldMarkers.lua | 46 +++++++++++++++++++----------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/DLL_README.md b/DLL_README.md index 019352b..7c18bb1 100644 --- a/DLL_README.md +++ b/DLL_README.md @@ -24,11 +24,12 @@ Markers automatically sync with group members who also have WeirdUtils installed Lua API for addon developers: -- `WorldMarker(index)` -- place marker at cursor terrain position (returns 1 on success, nil if no permission) +- `WorldMarker(index)` -- place marker at cursor (returns x,y,z,areaId on success, nil if no permission, -1 on failure) - `WorldMarker(index, "unit")` -- place marker at a unit's position - `WorldMarker(index, x, y, z)` -- place marker at world coordinates - `ClearWorldMarker(index)` / `ClearWorldMarker()` -- remove one or all markers (returns 1 on success, nil if no permission) -- `CanSetWorldMarkers()` -- returns 1 if the local player is party/raid leader or raid assist, nil otherwise +- `GetWorldMarker(index)` -- returns x,y,z,areaId for an active marker, nil if empty +- `CanSetWorldMarker()` -- returns 1 if the local player is party/raid leader or raid assist, nil otherwise **DLL:** `worldmarkers.dll` diff --git a/src/markers/addon/Bindings.xml b/src/markers/addon/Bindings.xml index b279f80..a439256 100644 --- a/src/markers/addon/Bindings.xml +++ b/src/markers/addon/Bindings.xml @@ -1,20 +1,20 @@ - WorldMarker(1) + WorldMarkers.UI_WorldMarker(1) - WorldMarker(2) + WorldMarkers.UI_WorldMarker(2) - WorldMarker(3) + WorldMarkers.UI_WorldMarker(3) - WorldMarker(4) + WorldMarkers.UI_WorldMarker(4) - WorldMarker(5) + WorldMarkers.UI_WorldMarker(5) - ClearWorldMarker() + WorldMarkers.UI_ClearWorldMarker() diff --git a/src/markers/addon/WorldMarkers.lua b/src/markers/addon/WorldMarkers.lua index 9428bfb..495d1fe 100644 --- a/src/markers/addon/WorldMarkers.lua +++ b/src/markers/addon/WorldMarkers.lua @@ -156,14 +156,8 @@ end local RawWorldMarker = WorldMarker function WorldMarker(index, ...) local x, y, z, areaId = RawWorldMarker(index, unpack(arg)) - if x == nil then - showDenyMessage() - return - end - if x < 0 and (y == nil) then - showFailMessage() - return - end + if x == nil then return end + if x < 0 and (y == nil) then return x end denyCount = 0 local ch = getChannel() if ch then @@ -175,10 +169,7 @@ end local RawClearWorldMarker = ClearWorldMarker function ClearWorldMarker(index) local ok = RawClearWorldMarker(index) - if not ok then - showDenyMessage() - return - end + if not ok then return end denyCount = 0 local ch = getChannel() if ch then @@ -188,6 +179,29 @@ function ClearWorldMarker(index) broadcastClearAll() end end + return ok +end + +-- ============================================================================= +-- UI wrappers — used by slash commands and keybindings, show error messages +-- ============================================================================= + +function WorldMarkers.UI_WorldMarker(index, ...) + local x, y, z, areaId = WorldMarker(index, unpack(arg)) + if x == nil then + showDenyMessage() + elseif x < 0 and (y == nil) then + showFailMessage() + end + return x, y, z, areaId +end + +function WorldMarkers.UI_ClearWorldMarker(index) + local ok = ClearWorldMarker(index) + if not ok then + showDenyMessage() + end + return ok end -- ============================================================================= @@ -379,9 +393,9 @@ SlashCmdList["WORLDMARKER"] = function(msg) end if parts[2] then - WorldMarker(index, parts[2]) + WorldMarkers.UI_WorldMarker(index, parts[2]) else - WorldMarker(index) + WorldMarkers.UI_WorldMarker(index) end end @@ -390,8 +404,8 @@ SLASH_CLEARWORLDMARKER2 = "/cwm" SlashCmdList["CLEARWORLDMARKER"] = function(msg) local index = tonumber(msg or "") if index then - ClearWorldMarker(index) + WorldMarkers.UI_ClearWorldMarker(index) else - ClearWorldMarker() + WorldMarkers.UI_ClearWorldMarker() end end