Separate UI feedback from public Lua API
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.
This commit is contained in:
+3
-2
@@ -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`
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<Bindings>
|
||||
<Binding name="Place Blue Square" header="WORLDMARKERS">
|
||||
WorldMarker(1)
|
||||
WorldMarkers.UI_WorldMarker(1)
|
||||
</Binding>
|
||||
<Binding name="Place Green Triangle" header="WORLDMARKERS">
|
||||
WorldMarker(2)
|
||||
WorldMarkers.UI_WorldMarker(2)
|
||||
</Binding>
|
||||
<Binding name="Place Purple Diamond" header="WORLDMARKERS">
|
||||
WorldMarker(3)
|
||||
WorldMarkers.UI_WorldMarker(3)
|
||||
</Binding>
|
||||
<Binding name="Place Red Cross" header="WORLDMARKERS">
|
||||
WorldMarker(4)
|
||||
WorldMarkers.UI_WorldMarker(4)
|
||||
</Binding>
|
||||
<Binding name="Place Yellow Star" header="WORLDMARKERS">
|
||||
WorldMarker(5)
|
||||
WorldMarkers.UI_WorldMarker(5)
|
||||
</Binding>
|
||||
<Binding name="Clear All Markers" header="WORLDMARKERS">
|
||||
ClearWorldMarker()
|
||||
WorldMarkers.UI_ClearWorldMarker()
|
||||
</Binding>
|
||||
</Bindings>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user