WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Can't get any frames to display (https://www.wowinterface.com/forums/showthread.php?t=53023)

BloodyLycan 01-02-16 12:38 PM

Can't get any frames to display
 
Hello everyone!

Before I start, I should say that I'm an experienced software developer for web applications. I'd like to think that I have a good working knowledge of XML and the LUA language seems simple enough to figure out as I go.

My problem at this point, after pouring through the WoW API and XML tutorials, I can't really get a frame to display. I'm assuming it may be because there's nothing actually in the frame at the moment. I just want to get the frame to display, either on start up or through the ingame "addon screen".

I'm very sure that it's something I'm going wrong :p . The addon layout at the moment is basic with a single toc file, a main_ui.xml file and a main.lua file all in the same directory.

toc file:
Code:

## Interface: 60200
## Title: My Addon
## Notes: "Nothing to be done."
## Version: Dev

main.lua
ui_main.xml

xml file:
Code:


<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
    <!-- the addon's functionality is defined in here -->
    <Frame name="MyAddon_Frame">
    <Size><AbsDimension x="100" y="100"/></Size>
    <Anchors>
      <Anchor point="TOPLEFT"/>
    </Anchors>
    </Frame>
</Ui>

lua file:

Code:

message('HelloWorld')
MyAddon_Frame:Show()

Again, I am very sure that it is something basic maybe I'm not understanding how addons are run within WoW, or maybe it is something wrong with how I'm trying to instantiate the frame. Even a small nudge in the right direction would be very helpful.

Thank you all :).

Seerah 01-02-16 12:47 PM

You haven't told your frame what to look like. ;)

PS.- It's much, much nicer to create your frames in Lua (not an acronym, by the way). You don't need XML unless you're dealing with creating secure templates.

BloodyLycan 01-02-16 01:11 PM

Hmmm... I read a few posts on doing that and it intrigued me. To write a UI within the data layer would be great.

Do you know of any resources that I can look at for me to get started? Most of the addons I've seen still use xml, and I can't find anything on doing that.

Also, I plan on having the addon be primarily within a frame that stays on the screen, sort of like MyRolePlay. I'm not sure whether that would affect how I should go about starting it.

EDit: I did some specific searching for creating lua frames and I came across this tidbit:

local self = CreateFrame("Frame", "FunWidget", UIParent)

Would this be in the right direction for creating a frame in lua?

Fizzlemizz 01-02-16 01:23 PM

In lua your frame would be

Code:

local frame = CreateFrame("Frame", "MyAddon_Frame")
frame:SetSize(100, 100)
frame:ClearAllPoints()
frame:SetPoint("TOPLEFT")

If you want to see it (all "Frames" are transparent by default) add:

Code:

frame.texture = CreateTexture("$parent_Texture")
frame.texture:SetAllPoints(frame)
frame.texture:SetTexture(" ")

Will create a green square which is the default when the texture file can't be found.

If you go here you can find a list of all the widget type (start with "Frame" from the list on the right hand side) and their associated methods.

SDPhantom 01-02-16 07:01 PM

Quote:

Originally Posted by Fizzlemizz (Post 312459)
Code:

frame.texture = CreateTexture("$parent_Texture")
frame.texture:SetAllPoints(frame)
frame.texture:SetTexture(" ")


CreateTexture(), like CreateFontString(), is a metamethod of frames. As such, you need to call it as Frame:CreateTexture(). Also, you need to specify a draw layer as the second argument. Names are optional and you can pass nil as the first argument to not assign one.



The reason why we need Textures and FontStrings to show frames is because they are the visual elements we see. Frames are just a set of coordinates defining a container that we can align Textures and FontStrings to. Some frame types can also react to mouse events within the screen coordinates they cover.

Fizzlemizz 01-02-16 07:29 PM

Quote:

Originally Posted by SDPhantom (Post 312461)
CreateTexture(), like CreateFontString(), is a metamethod of frames. As such, you need to call it as Frame:CreateTexture(). Also, you need to specify a draw layer as the second argument. Names are optional and you can pass nil as the first argument to not assign one.

You are indeed correct, my bad.


All times are GMT -6. The time now is 11:56 AM.

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