Trilobytes MV #1: Dude, Where's My Autorun?

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV

Dude, Where's My Autorun? Version 1.0
Created by Trihan

Introduction
Have you ever been test playing your game when all of a sudden the player couldn't move any more? Ah, crap, looks like you probably have an errant autorun event that's screwing things up. But this is a 500x500 map with 150 events on it, and your autorun could be ANY ONE OF THEM! What to do, what to do...if only there were a plugin that could help. Well, now there is!

Features
- Display a list of every autorun page in the game that meets its conditions to run.
- Tells you how you can activate higher-numbered pages to turn the page off.
- Tells you whether the autorun page has an "erase event" command that makes it turn itself off.

Screenshots


How to Use
Install the plugin pretty much anywhere. Its functionality is entirely contained within a new DataManager function, so it won't cause compatibility issues with any other plugin unless for some reason another plugin adds a function to DataManager called locateAutorun, which I can't imagine will happen any time soon.

In order to use it, there are two commands; due to the utility-based nature of this plugin, you have to run it from the console as you can run it from any point in the game. The volume of potential output is too great to use message boxes or a scene for it. So press F8 to open the console and then enter one of the following:

DataManager.locateAutorun()

This will look through every map in the game for events with autorunning pages, and if it finds any will tell you whether they meet their conditions and what you'd have to do to turn them off. It won't give you every single autorun page; if it finds a non-autorun page that's higher than the autorun and has its conditions met, it won't mention that page.

Note that as this loads up the data for every map in the game, larger games may take a while to process.

DataManager.locateAutorun(mapId)

This will cause the output to be limited to the specific map ID you enter.

Demo
No demo available at present.

Script
Code:
//=============================================================================
// DudeWheresMyAutorun.js v1.0
//=============================================================================

/*:
 * @plugindesc Gives you a list of all autorun events in the game with locations.
 * Handy if you have a game freeze and don't know where the autoruns are.
 * @author John Clifford (Trihan)
 *
 * @help
 *
 * Open a console by pressing F8 and type one of the following to call the
 * relevant function:
 *
 * DataManager.locateAutorun();
 * The plugin will display a list of all maps detailing events with autorun pages,
 * detailing conditions and whether they are met.
 *
 * NOTE: Due to this function having to load data for every map in the game, it
 * may take some time to process for large games.
 *
 * DataManager.locateAutorun(mapId);
 * The plugin will display a list of events on the given map with autorun pages,
 * detailing conditions and whether they are met.
 *
 * ============================================================================
 * Changelog
 * ============================================================================
 * Version 1.0 - Initial release
 * ============================================================================
 */
 

