DICE PACKS BUNDLE
Page 4 of 4 First ... 234
  1. #31
    Quote Originally Posted by SilentRuin View Post
    Not counting the extension.xml file this is the code in its entirety. Like I said - should have taken me 5 min but I'm fumble fingered and prone to typos so took me 1/2 hour

    Code:
    -- Store original ActionsManager2.encodeAdvantage function so we can restore it on close
    local saveencodeAdvantage = nil;
    
    function onInit()
    	saveencodeAdvantage = ActionsManager2.encodeAdvantage
    	ActionsManager2.encodeAdvantage = encodeAdvantage;
    end
    
    function onClose()
    	ActionsManager2.encodeAdvantage = saveencodeAdvantage;
    end
    
    function encodeAdvantage(rRoll, bADV, bDIS)
    	Debug.console("Advantages:encodeAdvantage called")
    	printstack();
    	if Input.isControlPressed() then
    		bADV = true;
    	else
    		if Input.isAltPressed() then
    			bDIS = true;
    		end
    	end
    	saveencodeAdvantage(rRoll, bADV, bDIS);
    end
    UGH now that I see it I will have to repackage it in this thread and give vex a less spammy version in console!!!! DAG NAB IT!!! 35 minutes total now

    [Update removed spammy prints - so fixed!!! See new .ext file in 2nd or 3rd post if you want the updated one]

    And remember people, and .ext file is just a .zip file renamed. It has ALL the code in it visible in notepad by anyone.
    Hey SilentRuin, total tangent here...
    That's a neat trick saving off the original function and restoring it with onClose(). In the one and only extension I've written I took great pains in an attempt to step back into the original logic flow after my inserted code, but I generally did so with manager_xx_override and then inserting a call to the real manager within the function.
    Code:
    function onInit()    
        ActionsManager2.encodeAdvantage = encodeAdvantage;                                                                
    end
    
    function encodeAdvantage(rRoll, bADV, bDIS)
        if Input.isControlPressed() then    
            bADV = true;    
        else    
            if Input.isAltPressed() then    
                bDIS = true;    
            end    
        end    
        ActionsManager2.encodeAdvantage(rRoll, bADV, bDIS);    
    end
    But that requires me tracking down anywhere the original call to ActionsManager2.encodeAdvantage is made and overriding it to call my own. Wish I woulda seen this trick about a week ago.

  2. #32
    Although looking into it, I suppose that trick only works for things that use a window?

  3. #33
    Quote Originally Posted by daddyogreman View Post
    Hey SilentRuin, total tangent here...
    That's a neat trick saving off the original function and restoring it with onClose(). In the one and only extension I've written I took great pains in an attempt to step back into the original logic flow after my inserted code, but I generally did so with manager_xx_override and then inserting a call to the real manager within the function.
    Code:
    function onInit()    
        ActionsManager2.encodeAdvantage = encodeAdvantage;                                                                
    end
    
    function encodeAdvantage(rRoll, bADV, bDIS)
        if Input.isControlPressed() then    
            bADV = true;    
        else    
            if Input.isAltPressed() then    
                bDIS = true;    
            end    
        end    
        ActionsManager2.encodeAdvantage(rRoll, bADV, bDIS);    
    end
    But that requires me tracking down anywhere the original call to ActionsManager2.encodeAdvantage is made and overriding it to call my own. Wish I woulda seen this trick about a week ago.
    Yeah, while you can't always prevent conflict between extensions, I try to minimize the impact of my code when I can. That way if someone else overrides it the only way they can screw me up is if their load order is higher - I won't mess them up. Course, Extensions = RISK and you can't guard against what you don't control. Still that's what I do when I can. If its .xml script I use the super calls to insure I call the original code - when I can.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in