Thread Tools Display Modes
12-04-07, 04:42 PM   #1
jamesst
A Defias Bandit
Join Date: Dec 2007
Posts: 3
Newb Lau question

Hi all.

I am new to making addons, but not new to coding. LUA is easy enough, however LAU in WOW isnt as straight foreward.

What i am struggling with is how to access widget methods.

Assume i have a form called myform. And a label called Label1.

I have afunction in LAU as follows

Function writetolabel(self)

self.Label1:SetText("yataa")

end

thing is, it doesnt work, all i get is error messages. I have tried :
Label1:SetText("yataa")

local lable;
label = getgobel("Label1")
label:SetText("yataa")

I have used $parent correclt aswell, and this makes no differnce.

Nothing works. its is obvious that i am clueless as to how to access the XML Widgets from inside LUA scripts.

As there are no real tutorials on this. All i can say is. PLEASE, some one put me out of my missery.
HELP !!!
  Reply With Quote
12-04-07, 05:18 PM   #2
Gemini_II
A Molten Giant
 
Gemini_II's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 762
I can't code worth beans, but I know where to look:

www.lua.org
www.lua-users.org
www.wowwiki.com <- this also has a list of all current API functions. If you know LUA, I would start here

If you plan on using any Ace libs then you can usually find lots of help over at www.wowace.com also.
__________________
Retired prior to 3.2, before all challenge was removed.

  Reply With Quote
12-05-07, 02:34 AM   #3
jamesst
A Defias Bandit
Join Date: Dec 2007
Posts: 3
Been to all these places, and none have this specific info.

wowwiki says <elementname>:<function> which doesnt work.
Lau org is good for learning LAU, but interacting with the XML elements is outside its scope and i custom to wow. i have trolled the net and even google cant finda tutorial that actually explains this. A few demos, whcih, incidentally, dont work either lol
  Reply With Quote
12-05-07, 04:54 AM   #4
jamesst
A Defias Bandit
Join Date: Dec 2007
Posts: 3
hhmm

Ok, this is from another mod on this site

function Simple_Coords_OnUpdate(elapsed)
Simple_Coords_SecondsSinceUpdate = Simple_Coords_SecondsSinceUpdate + elapsed;
if (Simple_Coords_SecondsSinceUpdate > HEARTBEAT_INTERVAL) then
local x, y = GetPlayerMapPosition("player");

if x == 0 then
Simple_CoordsText:SetText("---");
else
Simple_CoordsText:SetText(format( "%.1f, %.1f", x * 100, y * 100));
Astrolabe:UpdateMinimapIconPositions();
end
Simple_Coords_SecondsSinceUpdate=0;
end -- if
end

This function is passed as the onupdate event handler in the XML file for the frame.
Note Simple_CoordsText:SetText("---");

This is more or less what i have done. I have got the event handler registered. I have the label1:SetText("meep"); in it.

All i get is an error message lol. I am lost lol
  Reply With Quote
12-05-07, 05:29 AM   #5
Jayhawk
Premium Member
 
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
First, it's lua not lau.

I'm not quit sure what you are doing (or want to do), but when quoting code snippets, it helps to use the code tags to keep spacing. They ar under the little # icon when you write/edit a post.

Code:
function Simple_Coords_OnUpdate(elapsed)
  Simple_Coords_SecondsSinceUpdate = Simple_Coords_SecondsSinceUpdate + elapsed;
  if (Simple_Coords_SecondsSinceUpdate > HEARTBEAT_INTERVAL) then
    local x, y = GetPlayerMapPosition("player");

    if x == 0 then
      Simple_CoordsText:SetText("---");
    else
      Simple_CoordsText:SetText(format( "%.1f, %.1f", x * 100, y * 100));
      Astrolabe:UpdateMinimapIconPositions();
    end
    Simple_Coords_SecondsSinceUpdate=0;
  end -- if
end
The code you quote above should work. Being bold and judging by your spelling here, I'd say: double-check everything, spelling, case (upper/lower) etc.
Of course, I can be wrong and you do code more neat that you write forum posts.

Last edited by Jayhawk : 12-05-07 at 05:34 AM.
  Reply With Quote
12-05-07, 09:50 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Most people have learned to code by dissecting or fiddling with other people's addons. Look at the lua. Look at the xml. Go to the WoW site and download the Custom UI Toolkit - it extracts the game data for you and has a couple of tutorials in it.
__________________
"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

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Newb Lau question


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