ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   trying to do my 1st LUA addon (https://www.esoui.com/forums/showthread.php?t=126)

raykai 02/27/14 05:57 AM

trying to do my 1st LUA addon
 
hi im new to doing addons but i would like to try and do one.

but il need your help to get on track

what i need help with is:

im trying to do a icon that is above the chat box that has the name Emote

ones you click on it it would show a frame with all the list of Emote that would be clickable on click it would send the / event in the chat.

so far i did

one file named emote_list.txt
code:
Code:

## Title: Emote list
## APIVersion: 100000

emote_list.lua
emote_list.xml

then i have my two files:
emote_list.lua
emote_list.xml

now from there im not sheer how to get my frame with the emote list...
should i create a frame in the xml file ?

and do a list of the in game emots scrip list in the lua file ?

if i could get a short example of doing a frame with text in it that on click it would past that text in chat i think i could manage the rest.

Wykkyd 02/27/14 02:54 PM

Neat addon idea.
Not as simple to implement as one might think.

Tip 1: I wouldn't personally use an XML file for this. It's fairly pointless.

Tip 2: You can get a dynamic list of emotes with something like this:
Code:

local emotes = nil
local LoadEmotes = function()
        emotes = {}
        for e = 1, GetNumEmotes(), 1
        do emotes[GetEmoteSlashName(e)] = e end
end

Tip 3: To draw the 1st frame on screen, sure you could use XML but it'd be just as easy to build a frame using something like this:
Code:

local emoteFrame = WINDOW_MANAGER:CreateTopLevelWindow( "some_unique_name" )
emoteFrame.Background = WINDOW_MANAGER:CreateControl( "another_unique_name", emoteFrame, CT_BACKDROP)
emoteFrame.Label = WINDOW_MANAGER:CreateControl( "another_unique_name", emoteFrame, CT_LABEL)

Then you could go about setting properties of those frames like emoteFrame.Label:SetText( "Emote List" ), etc.


Tip 4: For the pop-up emote list since you want each emote clickable each one will have to be a different unique control, so it'd be best to build a local function that creates a Button with an overlayed Label (Label containing the Emote text). And then make the Button clickable.


Tip 5: Here's the command to issue an emote to be played:
Code:

PlayEmote(emotes[ emoteName ])


All times are GMT -6. The time now is 09:56 PM.

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