WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Check boxes (https://www.wowinterface.com/forums/showthread.php?t=4097)

Mr_Vonhelding 03-20-06 11:56 AM

Check boxes
 
Im wokring on my addon and here is one of the features I want.

On Death I want a message to be sent to a preset channel

So I know I have to do this much

register the event
myaddon.xml
<OnLoad>
this:RegisterEvent("PLAYER_DEAD");
</OnLoad>
<OnEvent>
MyAddon_OnEvent();
</OnEvent>

here is where im not sure what to do
On my frame I have a checkbox I have named $parentHRFChkOnDeath

Heres my function so far
function MyAddon_Onevent()
idplayer = UnitName("player");
if (event == "PLAYER_DEAD" and deadpc == idplayer) then
DEFAULT_CHAT_FRAME:AddMessage("YOUR DEAD!!!.", 1, 1, 1);
SendChatMessage("I'M DEAD!!!", "channel", "common", mychan);
end
end

So i want the check box ($parentHRFCheckOnDeath) to act like a toggle, to turn this feature off an on.
I thought something like
if (event == "PLAYER_DEAD" and deadpc == idplayer and MyFormHRFChkOndeath:True) then
Might do it but I really not sure.

Can anyone assist here?
please and thank you.

Nulkris 03-20-06 04:26 PM

There are these functions you can use:
Code:

state = checkbox:GetChecked()
checkbox:SetChecked(state)

to handle the state of the checkbox.

You could use the OnClick script of the checkbox to update your saved variable, and just reference your saved variable within the code.
Code:

<OnClick>dead_SV.Enabled = MyFormHRFChkOndeath:GetChecked();</OnClick>
...
if(event == "PLAYER_DEAD" and deadpc == playerid and dead_SV.Enabled) then
        ...
elseif(event == "VARIABLES_LOADED") then
        if(dead_SV == nil) then dead_SV = {}; end
        if(dead_SV.Enabled == nil) then dead_SV.Enabled = true; end
        MyFormHRFChkOndeath:SetChecked(dead_SV.Enabled);
end



All times are GMT -6. The time now is 02:47 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI