lua & xml

Re: lua & xml

by cyklon » Sat Jan 02, 2016 2:53 pm

Sorry for all the questions, i do seach the internet before i ask you.

Any idea why this doesnt make the frame draggable?
Code: Select all
f:SetMovable(true)
f:EnableMouse(true)
User avatar
cyklon
Senior Sergeant
Senior Sergeant
 

Re: lua & xml

by kuurtzen » Sat Jan 02, 2016 3:12 pm

in addition to those you need to set these scripts

Code: Select all
Frame:SetScript('OnDragStart', function()  this:StartMoving()  end)
Frame:SetScript('OnDragStop', function()  this:StopMovingOrSizing() end)
Frame:RegisterForDrag('LeftButton')
kuurtzen
Senior Sergeant
Senior Sergeant
 

Re: lua & xml

by cyklon » Sat Jan 02, 2016 3:17 pm

I think i need to upgrade my ggogle skills to filter out the retail wow lua scripting, that worked like a charm! Thanks!
User avatar
cyklon
Senior Sergeant
Senior Sergeant
 

Re: lua & xml

by Dreez » Sat Jan 02, 2016 5:54 pm

search tools
instead of "any time" click on "custom range"
1/1/2004-12/30/2006

you're welcome :)
Dreez - PvP server
<Endzeit>
User avatar
Dreez
Knight-Lieutenant
Knight-Lieutenant
 

Re: lua & xml

by Renew » Sat Jan 02, 2016 11:56 pm

imo there is no reason to use XML for GUIs in 2016...CreateFrame() was added in 1.10 and it gives the benefit of dynamic frame creation! also it gives waaay better overview then frames in XML (imo) :)

the only profit from XML is that you can make "virtual" frames as easy templates :)
my Addons:
- Vanilla Healing Assignments - /viewtopic.php?f=63&t=23326
- Vanilla Storyline -
User avatar
Renew
Senior Sergeant
Senior Sergeant
 

Re: lua & xml

by SSJSketch » Sun Jan 03, 2016 1:00 am

Renew wrote:imo there is no reason to use XML for GUIs in 2016...CreateFrame() was added in 1.10 and it gives the benefit of dynamic frame creation! also it gives waaay better overview then frames in XML (imo) :)

the only profit from XML is that you can make "virtual" frames as easy templates :)

Imo it just makes it neater, keeping frame creation in xml while the actual scripts/functions in lua. But that's just my thought process.
modui_ified
-----------------------------------------------------------------
"Success is buried in a garden of failure."
User avatar
SSJSketch
Grunt
Grunt
 

Re: lua & xml

by Rhena » Sun Jan 03, 2016 10:00 am

When you are using CreateFrame() it might give you the illusion that you can dynamically create AND remove frames. This is NOT true. Once a frame is created it will stay in memory until the ui is reloaded or you relog. This can lead to your addon making itself bigger and bigger the longer the client runs (memory leak). So always "recycle" your frames!
Author of LunaUnitFrames - The most advanced unit frames for classic WoW. Visit my GitHub page for them and some other tools i wrote.
Rhyna - Warrior | Nost PvP | Alliance
User avatar
Rhena
Sergeant Major
Sergeant Major
 

Re: lua & xml

by modernist » Sun Jan 03, 2016 12:21 pm

well it depends how often you cycle the creation of frames within a function, a good rule is to only create your frames outside so they will only ever be run once on login — or yeah, carefully recycle 'em.

for example, CustomNameplates is a really good example of a major addon NOT doing this and the reason i would not recommend it to people based on the code i've looked through — if i remember correctly it creates a set of 8 new "buff" frames on every tick of its OnUpdate. assuming that you're running at a consistent 60fps, thats 28800 frames being created and stacked on top of one another inside of a minute.

but in that case you couldn't use XML either, since the frames are parented to a scaling number of (dynamically created) nameplate frames.

the "keep it neat" thing makes sense, and i've sometimes used global vars so that i can keep frame creation in a 2nd, separate lua file. I wish there was the option to use namespaces as available in retail wow.
modernist
Sergeant Major
Sergeant Major
 

Re: lua & xml

by Renew » Sun Jan 03, 2016 12:40 pm

modernist wrote:for example, CustomNameplates is a really good example of a major addon NOT doing this and the reason i would not recommend it to people based on the code i've looked through — if i remember correctly it creates a set of 8 new "buff" frames on every tick of its OnUpdate. assuming that you're running at a consistent 60fps, thats 28800 frames being created and stacked on top of one another inside of a minute.


i dont think you can create frames onupdate without getting massiv fps dropdown...also there is only 1 event frame in whole CustomNameplates addon...
my Addons:
- Vanilla Healing Assignments - /viewtopic.php?f=63&t=23326
- Vanilla Storyline -
User avatar
Renew
Senior Sergeant
Senior Sergeant
 

Re: lua & xml

by modernist » Sun Jan 03, 2016 1:08 pm

Renew wrote:
modernist wrote:for example, CustomNameplates is a really good example of a major addon NOT doing this and the reason i would not recommend it to people based on the code i've looked through — if i remember correctly it creates a set of 8 new "buff" frames on every tick of its OnUpdate. assuming that you're running at a consistent 60fps, thats 28800 frames being created and stacked on top of one another inside of a minute.


i dont think you can create frames onupdate without getting massiv fps dropdown...also there is only 1 event frame in whole CustomNameplates addon...


https://github.com/jejkas/CustomNamepla ... es.lua#L87
https://github.com/jejkas/CustomNamepla ... s.lua#L151

looks like there's checks before creation initialises on any textures (and it uses CreateTexture parented to the plate itself rather than more frames), so i retract my complaint. maybe i was looking at a bootleg version previously.
modernist
Sergeant Major
Sergeant Major
 

PreviousNext

Return to Addons & macros