(function() {
    DataManager.locateAutorun = function(mapId) {
        if (mapId) {
            if ($dataMapInfos[mapId]) {
                outputMapData($dataMapInfos[mapId]);
            } else {
                console.log("ERROR: Invalid map ID.");
            }
        } else {
            $dataMapInfos.forEach(function(mapInfo) {
                if (mapInfo) {
                    outputMapData(mapInfo);
                }
            });
        }
    };
  
    function outputMapData(mapInfo) {
        var autorunEvents = [];
                var xhr = new XMLHttpRequest();
                xhr.open("GET", 'data/Map%1.json'.format(mapInfo.id.padZero(3)));
                xhr.overrideMimeType('application/json');
                xhr.onload = function ()
                {
                    if(xhr.status < 400)
                    {
                        var mapData = JSON.parse(xhr.responseText);
                        var events = mapData.events;
                        events.forEach(function(ev) {
                            if (ev) {
                                ev.pages.forEach(function(page, index) {
                                    if (page.trigger === 3 && !autorunEvents.contains(ev)) {
                                        autorunEvents.push(ev);
                                    }
                                });
                            }
                        });
                        if (autorunEvents.length > 0) {
                            console.log("Map " + mapInfo.id + "(\"" + mapInfo.name + "\") contains " + autorunEvents.length + " autorun event" + (autorunEvents.length > 1 ? "s" : "") + ":");
                            autorunEvents.forEach(function(autoEv) {
                                console.log("  \"" + autoEv.name + "\" located at (" + autoEv.x + ", " + autoEv.y + ")");
                                var requiredConditions = [];
                                for (var i = autoEv.pages.length - 1; i >= 0; i--) {
                                    var conditionsMet = true;
                                    var page = autoEv.pages[i];
                                    if (page.trigger === 3) {
                                        console.log("    Page " + (i + 1) + ":");
                                    }
                                    var conditions = page.conditions;
                                    var condition;
                                    if (conditions.switch1Valid) {
                                        condition = $gameSwitches.value(conditions.switch1Id);
                                        if (!condition) {
                                            conditionsMet = false;
                                        }
                                        if (page.trigger === 3) console.log("      Requires switch " + conditions.switch1Id + " (" + (condition ? "MET" : "NOT MET") + ")");
                                    }
                                    if (conditions.switch2Valid) {
                                        condition = $gameSwitches.value(conditions.switch2Id);
                                        if (!condition) {
                                            conditionsMet = false;
                                        }
                                        if (page.trigger === 3) console.log("      Requires switch " + conditions.switch2Id + " (" + (condition ? "MET" : "NOT MET") + ")");
                                    }
                                    if (conditions.variableValid) {
                                        condition = $gameVariables.value(conditions.variableId) >= conditions.variableValue;
                                        if (!condition) {
                                            conditionsMet = false;
                                        }
                                        if (page.trigger === 3) console.log("      Requires variable " + conditions.variableId + " >= " + conditions.variableValue + " (" + (condition ? "MET" : "NOT MET") + ")");
                                    }
                                    if (conditions.selfSwitchValid) {
                                        condition = $gameSelfSwitches.value([mapInfo.id, autoEv.id, conditions.selfSwitchCh]);
                                        if (!condition) {
                                            conditionsMet = false;
                                        }
                                        if (page.trigger === 3) console.log("      Requires self switch " + conditions.selfSwitchCh + " (" + (condition ? "MET" : "NOT MET") + ")");
                                    }
                                    if (conditions.itemValid) {
                                        condition = $gameParty.hasItem($dataItems[conditions.itemId]);
                                        if (!condition) {
                                            conditionsMet = false;
                                        }
                                        if (page.trigger === 3) console.log("      Requires item " + conditions.itemId + " (" + (condition ? "MET" : "NOT MET") + ")");
                                    }
                                    if (conditions.actorValid) {
                                        condition = $gameParty.members().contains($gameActors.actor(conditions.actorId));
                                        if (!condition) {
                                            conditionsMet = false;
                                        }
                                        if (page.trigger === 3) console.log("      Requires actor " + conditions.actorId + " (" + (condition ? "MET" : "NOT MET") + ")");
                                    }
                                    if (page.trigger === 3) {
                                        if (conditionsMet) {
                                            console.log("    This page meets all conditions and will run on map entry");
                                            if (!conditions.switch1Valid && !conditions.switch2Valid && !conditions.variableValid && !conditions.selfSwitchValid && !conditions.itemValid && !conditions.actorValid) {
                                                var eraseEvent = false;
                                                var eventCommands = autoEv.pages[i].list;
                                                eventCommands.forEach(function(command) {
                                                    if (command.code === 214) {
                                                        eraseEvent = true;
                                                    }
                                                });
                                                if (!eraseEvent) {
                                                    if (i === autoEv.pages.length - 1) {
                                                        console.log("    WARNING: This page has no defined conditions and there are no non-autorun pages higher than it, so it is currently impossible to shut off.");
                                                    } else {
                                                        console.log("    WARNING: This page has no defined conditions. In order to shut it off, you will have to turn on a higher page by meeting the following conditions:");
                                                        requiredConditions.forEach(function(conditionSet) {
                                                            console.log("      Page " + (conditionSet[0] + 1) + ":");
                                                            if (conditionSet[1].switch1Valid) {
                                                                console.log("      - Turn ON switch " + conditionSet[1].switch1Id);
                                                            }
                                                            if (conditionSet[1].switch2Valid) {
                                                                console.log("      - Turn ON switch " + conditionSet[1].switch2Id);
                                                            }
                                                            if (conditionSet[1].variableValid) {
                                                                console.log("      - Set variable " + conditionSet[1].variableId + " to " + conditionSet[1].variableValue + " or higher");
                                                            }
                                                            if (conditionSet[1].selfSwitchValid) {
                                                                console.log("      - Turn ON self switch " + conditionSet[1].selfSwitchCh);
                                                            }
                                                            if (conditionSet[1].itemValid) {
                                                                console.log("      - Acquire item " + conditionSet[1].itemId);
                                                            }
                                                            if (conditionSet[1].actorValid) {
                                                                console.log("      - Add actor " + conditionSet[1].actorId + " to the party");
                                                            }
                                                        });
                                                    }
                                                } else {
                                                    console.log("    It erases itself so no further action necessary.");
                                                }
                                            }
                                            break;
                                        }
                                        else {
                                            console.log("    This page does not meet its conditions and will not run");
                                        }
                                    } else {
                                        if (conditionsMet) {
                                            console.log("    A higher non-autorun page (" + (i + 1) + ") meets its conditions, the autorun page will not run");
                                            break;
                                        }
                                        else {
                                            requiredConditions.push([i, conditions]);
                                        }
                                    }
                                }
                            });
                        } else {
                            console.log("Map " + mapInfo.id + " contains no autorun events.");
                        }
                    }
                }
                xhr.send();
    };
})();

FAQ
No questions at present.

Terms of Use
This plugin can be used freely for both commercial and non-commercial projects. No credit is necessary due to it being strictly for developer utility.

Credit and Thanks
- Trihan
- Thanks to all the newbies who have posted threads where this was their problem, prompting the idea in the first place.
 
Last edited:

Point08

Veteran
Veteran
Joined
Feb 10, 2015
Messages
115
Reaction score
115
First Language
English
This sounds like quite the useful tool. I love the stuff this community comes up with to make all our lives easier.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
Bumping this as I don't think it got much visibility when I first coded it and I think it's still a really useful utility for MV developers. Plus I want to see if anyone is using/has used it and whether it still works in the latest MV (so I know if I need to update it)
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
483
Reaction score
211
First Language
English
Primarily Uses
RMMV
I think it might be a little nicer if the default behaviour of DataManager.locateAutorun() was to check the currently-active map instead of every map; then you could pass 0 or something to check every map. (Since no map is active at the menu screen, it could still check every map by default if you run it from there.)

It does sound pretty useful in any case.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
That's not a bad suggestion. I'll consider changing it around for the next version.

Do you have any other suggestions for it?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Just a heads-up that Slip into Ruby and Jump into Javascript might be a bit slow for now while I'm on the team porting the YEP plugins to VisuStella's MZ suite.
So I managed to build a teleport skill. You can see the progression in the development topic
https://forums.rpgmakerweb.com/index.php?threads/in-dev-multi-hit-target-selection.125049/

Here's how it looks:


But the real question is, can I pull off FF8?

I love these little slime battlers. Really wish I could find more animated ones :'(
The curse of retail: you get ideas, you want to make something with those ideas, but because you're always at friggin' work you can't actually do anything with them.
Quexp wrote on lumimae's profile.
Welcome! :)

Forum statistics

Threads
100,629
Messages
977,958
Members
132,248
Latest member
Dealdeg
Top