Thread Tools Display Modes
08-02-08, 07:50 AM   #1
tuxeh
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 3
Assistance with frames in lua

Hi there.

I am a relatively new addon author, but I've got experience with other languages such as C++ and Java so I'm not new to it all.

I've talked with several addon authors, and most say that XML clutters up the global environment and that you might just as well create your frames in lua to create frames during runtime when needed, not to mention the dreaded xml debugging.

I have successfully created simple frames, with a background, but that's where it stops for me. I've found a couple of tutorials on how to create frames in XML, but I've not been able to port the code in to lua (by finding a matching method for the xml parameter, as some of them seem to me to be non-existant).

What I am asking is if there are any guides, or a reference/documentation that explains the lua methods for the frame objects, and what methods that have to be called to get these up and running as I've not found wowwiki to explain just that.

Edit: I just want to mention that I have been able to create a simple frame, assign a background, and set plus register events with the frame. I am however clueless when it comes to creating a visible frame with buttons, borders, pretty much the whole shebang

Last edited by tuxeh : 08-02-08 at 08:00 AM.
  Reply With Quote
08-02-08, 03:21 PM   #2
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Post sample frame with default blizz ui borders, backround and buttons

Ive written a sample addon, not so much a tutorial, that gives you the basics of what you need for frames / and slash command launch.

There are lua methods for Create / Destory Frame elements, but that is not an area i have done much exporation. As for clutter, i find the reduction of clutter with seperating command code from dispaly elements. I.E. .lua commands & arg. - .xml display elements.

My beta sample frame can be found here, its pretty self simple to see mechanics when you dive in the source. If you have questions concearning functions just send me a message.

http://www.wowinterface.com/download...85-Frames.html
__________________
  Reply With Quote
08-02-08, 04:55 PM   #3
svartalve
A Deviate Faerie Dragon
 
svartalve's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 11
Hope this helps:

CreateFrame API on
Wowprogramming.com & Wowwiki.
  Reply With Quote
08-03-08, 02:35 AM   #4
tuxeh
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 3
Hi there and thanks for the links.
I must however admit that it wasn't exactly what I was looking for.

I'm still trying to find either addons or guides that have had their frames defined in the lua code (without any xml what so ever) so that I have somewhere to start. Don't misunderstand, the reference and the wiki I was linked is a great resource but it doesn't say what parameters(methods) has to be set to, for example, making a movable bordered frame with a background show up.
  Reply With Quote
08-03-08, 04:50 PM   #5
Freki
A Deviate Faerie Dragon
 
Freki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 18
A simple example to help you get started maybe. Creating a draggable frame with a backdrop and close button using only lua. (untested, should work)

Code:
local MyAddon = CreateFrame("frame","MyAddonFrame")
MyAddon:SetBackdrop({
      bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", 
      edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", 
      tile=1, tileSize=32, edgeSize=32, 
      insets={left=11, right=12, top=12, bottom=11}
})
MyAddon:SetWidth(220)
MyAddon:SetHeight(400)
MyAddon:SetPoint("CENTER",UIParent)
MyAddon:EnableMouse(true)
MyAddon:SetMovable(true)
MyAddon:RegisterForDrag("LeftButton")
MyAddon:SetScript("OnDragStart", function(self) self:StartMoving() end)
MyAddon:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
MyAddon:SetFrameStrata("FULLSCREEN_DIALOG")

local button = CreateFrame("button","MyAddonButton", MyAddon, "UIPanelButtonTemplate")
button:SetHeight(24)
button:SetWidth(60)
button:SetPoint("BOTTOM", MyAddon, "BOTTOM", 0, 10)
button:SetText("Close")
button:SetScript("OnClick", function(self) PlaySound("igMainMenuOption") self:GetParent():Hide() end)
http://www.wowwiki.com/Widget_API
http://www.wowwiki.com/Widget_Handlers

Those two links will be very helpful resources. Basically your SetScript is like the <Scripts> in XML code.

Edit: http://home.blarg.net/~tyroney/wow/uitutorial/ That's a guide I used when I was first starting out with creating visible frames. It's nice because it shows both the XML and lua way of going about creating frames.

Last edited by Freki : 08-03-08 at 04:56 PM. Reason: addition
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Assistance with frames in lua

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