• 0

    posted a message on Best Lua coding practise for continuously called functions
    ok thank you didn't think about that as I just tend to put all my functions and stuff into tables and use local variables inside my functions all the time.
    Guess I have some optimization to be gained then :)
    Posted in: Need Help?
  • 0

    posted a message on Best Lua coding practise for continuously called functions
    I have noticed while developing on my addon that sometimes, when messing with functions which are continuously called from "OnUpdate" frame scripts, the memory usage for my addon start to rise aggressively (like +2kb per sec). I am quiet sure that local variables in the called functions are the guilty ones for this rise in memory usage.

    --this stuff is continuously updated
    function someFunction()
    	local var1
    	local var2
    	local var3

    I guess new memory for those local variables are allocated all the time, and then the garbage collector kicks in once in a while to clean up and then the rise of memory usage starts over again.

    If my assumption is correct, is it then better to refrain from using local variables in such functions and use global ones instead? OR is it best to use local variables because they use less CPU to access compared to global variables?
    Access to global variables in for example C programming is CPU expensive, but then again C is stack-based and Lua is register-based-VM...
    Posted in: Need Help?
  • 0

    posted a message on SecureActionButtonTemplate-button only enabled on alt+mousehover?
    HUURAAY!!! I made it work, thank you so much for helping out it was great inspiration :)

    The Solution:
    - create a Frame with 'SecureHandlerStateTemplate' as template.
    - setup statedriver and attribute to show and hide the frame based on the [alt] key as modifier.
    - create a Button with 'SecureActionButtonTemplate' as template, and the Frame created before as parent.
    - create the texture for the button highlight.
    - setup 'OnLeave' and 'OnEnter' scripts for the button to show and hide the button texture.
    	SimpleHUD["player"].clickable_Frame = CreateFrame("Frame", "player_clickable_Frame", UIParent, "SecureHandlerStateTemplate")
    	SimpleHUD["player"].clickable_Frame:SetAttribute("_onstate-visib", [[
    	if newstate == "show" then
    	elseif newstate == "hide" then
    	RegisterStateDriver(SimpleHUD["player"].clickable_Frame, "visib", "[mod:alt] show; hide");
    	SimpleHUD["player"].clickable_Button = CreateFrame("Button", "player_clickable_Button", SimpleHUD["player"].clickable_Frame, "SecureActionButtonTemplate")
    	SimpleHUD["player"].clickable_Button:SetAttribute("alt-type1", "target")
    	SimpleHUD["player"].clickable_Button:SetAttribute("unit", "player")
    	local clickable_ButtonTexture = SimpleHUD["player"].clickable_Button:CreateTexture("player_clickable_ButtonTexture", "HIGHLIGHT")
    	clickable_ButtonTexture:SetTexture(0.9, 0.5, 0)
    	SimpleHUD["player"].clickable_ButtonTexture = clickable_ButtonTexture
    	SimpleHUD["player"].clickable_Button:SetScript("OnEnter", function()
    	SimpleHUD["player"].clickable_Button:SetScript("OnLeave", function()

    I know its late to post it, but there was a bug in version of my addon which I reffered to earlier, its fxed now:
    If you wish to see it in action go download latest alpha of my addon http://wow.curseforge.com/addons/simplehud/files/ (its far from complete yet, but should be relative bug free)
    Posted in: Need Help?
  • 0

    posted a message on SecureActionButtonTemplate-button only enabled on alt+mousehover?
    I want to make a ('secure'-)frame which is only click-enabled when the mouse hovers over it while the [alt] key is held down. When the [alt] key is not held down it should be possible to click through the frame. I also want it to be possible to move the frame based on a user defined variable which locks or unlocks the position of the frame.
    Furthermore I want the frame to be kind of 'highlighted' when the mouse hovers over it while the [alt] key is held down, and nothing to happen when the mouse hovers over the frame without the [alt] key held down.
    The purpose of the frame, is to show information to the player and for the player to be able to target himself with it.

    I am pretty new to this 'SecureActionButtonTemplate'-stuff, but I have come up with this piece of code after reading up on it around the net:

    	SimpleHUD["player"].clickable_Frame = CreateFrame("Button", "player_clickable_Frame", UIParent, "SecureActionButtonTemplate")
    	SimpleHUD["player"].clickable_Frame:SetAttribute("alt-type1", "target")
    	SimpleHUD["player"].clickable_Frame:SetAttribute("unit", "player")
    	SimpleHUD["player"].clickable_Frame:SetScript("OnEnter", function()
    		if IsAltKeyDown() then
    	SimpleHUD["player"].clickable_Frame:SetScript("OnLeave", function()
    		if IsAltKeyDown() then

    This works almost the way I want, except that:
    - It is not possible to click through the frame when the [alt] key is not held down, it also highlights my character even though the [alt] key isn't activated.
    - The frame isn't highlighted when the mouse already hovers over the frame and the [alt] key is pressed.

    I think I might be able to fix the frame-highlighting problem, but I can't seem to find a solution to the "click-through" problem.
    I have unsuccessful messed around with:
    SimpleHUD["player"].clickable_Frame:Disable() / Enable()
    SimpleHUD["player"].clickable_Frame:EnableMouse(false) / EnableMouse(true)

    My conclusion so far:
    I think I have to disable and enable the 'Attribute'-stuff somehow based on whether the [alt] key is activated or not. But I don't know how to reset or disable these 'SetAttribute'-things in a proper way, and I wouldn't be surprised if this really isn't the solution.

    Any help will be appreciated.
    Posted in: Need Help?
  • 0

    posted a message on no such method GetUnitTarget("target")!??
    Awesome, thank you very much!. Then I don't have to guess and experiment to get what I want :P.
    This is going to be very useful for me :)
    Posted in: Need Help?
  • 0

    posted a message on no such method GetUnitTarget("target")!??
    I can't seem to find any api function that returns the target of a specific unit, like target of my target... Are there really no such method :S?, and if not then what cowboy tricks do you use to get target of target?

    ( My usual api information resource is http://wowprogramming.com/docs/api_categories, but I also looked at http://www.wowwiki.com/World_of_Warcraft_API )

    EDIT: Solved it!, yeh I know this post hasn't been up for long but I wont delete it, because maybe someone else has the same problem or run into the same problem (and google totally let me down this time)...

    Apparently you can write "targettarget" to get target of target, for example: UnitName("targettarget")
    Posted in: Need Help?
  • To post a comment, please or register a new account.