Thread Tools Display Modes
06-20-10, 05:51 AM   #1
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
need help to learn and compleet my simple addon

Hi I'm new in addon and lua .
I started from wowwiki and did "hello world" tutorial then there was nothing to teach me how to use events - checkbox - and ...
i managed to design my addon's interface with addon studio but my lua file is still empty .
i know few of programing and scripting and just need some push to start my car . just few questions !

1- how i can make my addon to react to events ?
2- is there a list of events?
3- how i can use checkboxes ?
4- witch one of things i want in my(this) addon are possible?
(addon is attached)

please don't complete the addon with a twisted solution ! i need to learn this basics . ty
Attached Files
File Type: zip K1A.zip (1.5 KB, 706 views)
  Reply With Quote
06-20-10, 06:04 AM   #2
Soulofsin_007
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 125
1.
Code:
Events = CreateFrame("Frame")
Events:SetScript("OnEvent", function(self, event, ...)
     if event == "PLAYER_ENTERING_WORLD" then
         print("Hello"...UnitName("player"))
     end
end)
Events:RegisterEvent("PLAYER_ENTERING_WORLD")
2. Here

3.
Code:
Parent = CreateFrame("Frame", "ParentingFrames", WorldFrame)
Parent:SetWidth(300)
Parent:SetHeight(300)
Parent:SetPoint("CENTER")
Parent:SetBackdrop(StaticPopup1:GetBackdrop())
Parent:EnableMouse(true)
Parent:SetMovable(true)
Parent:Show()
Parent:SetScript("OnMouseDown", function()
  Parent:StartMoving()
end)
Parent:SetScript("OnMouseUp", function()
  Parent:StopMovingOrSizing()
end)


Parent.text = Parent:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
Parent.text:SetPoint("CENTER",25,0)


CheckButton = CreateFrame("CheckButton", "Button2", Parent, "OptionsCheckButtonTemplate") 
CheckButton:SetWidth("25") 
CheckButton:SetHeight("25")
CheckButton:SetPoint("CENTER") 
CheckButton:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up") 
CheckButton:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down") 
CheckButton:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight", "ADD") 
CheckButton:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check") 
CheckButton:Show()

local checkbutton = 0

local function onUpdate(self,elapsed)
    local isChecked = CheckButton:GetChecked()

    
    checkbutton = checkbutton + elapsed
    if checkbutton >= 0.1 then -- how often it checks to see what is checked.
       if(isChecked == 1) then
        Parent.text:SetText("Checked")
        Parent.text:SetPoint("CENTER",35,0)
       else
        Parent.text:SetText("Unchecked")
        Parent.text:SetPoint("CENTER",45,0)
       end
        checkbutton = 0
    end
end

local f = CreateFrame("frame")
f:SetScript("OnUpdate", onUpdate)
4. I didn't see anything were it says what you want your addon to do. Both the lua/xml files are empty
when I open them.

Also the timer part in the end is pry alittle messy, I bet there is a better way to do it. Thats just how I had it saved.

Last edited by Soulofsin_007 : 06-20-10 at 07:53 AM.
  Reply With Quote
06-20-10, 09:49 AM   #3
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Am I the only one that has grown a hate against that addon studio because it learns beginners the completely wrong things?
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
06-20-10, 10:00 AM   #4
Soulofsin_007
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 125
I couldn't even get the thing to work right. =/
  Reply With Quote
06-20-10, 01:46 PM   #5
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by nightcracker View Post
Am I the only one that has grown a hate against that addon studio because it learns beginners the completely wrong things?
Is this meant to be ironic?
  Reply With Quote
06-20-10, 03:30 PM   #6
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
xml

ty for answer
what I'm trying to do is making an addon to auto accept release/resurrect/ress/enter arena/leave arena and party messages (any of them that are possible) with a simple interface and some chechboxes .

what i learned so far :
i need register events after function
and few about creating frames - buttons and ... in lua

