I have been beating my head against this brick wall for a week now.
I'm working on trying to get this mod to work and then I'll try to understand the 3.0 changes.
I am down to just guessing now and that's getting nowhere very quickly.
Yes, I'm told that this will be easier with 3.x. I don't see that as being comforting since I can't find much about it beyond Iriel's documentation. Perhaps I'm just an idiot, but I don't think so.
So, what is the obvious thing I've done in the below code?
I'll tell you what it does do. I get the button I create. I can right and left click in the parent frame to change the state. That piece of code isn't in the box below. What does not happen is, at no time does a spell ever get cast. The button just presses and animates. No error message. No attempt to cast the spell I thought I associated with any of the virtual buttons.
The spell names are spelled right as I can change this up to a normal secure button without states and it casts nicely. I just can't change what the button does in combat.
All the examples I've seen only use secureactionbarbutton. That has functionality I don't want. Namely its tied to action buttons. Perhaps changing spells per state is not allowed.
Code:
ntraps=trapper:enumeratetraps()
if ntraps then
-- Create buttons for each trap
trap_b = CreateFrame("Button","trapper_button",trapper,"ActionButtonTemplate,SecureActionButtonTemplate")
-- set state spell attributes &
-- build statebutton string
statestring="1:S1"
for t = 1, ntraps do
if t>1 then
statestring=statestring..";"..t..":S"..t
end
end
trap_b:SetAttribute("statebutton",statestring)
-- Set possible states
trap_b:SetAttribute("newstate","1-"..ntraps..":=")
-- Set type and spell for each state
for t = 1, ntraps do
trap_b:SetAttribute("type1-S"..t,"spell")
trap_b:SetAttribute("spell-S"..t,trap_n[t])
end
-- add this button as a child of the state header
trapper:SetAttribute("addchild",trab_b)
-- set the state to "1"
trap_b:SetAttribute("state","1")
trap_b:SetScript("OnAttributeChanged", TrapButton_Update)
-- Set the image for the button
trap_b:SetNormalTexture(trap_i[1])
trap_b:SetPushedTexture(trap_i[1])