Convert Secure Macro Button to Worldmarker Button?

Is there a way to convert this into a secure worldmarker button and still cycle the index on click? Bonus if it clears on shift-click.

local b = CreateFrame("Button", "_MB", nil, "SecureActionButtonTemplate")
b:SetAttribute("*type5","macro") SecureHandlerWrapScript(b,"PreClick",b,'Z=IsShiftKeyDown()and 0 or(Z or 0)%8+1 self:SetAttribute("macrotext5","/wm [@cursor] "..Z)')

The macro to trigger this version is

/cwm [mod:shift] 0
/click _MB Button5

Also, I’m not stuck on button 5, it’s just something I stole from the original macro.

[added]
Tried the following and it gives me the reticle to place {square} but doesn’t increment and I’d like it to place without a 2nd click.

local b = CreateFrame("Button", "_MB", nil, "SecureActionButtonTemplate")
b:SetAttribute("*type5","worldmarker") SecureHandlerWrapScript(b,"PreClick",b,'Z=IsShiftKeyDown()and 0 or(Z or 0)%8+1 self:SetAttribute("marker"..Z,"set")')

Looks like to place the marker at cursor I need to pass cursor as a 2nd argument to PlaceRaidMarker() which worldmarker secure buttons don’t appear to support.

https://github.com/Gethe/wow-ui-source/blob/live/Interface/AddOns/Blizzard_FrameXML/Mainline/SecureTemplates.lua#L566
https://github.com/Gethe/wow-ui-source/blob/live/Interface/AddOns/Blizzard_ChatFrameBase/Mainline/ChatFrame.lua#L1668

Haven’t made any progress on this since yesterday but I confirmed Z was being incremented so I’m not sure why it wasn’t translating through to the actual marker being placed.

[added]
Looks like I’m doing it wrong, gonna steal this code from ExRT when servers come back up.

frame:SetAttribute("type", "worldmarker")
frame:SetAttribute("marker", tostring(Z))
frame:SetAttribute("action", "set")
frame:SetAttribute("shift-action", "clear")

Alright, I’ve got everything working except being able to skip the left click to place the reticle, any ideas?

local b = CreateFrame("Button", "_MB", nil, "SecureActionButtonTemplate")
b:RegisterForClicks("AnyUp", "AnyDown")
b:SetAttribute("type","worldmarker")
b:SetAttribute("action", "set")
SecureHandlerWrapScript(b,"PreClick",b,'Z=IsShiftKeyDown() and 0 or (Z or 0)%8+1 self:SetAttribute("marker",tostring(Z))')

I had a quick go at it and doesn’t look like it’s possible to place at cursor when using the worldmarker type :frowning:

Hey Elvenbane!

Did you make any progress on this? Been trying to get this WorldMarker stuff working myself.

Even if I had to manually click between each one, it is still a big benefit to be able to cycle through them all.

https://wago.io/koguSJAuR