WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Assistance with frames in lua (https://www.wowinterface.com/forums/showthread.php?t=17503)

tuxeh 08-02-08 07:50 AM

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 :)

Drshow 08-02-08 03:21 PM

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

svartalve 08-02-08 04:55 PM

Hope this helps:

CreateFrame API on
Wowprogramming.com & Wowwiki.

tuxeh 08-03-08 02:35 AM

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.

Freki 08-03-08 04:50 PM

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.


All times are GMT -6. The time now is 01:50 PM.

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