question 1 : do i have to create frame on lua even when i have some on xml ?
my .xml codes
Code:
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
	<Script file="Frame.lua" />
	<Frame name="F_K1A" parent="UIParent" toplevel="true" movable="true" enableMouse="true">
		<Size>
			<AbsDimension x="100" y="22" />
		</Size>
		<Anchors>
			<Anchor point="TOPLEFT">
				<Offset>
					<AbsDimension x="399" y="-49" />
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad />
			<OnMouseDown>self:StartMoving();</OnMouseDown>
			<OnMouseUp>self:StopMovingOrSizing();</OnMouseUp>
		</Scripts>
		<Layers>
			<Layer>
				<FontString name="T_Party" inherits="GameFontNormalSmall" text="Party">
					<Size x="39" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="510" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="T_LeaveArena" inherits="GameFontNormalSmall" text="LeaveArena">
					<Size x="75" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="417" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="FontString1" inherits="GameFontNormalSmall" text="K1Acceptor">
					<Size x="100" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="0" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="T_Recurrect" inherits="GameFontNormalSmall" text="Recurrect">
					<Size x="63" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="190" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="T_Release" inherits="GameFontNormalSmall" text="Release">
					<Size x="53" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="119" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="T_Ress" inherits="GameFontNormalSmall" text="Ress">
					<Size x="35" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="274" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="T_EnterArena" inherits="GameFontNormalSmall" text="EnterArena">
					<Size x="70" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="328" y="0" />
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
			<BackgroundInsets>
				<AbsInset left="0" right="0" top="0" bottom="0" />
			</BackgroundInsets>
			<TileSize>
				<AbsValue val="32" />
			</TileSize>
			<EdgeSize>
				<AbsValue val="1" />
			</EdgeSize>
		</Backdrop>
		<Frames>
			<CheckButton name="C_Party" inherits="UICheckButtonTemplate">
				<Size x="20" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="497" y="-1" />
					</Anchor>
				</Anchors>
			</CheckButton>
			<CheckButton name="C_LeaveArena" inherits="UICheckButtonTemplate" checked="true">
				<Size x="20" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="404" y="-1" />
					</Anchor>
				</Anchors>
			</CheckButton>
			<CheckButton name="C_Recurrect" inherits="UICheckButtonTemplate">
				<Size x="20" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="178" y="-1" />
					</Anchor>
				</Anchors>
			</CheckButton>
			<CheckButton name="C_Release" inherits="UICheckButtonTemplate" checked="true">
				<Size x="20" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="106" y="-1" />
					</Anchor>
				</Anchors>
				</CheckButton>
			<CheckButton name="CheckButton1" inherits="UICheckButtonTemplate" checked="true">
				<Size x="20" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="260" y="-1" />
					</Anchor>
				</Anchors>
			</CheckButton>
			<CheckButton name="C_EnterArena" inherits="UICheckButtonTemplate">
				<Size x="20" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="314" y="-1" />
					</Anchor>
				</Anchors>
			</CheckButton>
		</Frames>
	</Frame>
</Ui>
Question 2 :witch one is better creating frames in lua or xml ?
Question 3 : when i register an event it will react when that event happens and i don't need any other code to call it or something like that . right?
Question 4 :am i asking too much questions?

i will try to fix my addon tomorrow and will come back with more questions
again , ty for support

and about addon studio i think its very good for making xml interfaces but i like coding lua in notepad++ (well i still need to learn lua first then i can talk about it)

Last edited by b3vad : 06-20-10 at 03:34 PM.
  Reply With Quote
06-20-10, 03:57 PM   #7
Soulofsin_007
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 125
1. You do not need to create the frame through lua if you do it in XML. Just a different way to do it. I prefer lua.

2. Personal preference. Don't know if one is more efficient

3. Yes it will automatically happen. You just have to have the code that does someone then the game calls it.

4. I don't think so.
  Reply With Quote
06-20-10, 09:31 PM   #8
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Soulofsin_007 View Post
1.
Code:
Events = CreateFrame("Frame")
Events:SetScript("OnEvent", function(self, event, ...)
     if event == "PLAYER_ENTERING_WORLD" then
         print("Hello"...UnitName("player"))
     end
end)
Events:RegisterEvent("PLAYER_ENTERING_WORLD")
My head just exploded because you created those frames in the global namespace instead of locally.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
06-20-10, 09:41 PM   #9
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by Torhal View Post
My head just exploded because you created those frames in the global namespace instead of locally.
*boom*

