• 1 page(s)
Remove a Frame element with LUA
hi guys

i want to create a frame that shows your main bag's content with icons too...

so when i open up my addon frame the LUA dynamically draws a frame and draws the CURRENT content of my bag into...

is it possible to remove/delete/clear frames, textures and fontstrings ( xml elements ) with LUA somethings like Frame:Delete ?

thanks for any replies
Report this thread post

The frame is simply a table, from Lua's point of view.  You can delete it like any other table.  I'm willing to bet that WoW implements fontstrings, textures, etc. the same way, as either tables or variables.

What most addon writers do in this situation, though, is create a frame and reuse it each time, instead of creating and deleting frames.  Since Lua is garbage-collected, this saves memory -- you don't have "deleted" frames hanging around taking up memory until the garbage collection gets around to actually removing them.

Report this thread post

There is no deleting for frames, but you can hide them. Tables can be deleted, or wiped, however.

Project Lead for SmartRes and MrBigglesworthDeath. SmartRes2 coming soon!

 

Report this thread post

thanks guys

so when i open the addon's window (frame) the lua draws the elements into and when i close the garbage collector collects them so next time i open that the elements won't be drawn on each other cause a mass but because the garbage collector the last elements deleted by the GC and i can draw new elements in a clear frame?

Report this thread post

Actually I think you can remove frames if they were created from LUA code.  When you want to remove it, just call frame:Hide() on it and then set it to nil.  Then just call the garbage collector.

Example:

 

local MyFrame = CreateFrame("Frame", "MyFrameName", UIparent)

MyFrame:Hide()

MyFrame = nil

collectgarbage()

 

I currently use this in one of my addons.  I monitored memory usage and without the collectgarbage() call, memory usage keeps building up.  Use it and your frame is collected by the garbage collector

Report this thread post

thank you so much KC !


[edited by: richardCHEF at 9:47 PM (GMT -6) on 31 Oct 2009]

Report this thread post
  • 1 page(s)
Subscribe to this thread: (you will receive emails when new posts are made)