My Mod won't load through $INIT$ (1 Viewer)

DrZombi

Content Creator
Joined
Jul 10, 2016
Hi community,

I'm trying to create my own Mod to add some triggers to DialogueActions but after building the file, I can't load it through the $INIT$ folder. I can load the Mod through the GUI and it works, but if I put it in the $INIT$ folder, even at the end of the file, I'll always end up with a "Mod Loading Failed" Error...

I suspected a delay needed between the loading of DA and my mod but I tried the same loading sequence with Coli's Mod CustomAutomation (from which my mod is derivated), and there is no problem to load his mod just after DA through the $INIT$ folder.

So I'm very frustrated because the mod does work when loaded through the GUI but I can't figure out why it won't load at startup. I'm posting here in hope that experienced modders with a good knowledge of the SDT/Loader Architecture will know what could be the problem.

In case you need it, here is the code of my mod. I removed the specific functions I created to keep it short because I think that this is not relevant to troubleshoot this problem but if you need my complete code, no problem, just ask:

Code:
package
{
    import flash.display.MovieClip;
    import flash.utils.Dictionary;

    public dynamic class MoreTriggers extends MovieClip
    {
       
        private const API_DA:String = "DialogueActions";
        public var register:Function;
        private var _apiDict:Dictionary = new Dictionary();
        public var dialogueAPI:Dictionary;
        private var DAFound:Boolean = false;
        public var main;
        public var g;

        public function initl(l) : void
        {
            main = l;
            g = l.g;

            _apiDict["apiRegister"] = detectAPI;
            l.registerAPI("DA_Extension", _apiDict, true);
            main.unloadMod();
        }
       
        private function detectAPI(apiName:String, apiDict:Dictionary) : void
        {
            if(apiName == API_DA)
                doStuff();
        }
       
        public function apiNotify() : void
        {
            doStuff();
        }
       
        private function doStuff() : void{
           
            dialogueAPI = main.getAPI(API_DA);

            if (!DAFound){
                if (dialogueAPI == null){
                    main.updateStatusCol("DialogueActions API not found!","#FF0000");
                    return;
                } else {
                    DAFound = true;
                    if (!addTriggers()){
                        main.updateStatusCol("Dictionary Load Failed","#FF0000");
                        main.unloadMod();                       
                    } else {
                        main.updateStatusCol("MoreTriggers loaded successfully","#00FF00");
                    }
                }
            }
        }
       
        private function addTriggers():Boolean{
           
            register = dialogueAPI["registerTrigger"].getFunction();
           
            register("TONGUE_ADD", 0, tongueAdd, this, []);
            register("TONGUE_REMOVE", 0, tongueRemove, this, []);
            register("UPDATE_RESISTANCE", 1, UpdateRes, this, []);
            register("HIDE_HIS_LEFT_ARM", 0, hideHisLeftArm, this, []);
            register("SHOW_HIS_LEFT_ARM", 0, showHisLeftArm, this, []);
            register("TOGGLE_LOADER_ARM", 1, toggleLoaderArm, this, []);
            register("TOGGLE_NIPPLES", 1, toggleNipples, this, []);
           
            return true;
        }

...
 

stuntcock

Content Creator
Joined
Jun 5, 2012
I removed the specific functions I created to keep it short because I think that this is not relevant to troubleshoot this problem
This code throws runtime exceptions due to missing functions. Please post the complete code (or a compiled mod) so that we can bypass the surface-level stuff and troubleshoot the mod interactions.
 

DrZombi

Content Creator
Joined
Jul 10, 2016
Here you are,

The .as and the .swf. For now I've still not found anything relevant through my searches around the forum and guides... Many thanks for having a look at it, that's greatly appreciated :)

For your information, I use FlashDevelop (latest version) in which I created a new AS3 Project for Flash 11 (which is the flash_sa I use for SDT).

EDIT: I forgot to mention it but if you want to have a deeper comprehension of what I'm trying to do (for testing purposes for example), you may find the detailed use of each trigger in the posts I made when I originally added those triggers directly into DA: Pim_gd's Mods - DialogueActions v4.03 (22 Aug 2016)

But if you really need to test the triggers, you can just throw them randomly at the start of any dialogue, they have almost all easy to spot/immediate effects.
 

Attachments

MoreTriggers.txt
3.9 KB · Views: 173

MoreTriggers.swf
2.4 KB · Views: 199

Last edited:

stuntcock

Content Creator
Joined
Jun 5, 2012
I put it in the $INIT$ folder, even at the end of the file, I'll always end up with a "Mod Loading Failed" Error...
I'm unable to reproduce this problem.

I've placed MoreTriggers.swf immediately after SDTDialogueActionsv4.02.swf in the Mods\$INIT$\Mods.txt file. Tried again with pim_gd's new 4.03 file. Same result: no loading error.

Tried with your 4.03 and 4.04 files; got an error. This is as expected, since I was indirectly trying to register the new triggers twice.

I can get it to crash (undefined reference exception) if I try to load MoreTriggers.swf before dialogueActions.

There is a three-second timeout for the loading of a Character Folder (such as $INIT$). It's possible that you're encountering this error simply because your $INIT$ folder is heavily populated. Please review the Mods\$INIT$\Mods.txt file and comment-out some of the less crucial items by adding a semicolon at the beginning of each line. If the test seems conclusive (i.e. the error goes away), then it would be prudent to review the file more carefully; some of those temporary exclusions might become permanent. The goal would be to reduce your average loading-time until it's short enough to avoid any "Mod Loading Failed" errors.

The "Mod Loading Failed" error can also be triggered by a missing or renamed SWF file - often a vanilla import. That's probably not the culprit in this case, but it wouldn't hurt to do a few "clean" restarts (without loading the MoreTriggers mod in any way) just to be certain that the error doesn't appear spontaneously.

In case you're new to Flash debugging: if you click the "Dismiss All" button after seeing an exception, then the debugger app will silently discard all subsequent exception messages for the remainder of the app's lifespan. This behavior persists even if you restart Loader.swf via the File menu. Hence, you might be encountering an actual exception, with the "Mod Loading Failed" notification being a secondary consequence. If you've done the "Dismiss All" thing, then you must close down the Flash Player projector window and reopen it (and then open Loader.swf) in order to proceed with debugging.

P.S. If you're not sure what I mean by "debugger" then you should download the Flash Player Projector content debugger and use it whenever you're testing any mods.

For your information, I use FlashDevelop (latest version) in which I created a new AS3 Project for Flash 11 (which is the flash_sa I use for SDT).
Not a problem. I usually rely on the lightweight compiler (because it's "too simple to fail") and it's true that the lightweight compiler produces a smaller version of MoreTriggers.swf (1.39 kB vs 2.44 kB). However, I doubt that the problem here is related to your code or the structure of your mod file. It's probably something environmental.
 

Pim_gd

Content Creator
Joined
Jan 25, 2013
Code:
        public function registerTrigger(name:String, argumentCount:int, callback:FunctionObject):void {
            if (!hasTrigger(name, argumentCount)) {
                var triggerArray:Array = registeredTriggers[name];
                if (triggerArray == null) {
                    triggerArray = new Array();
                    registeredTriggers[name] = triggerArray;
                }
                triggerArray[argumentCount] = callback;
            } else {
                throw new Error("IllegalStateException: Already have such a trigger ["+name+"] with "+argumentCount+" arguments.");
            }
        }

DialogueActions will throw an error if the trigger cannot be registered. The debugger should be able to tell you about this error - failing that, you can try wrapping everything in try catch:

Code:
try {
 ... 
} catch (e:Error) { 
 main.updateStatusCol("Error: "+e.message+", "+e.errorID, "#FF0000");
}

Oh and uhhh

Code:
main.main.updateStatusCol("Dictionary Load Failed","#FF0000");

That's not gonna work. "main.main" doesn't exist. Try just using "main".
 

DrZombi

Content Creator
Joined
Jul 10, 2016
stuntcock stuntcock :

I'm unable to reproduce this problem.

Which is both a pleasure to hear and a total WTF lol ^^

There is a three-second timeout for the loading of a Character Folder (such as $INIT$). It's possible that you're encountering this error simply because your $INIT$ folder is heavily populated. Please review the Mods\$INIT$\Mods.txt file and comment-out some of the less crucial items by adding a semicolon at the beginning of each line. If the test seems conclusive (i.e. the error goes away), then it would be prudent to review the file more carefully; some of those temporary exclusions might become permanent. The goal would be to reduce your average loading-time until it's short enough to avoid any "Mod Loading Failed" errors.

I agree that this could be a problem but in this case why could I load Colin's Mod without any problem in the same conditions when it's a far bigger mod ? The truth is probably elsewhere, but I do keep a note on that 3 seconds time-out !

P.S. If you're not sure what I mean by "debugger" then you should download the Flash Player Projector content debugger and use it whenever you're testing any mods.

Thanks ! I am totally new to flash and I will definitely have a look at this, thanks !

Not a problem. I usually rely on the lightweight compiler (because it's "too simple to fail") and it's true that the lightweight compiler produces a smaller version of MoreTriggers.swf (1.39 kB vs 2.44 kB). However, I doubt that the problem here is related to your code or the structure of your mod file. It's probably something environmental.

Well... Did you regenerate totally my mod with the compiler or did you test directly the .swf I posted here ?
Because I just recompiled the mod with the Lightweight compiler and now it loads at startup with no problem ! (And I did not have to comment out other mods by the way). I really wonder what is the difference between the 2 generated codes but I'll stick to the lightweight compiler from now on !!

Many thanks for pointing this out, I did download this compiler and tested it on another mod but I would never have thought about this possibility !!

Pim_gd Pim_gd :

That's not gonna work. "main.main" doesn't exist. Try just using "main".

Ah ah yes ! The classical copy/paste stupidity ! I did spot that when I pasted the code in the codebox of the OP and I forgot to correct it in the file¨before uploading it to you.
Don't worry it is corrected :)

That seems highly not probable but could it be this error which caused the mod to not load well at startup ? I'll retry a compilation with flashdevelop without this error just to see...
...
And it still fails. So it is really a compilation difference. That's crazy but OK, good enough for me :)
 

DrZombi

Content Creator
Joined
Jul 10, 2016
In case anyone is interested and/or have the same problem, I finally solved it and am now able to compile with Flash Develop and the Mod loads well at startup in the $INIT$ folder.

What have I done ? I just downloaded the whole source of Dialogue Actions, renamed the project and replaced the files in src with my .as classes. And now it runs perfectly. So the problem was absolutely not in the code, but rather in the way I created my project in Flash Develop.

(I tried to compare my project and the DA project but in every menu I went, I never found out where the difference were. That's why I finally replaced everything except for the project file. And it works :tongue::grin:)
 

Users who are viewing this thread

Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.