tooshort [;'
  Reply With Quote
06-20-10, 09:51 PM   #10
Soulofsin_007
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 125
Originally Posted by Torhal View Post
My head just exploded because you created those frames in the global namespace instead of locally.
I didn't even think about that.

Edit:Mhmm brains?
  Reply With Quote
06-21-10, 01:52 AM   #11
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
dosent work on my xml

i cant make it work on my xml and i don't know why !
i added lines
Code:
   <OnLoad> self:RegisterEvent("PLAYER_ENTERING_WORLD"); </OnLoad>
   <OnEvent> print("Hello World! Hello " .. event); </OnEvent>
in scripts tag (taken from wowwiki sample)
Code:
<Ui>
<Frame name="FooAddonFrame">
 <Scripts>
   <OnLoad> self:RegisterEvent("PLAYER_ENTERING_WORLD"); </OnLoad>
   <OnEvent> print("Hello World! Hello " .. event); </OnEvent>
  </Scripts>
</Frame>
</Ui>
is it because that my xml is not foo (whatever it is)?
or maybe <Script file="Frame.lua" /> tag?

Last edited by b3vad : 06-22-10 at 06:34 AM.
  Reply With Quote
06-22-10, 11:44 AM   #12
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
my lua error

this is my lua eror
Note: F_K1A is name of my frame
Code:
Message: [string "F_K1A:OnLoad"]:1: attempt to call global 'F_K1A_OnLoad' (a nil value)
Time: 06/22/10 22:08:25
Count: 1
Stack: [string "*:OnLoad"]:1: in function <[string "*:OnLoad"]:1>

Locals: self = F_K1A {
 0 = <userdata>
}
(*temporary) = nil
(*temporary) = "attempt to call global 'F_K1A_OnLoad' (a nil value)"
after adding
Code:
function F_K1A_onLoad()
this.RegisterEvent("PLAYER_TARGET_CHANGED"); 
end
function F_K1A_onEvent()
if (event == "PLAYER_TARGET_CHANGED") then
print("Hello " .. UnitName("target") .. "!");
end

end
in my lua file and calling them from xml with
Code:
			<OnLoad>F_K1A_OnLoad();</OnLoad>
			<OnEvent>F_K1A_OnEvent();</OnEvent>
this little problem really eats my nerves

Last edited by b3vad : 06-22-10 at 11:49 AM.
  Reply With Quote
06-22-10, 11:50 AM   #13
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
are you including the lua file in either the xml file or the toc file before the xml file ?
__________________
  Reply With Quote
06-22-10, 12:01 PM   #14
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Also, are these direct copy-pastes?

F_K1A_OnLoad =/= F_K1A_onLoad
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-22-10, 12:09 PM   #15
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
Originally Posted by Xrystal View Post
are you including the lua file in either the xml file or the toc file before the xml file ?
yes i did
Originally Posted by Seerah View Post
Also, are these direct copy-pastes?

F_K1A_OnLoad =/= F_K1A_onLoad
that's right my typo mistake (renamed both function and fund another mistake in
Code:
this.RegisterEvent("PLAYER_TARGET_CHANGED");
the dot after this must be :
fixed thanks i will come back with more question and problems

for start whats the meaning of .. and "!" in
print("Hello " .. UnitName("target") .. "!");
does .. means that the next word is a code or function not a string?

Last edited by b3vad : 06-22-10 at 12:14 PM.
  Reply With Quote
06-22-10, 12:15 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Two periods (..) mean to concatenate (connect) two things together for the string. So, if UnitName("target") = "b3vad" (string), then "Hello"..UnitName("target") will equal "Hello b3vad". The ! is just an !, since it's in quotes (a string), connected to the rest of the string to print out.

Code:
print("Hello " .. UnitName("target") .. "!")
>> "Hello b3vad!"
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-22-10, 01:57 PM   #17
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
CORPSE_IN_RANGE auto Resurrect ?

ty for gr8 answers ^_^
now I'm half way and hard part
is Resurrect when CORPSE_IN_RANGE protected?
cause i cant find any event to use when time is over and Resurrect is available and there is nothing like AcceptResurrect(); for Resurrect from crops (i think)
any idea?
and same about entering and leaving arena
--------------------
beta version is ready and attached
Attached Files
File Type: zip K1A.zip (2.0 KB, 691 views)

Last edited by b3vad : 06-22-10 at 02:52 PM.
  Reply With Quote
06-24-10, 10:25 AM   #18
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
save checkboxes status

whats your suggestion for saving checkboxes status ?
I'm looking for simplest way possible
-------------
and any info about things in my perv post?
  Reply With Quote
06-28-10, 02:19 AM   #19
b3vad
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 21
soper long (not answered Thread)

well i think repeating my question will get some attention again

1- what do you suggest for saving checkboxes status (i think of making some viable and saving them but maybe someone wanna say some tips about it)
2- (if its possible) anyone knows how to automatic accept arena enter / leave massages ?
3- (if its possible) how to Resurrect from crops ?
  Reply With Quote
06-28-10, 06:37 PM   #20
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by b3vad View Post
well i think repeating my question will get some attention again

1- what do you suggest for saving checkboxes status (i think of making some viable and saving them but maybe someone wanna say some tips about it)
2- (if its possible) anyone knows how to automatic accept arena enter / leave massages ?
3- (if its possible) how to Resurrect from crops ?
1) The only way to save checkbox status is by saved variables. Here's and example of the check to use for it:

lua Code:
  1. if var then -- is var true?
  2.         checkButton:SetChecked() -- check the button
  3.     else
  4.         checkButton:SetChecked(false) -- var is false, uncheck button
  5.     end

2) Try this, since a lot of the battleground API is shared with arena API:
lua Code:
  1. AcceptBattlefieldPort(1,1)

If that doesn't work, let me know and I'll see what I can dig up.

3) I'm not sure what you're asking here. Are you looking to automatically accept player rezzes or corpse release?

As far as .lua vs .xml, I find lua to be easier to manage and work with. I used to use xml, but the problem came in when I realized that a simple mistake would not let the addon load at all, which is hardly useful when looking to squash bugs. If using lua, the addon will always load and errors will pop telling you where your errors are.

Last edited by Sythalin : 06-28-10 at 06:40 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » need help to learn and compleet my simple addon

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