Thread Tools Display Modes
03-20-06, 11:56 AM   #1
Mr_Vonhelding
A Deviate Faerie Dragon
Join Date: Feb 2006
Posts: 10
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.
  Reply With Quote
03-20-06, 04:26 PM   #2
Nulkris
A Cobalt Mageweaver
 
Nulkris's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 214
Post

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
__________________
Nulkris - A80 Rogue - Proudmoore
(Also Drukris, Hamkris on Proudmoore; Hulkris on Jubei'Thos & Khaz Modan)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Check boxes

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off