• 0

    posted a message on General Practise: named arguments, optional arguments
    Hello lua dwellers:

    If this two definitions are wrong/inconsistent plz don't bash me a hammer, I make many mistakes so tips are appreciated:

    D1 - First of all I will call Named Arguments the ability of a function to have it's arguments parsed in any order and properly assert them.

    D2 - Second definition, an optional argument is as it name refers a value that can be omitted.

    So let the discussion begin:

    Topic1 - How does the WoW API manages Named and Optional Arguments?.

    T2 - How does a wow-lua-coder should build a function with Named Arguments?. (Consider the very different cases even the obvious ones).

    T3 - How does a wow-lua-coder should build a function with Optional Arguments?. (Consider the very different cases even the obvious ones).


    According to PIL (programing in lua) doc:

    http://www.lua.org/pil/5.3.html


    Sometimes, however, it is useful to specify the arguments by name. To illustrate this point, let us consider the function rename (from the os library), which renames a file. Quite often, we forget which name comes first, the new or the old; therefore, we may want to redefine this function to receive its two arguments by name: -- invalid code
    rename(old="temp.lua", new="temp1.lua")
    Lua has no direct support for that syntax, but we can have the same final effect, with a small syntax change. The idea here is to pack all arguments into a table and use that table as the only argument to the function. The special syntax that Lua provides for function calls, with just one table constructor as argument, helps the trick:
    rename{old="temp.lua", new="temp1.lua"}
    Accordingly, we define rename with only one parameter and get the actual arguments from this parameter: function rename (arg)
    return os.rename(arg.old, arg.new)
    end
    Wich in short suggest to fix the issue with table a implementation; I just hope there is a better workaround. Also PIL generally refers to some un-updated practices.

    Ty.
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to Stop Literal String Highlight in Notepad++
    Xd
    I know.
    That is what I want but ...
    If it is possible in a more automated way...

    Thanks any way.
    Posted in: General Chat
  • 0

    posted a message on How to Stop Literal String Highlight in Notepad++
    Hi there, would be wonderful that Notepad++ stopped highlighting the literal strings so it would be much nicer to code Handlers Snippets?.

    I have been digging arround Notepad++ plug-ins forums and playing with the Notepad++ configurations files for hours with no good results; if anyone has achieved this or anything similar I would really greet the answer.

    Thanks for your Time.
    FF.
    Posted in: General Chat
  • 0

    posted a message on Custom Named Click Macro
    Interesting Fact for those reading.

    The /click macro can also pass down or up click.

    Example for a button down click:

    /click FreeFog_Switch Lock true
    Posted in: General Chat
  • 0

    posted a message on Custom Named Click Macro
    Sry I tested in a wrong context; the functionality is still working even if the click name begins with a "_".
    Posted in: General Chat
  • 0

    posted a message on Custom Named Click Macro
    Hi some time ago I had a macro like the following:

    /click FreeFog_Switch Lock


    Witch parsed a custom named click to a button.

    Q1 Is it possible to do something like that anymore?
    Q1.1How?

    Thanks for your time.
    Posted in: General Chat
  • 0

    posted a message on Nilling Attributes = Trash?
    I was coding around and I wondered:

    Q1 - Does setting an attribute to nil generate Garbage?

    Q2 - Is it recommended to reuse/set to false attributes instead of nil them?

    Q3 - If anyone is so kind can explain me the way attributes are managed in WoW in general and regarding Handlers?

    Thanks for your Time.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Ways To Bind Pet Commands
    Already done that way (using macrotext); but I just wanted to be sure;

    The problem is not that the functions are protected but it is that from inside a handler I cannot make the override bind since it some how the handlers environment excludes the PetFollow, PetAttack and else functions (I am not talking about slash commands but the function it self) (out side handlers it is possible).

    I also tried to make a reference to those functions but was impossible (at least to me).
    Posted in: Lua Code Discussion
  • 0

    posted a message on Ways To Bind Pet Commands
    Aren't there any directs commands?.
    Is my best bet to create a action macro button with macrotexts and pass clicks to it?.

    I tried using GetCursorInfo() to get the information about pet spells but I always got a nil return is there any other way?.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Ways To Bind Pet Commands
    Is there any more direct way to bind a pet command to a header other than:

    button:SetAttribute("_onclick",[[
            if down then
                print("Down");
                self:SetBinding(true, "MOUSEWHEELUP", "BonusActionButton1")
                self:SetBinding(true, "MOUSEWHEELDOWN", "BonusActionButton3")
                self:SetBinding(true, "BUTTON5", "BonusActionButton2")
            else
                self:ClearBindings()
            end
        ]]);


    What I mean is if there is a way to bind for example the "petfollow" action without binding the ActionButton or with out the use of other SecureButton; something like binding a spell to a key.

    Thanks in Advance.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Is SecureHandlerMouseUpDown functional?
    Thanks I just needed confirmation.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Is SecureHandlerMouseUpDown functional?
    Sry to disturb you all but I was wondering if:
    SecureHandlerMouseUpDownTemplate was functional.


    I have this little code:
    local button = CreateFrame("Button", "FFButton5", UIParent, "SecureHandlerMouseUpDownTemplate");
        button:SetAttribute("_onmouseup",[[
            print("Up ", button)
        ]]);
        button:SetAttribute("_onmousedown",[[
            print("Down ", button)
        ]]);
    
    SetBindingClick("2", "FFButton5", "LeftButton");
    SetBindingClick("3", "FFButton5", "RightButton");
    SetBindingClick("4", "FFButton5", "ClickC");
    and whenever I hit any of the above keys I get the following error:

    Message: ..\FrameXML\SecureHandlers.lua line 150:
    attempt to call method 'GetAttribute' (a nil value)

    Debug:
    [C]: GetAttribute()
    ..\FrameXML\SecureHandlers.lua:150: SecureHandler_OnMouseUpDown()
    [string "*:OnMouseDown"]:1:
    [string "*:OnMouseDown"]:1



    I would like to know if I am doing something wrong.

    Thanks for your time.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Transition From Burning To WoTK
    This is my replay to Alestante answer:
    http://forums.worldofwarcraft.com/thread.html?topicId=14990939194&postId=149893961019&sid=1#3

    You're on basically the right track. I would have your button that actually casts spells inherit SecureActionButtonTemplate and SecureHandlerStateTemplate. The button that changes the first button would inherit either SecureHandlerClickTemplate or SecureActionButtonTemplate with type "attribute". Finally, you'd register the first button with a state driver to set an attribute based on stance changes.

    The state handler snippet on the first button would set that button's "spell" attribute when the stance changed, according to the current value set by the other button. The other button's click handler would set the first button's "spell" attribute according to the current stance.
    it seams that I can't inherit the 2 templates the last one overwrites the first one or sometimes affects removing all visuals.

    Q6 : The following code works even in combat but I wonder if it is a waste to set all the spells of one state instead of just setting the spell that is going to be cast. I tried in many ways to do that but the only fair formula was the wrap coz it seams that inhering actionbutton and clickhandle to the same frame causes an overwrite .

    lua file
    local frame = CreateFrame("Frame")
    frame:RegisterEvent("PLAYER_LOGIN")
    frame:SetScript("OnEvent", function(self, event, ...)
            
        SetBindingClick("3", "FFButton1", "Token3");
        SetBindingClick("4", "FFButton1", "Token4");
        SetBindingClick("5", "FFButton1", "Token5");
        SetBindingClick("7", "FFButton1", "7");
        SetBindingClick("8", "FFButton1", "8");
    
    SecureHandlerExecute(FFButton1,[[
                                        FFAction = table.new();
                                        FFAction.State = table.new("restorarion","balance");
                                        FFAction.State.restorarion = table.new();
                                        FFAction.State.restorarion.Token4 = "Lifebloom";
                                        FFAction.State.restorarion.Token5 = "Mark Of The Wild";
                                        FFAction.State.balance = table.new();
                                        FFAction.State.balance.Token4 = "Thorns";
                                        FFAction.State.balance.Token5 = "Innervate";
        ]]);
        
        FFButton1:SetAttribute("_onstate-ww",[[
                                            local STATE = FFAction.State[newstate];
                                            if STATE then
                                                for token,button in pairs(STATE) do
                                                    local outPut = tostring(STATE[token]);
                                                    print("outPut: " .. tostring(outPut));
                                                    if outPut then
                                                        local SpellType = "spell-" .. tostring(token);
                                                        self:SetAttribute(SpellType, outPut);
                                                    end
                                                end
                                            end
        ]]);
    end)


    xml file
    <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">
    
    <Texture name="FreeFog_CT_Texture_Button_Up" setAllPoints="true" virtual="true">
        <Color r="0.3" g="0.7" b="0" a="1"/>
    </Texture>
    <Texture name="FreeFog_CT_Texture_Button_Down" setAllPoints="true" virtual="true">
        <Color r="1" g="0" b="0" a="1"/>
    </Texture>
    <Texture name="FreeFog_CT_Texture_Button_Disabled" setAllPoints="true" virtual="true">
        <Color r="0.3" g="0.3" b="0.3" a="1"/>
    </Texture>
    <Texture name="FreeFog_CT_Texture_Button_Highlight" setAllPoints="true" alphaMode="ADD" virtual="true">
        <Color r="0" g="0" b="1" a="1"/>
    </Texture>
    
    <Button name="FreeFog_CT_Button_1" inherits="SecureActionButtonTemplate" virtual="true">
        <Size x="100" y="15"/>
        <ButtonText name="$parentText"/>
        <NormalFont inherits="GameFontNormal"/>
        <HighlightFont inherits="GameFontHighlight"/>
        <DisabledFont inherits="GameFontDisable"/>
        <NormalTexture inherits="FreeFog_CT_Texture_Button_Up"/>
        <PushedTexture inherits="FreeFog_CT_Texture_Button_Down"/>
        <DisabledTexture inherits="FreeFog_CT_Texture_Button_Disabled"/>
        <HighlightTexture inherits="FreeFog_CT_Texture_Button_Highlight"/>
    </Button>
    <Frame name="FFHeader1" hidden="false" inherits="SecureStateHeader" parent="UIParent" movable="true" enableMouse="true">
        <Anchors><Anchor point="CENTER"><Offset x="0" y="0"/></Anchor></Anchors>
        <Size x="300" y="75"/>
        <Layers>
            <Layer level="ARTWORK">
                <FontString name="$parent_Text" inherits="GameFontNormal" text="FFHeader1">
                    <Anchors><Anchor point="TOPLEFT"/></Anchors>
                </FontString>
            </Layer>
            <Layer level="BACKGROUND">
                <Texture name="$parent_Background" setAllPoints="true">
                    <Color r="0" g="0.5" b="0.3" a="1" />
                </Texture>
            </Layer>
        </Layers>
    
        <Frames>
            <Button name="FFButton1" inherits="FreeFog_CT_Button_1, SecureHandlerStateTemplate" text="FFButton1">
                <Anchors><Anchor point="TOPLEFT" relativePoint="TOPLEFT"><Offset x="0" y="15"/></Anchor></Anchors>
                <Scripts>
                    <OnLoad>
                        this:RegisterForClicks("AnyDown");
                    </OnLoad>
                </Scripts>
                <Attributes>
                    <Attribute name="type" value="spell"/>
                    <Attribute name="unit" value="player"/>
                    <Attribute name="spell" value="Flight Form(Shapeshift)"/>
                </Attributes>
            </Button>
            <Button name="FFButton2" inherits="FreeFog_CT_Button_1" text="FFButton2">
                <Anchors><Anchor point="TOPLEFT" relativePoint="TOPLEFT"><Offset x="150" y="15"/></Anchor></Anchors>
                <Scripts>
                    <OnLoad>
                        this:RegisterForClicks("AnyDown");
                        this:SetAttribute("type", "attribute");
                        this:SetAttribute("attribute-frame", FFButton1);
                        this:SetAttribute("attribute-name", "state-ww");
                        this:SetAttribute("attribute-value1", "restorarion");
                        this:SetAttribute("attribute-value2", "balance");
                    </OnLoad>
                </Scripts>
            </Button>
        </Frames>
        <Scripts>
            <OnMouseDown>this:StartMoving();</OnMouseDown>
            <OnMouseUp>this:StopMovingOrSizing();</OnMouseUp>
            <OnDragStop>this:StopMovingOrSizing(); </OnDragStop>
        </Scripts>    
    </Frame>
    
    </Ui>


    Any ideas? How should I proceed?
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to hook an action button to go to a new target?
    Or get the unit attribute from the parent so that if in any case you want to change the unitId it would be easier
    Posted in: Lua Code Discussion
  • 0

    posted a message on Transition From Burning To WoTK
    The Following code illustrates what I wanted to do. Although the code works I am not sure if it is the right implementation of the resources provided by Blizzard, my hope is that someone would enlighten me so I can be in the right road to my intentions. (again Q1: Witch would be the best way to solve this using WoTK ways?.)

    Q4: I would also like to know if the Templates I use were the correct and most lightweight for what I did; in the future the buttons will not even have textures or any visible elements.

    XML File
    <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">
    
    <Texture name="FreeFog_CT_Texture_Button_Up" setAllPoints="true" virtual="true">
        <Color r="0.3" g="0.7" b="0" a="1"/>
    </Texture>
    <Texture name="FreeFog_CT_Texture_Button_Down" setAllPoints="true" virtual="true">
        <Color r="1" g="0" b="0" a="1"/>
    </Texture>
    <Texture name="FreeFog_CT_Texture_Button_Disabled" setAllPoints="true" virtual="true">
        <Color r="0.3" g="0.3" b="0.3" a="1"/>
    </Texture>
    <Texture name="FreeFog_CT_Texture_Button_Highlight" setAllPoints="true" alphaMode="ADD" virtual="true">
        <Color r="0" g="0" b="1" a="1"/>
    </Texture>
    
    <Button name="FreeFog_CT_Button_1" inherits="SecureActionButtonTemplate" virtual="true">
        <Size x="100" y="15"/>
        <ButtonText name="$parentText"/>
        <NormalFont inherits="GameFontNormal"/>
        <HighlightFont inherits="GameFontHighlight"/>
        <DisabledFont inherits="GameFontDisable"/>
        <NormalTexture inherits="FreeFog_CT_Texture_Button_Up"/>
        <PushedTexture inherits="FreeFog_CT_Texture_Button_Down"/>
        <DisabledTexture inherits="FreeFog_CT_Texture_Button_Disabled"/>
        <HighlightTexture inherits="FreeFog_CT_Texture_Button_Highlight"/>
    </Button>
    
    
    
    <Frame name="QTState" inherits="SecureHandlerStateTemplate" parent="UIParent">
            <Scripts>
                <OnLoad>
                    
                </OnLoad>
            </Scripts>
    </Frame>
    
    
    
    
    <!-- SecuFrames -->
    <Frame name="FFHeader1" hidden="false" inherits="SecureStateHeader" parent="UIParent" movable="true" enableMouse="true">
        <Anchors><Anchor point="CENTER"><Offset x="0" y="0"/></Anchor></Anchors>
        <Size x="300" y="75"/>
        <Layers>
            <Layer level="ARTWORK">
                <FontString name="$parent_Text" inherits="GameFontNormal" text="FFHeader1">
                    <Anchors><Anchor point="TOPLEFT"/></Anchors>
                </FontString>
            </Layer>
            <Layer level="BACKGROUND">
                <Texture name="$parent_Background" setAllPoints="true">
                    <Color r="0" g="0.5" b="0.3" a="1" />
                </Texture>
            </Layer>
        </Layers>
    
        <Frames>
            <Button name="FFButton1" inherits="FreeFog_CT_Button_1" text="FFButton1">
                <Anchors><Anchor point="TOPLEFT" relativePoint="TOPLEFT"><Offset x="0" y="15"/></Anchor></Anchors>
                <Scripts>
                    <OnLoad>
                    </OnLoad>
                </Scripts>
                <Attributes>
                    <Attribute name="type" value="spell"/>
                    <Attribute name="unit" value="player"/>
                    <Attribute name="spell-Restoration" value="Lifebloom"/>
                    <Attribute name="spell-Balance" value="Thorns"/>
                    <Attribute name="spell-MoW" value="Mark Of The Wild"/>
                    <Attribute name="spell-Innervate" value="Innervate"/>
                    <Attribute name="spell1" value="Mark Of The Wild"/>
                </Attributes>
            </Button>
            <Button name="FFButton2" inherits="FreeFog_CT_Button_1" text="FFButton2">
                <Anchors><Anchor point="TOPLEFT" relativePoint="TOPLEFT"><Offset x="150" y="15"/></Anchor></Anchors>
                <Scripts>
                    <OnLoad>
                        this:RegisterForClicks("AnyDown");
                        this:SetAttribute("type", "attribute");
                        this:SetAttribute("attribute-frame", QTState);
                        this:SetAttribute("attribute-name", "state-qt");
                        this:SetAttribute("attribute-value1", "1");
                        this:SetAttribute("attribute-value2", "2");
                    </OnLoad>
                </Scripts>
            </Button>
            <!-- Crear Boton de clase spell -->
        </Frames>
        <Scripts>
            <OnMouseDown>this:StartMoving();</OnMouseDown>
            <OnMouseUp>this:StopMovingOrSizing();</OnMouseUp>
            <OnDragStop>this:StopMovingOrSizing(); </OnDragStop>
        </Scripts>    
    </Frame>
    
    </Ui>
    Lua File
    local frame = CreateFrame("Frame")
    frame:RegisterEvent("PLAYER_LOGIN")
    frame:SetScript("OnEvent", function(self, event, ...)
        DEFAULT_CHAT_FRAME:AddMessage(tostring(FFButton1) .. "\n" .. tostring(QTState));
        
        SetBindingClick("5", "FFButton1", "VirtualFive")
        --RegisterStateDriver(QTState,"qt","[stance:5] 2; [stance:0] 1")
        
        
        
        QTState:SetAttribute("_onstate-qt",[[
                                            print("STATE qt: " .. "\n" .. tostring(self) .. "\n" .. "State ID = " .. tostring(stateid) .. "\n" .. "State Value = " .. tostring(newstate));
                                            if newstate == "1" then
                                                print("Current State is = 1")
                                            elseif newstate == "2" then
                                                print("Current State is = 2")
                                            end
        ]]);
        SecureHandlerSetFrameRef(FFButton1, "parent", QTState);
        SecureHandlerWrapScript(FFButton1, "OnClick", QTState,[[
                                print("B1:" .. "\n" .. tostring(self) .. "\n" .. tostring(button) .. "\n" .. tostring(down))
    
    --Q5: Solve with tables instead of "if" for every key by every state?
    
                                if self:GetFrameRef("parent"):GetAttribute("state-qt") == "1" then
                                    if button == "LeftButton" then
                                        return "Restoration"
                                    elseif button == "VirtualFive" then
                                        return "MoW"
                                    end
                                elseif self:GetFrameRef("parent"):GetAttribute("state-qt") == "2" then
                                    if button == "LeftButton" then
                                        return "Balance"
                                    elseif button == "VirtualFive" then
                                        return "Innervate"
                                    end
                                end
        ]])
    end)
    Q5: Solve with tables instead of "if" for every key by every state?
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.