MV How do I make a plugin run without plugin command?

good question, specially if a condition is met, will it continue or break
before it check the rest, but it need to be on each condition on the "else if"
and on the end, so there need to be a cleaner way to do it by than.

this going to be a bit more complicated than I though it will be.
as the way I placed wont work quite well.

I dont know the variables, but the structure is visible though.
maybe @Mac15001900 might have an idea, but I dont know if it can
be cleaner as well, depending on condition, and it could be easier and
shorter if its an array instead for those value, so you can use 1 or 2 variables,
and use the array for the values.

maybe the object to do it for you which could work as well.
The variables are all correct. You can trust me on that one. 😛 Many of those are plugin parameters. Others are formula's to calculate a certain value. And those values create a string, which is the final result written back into a $gameVariables.

I can tell you now what it is... Because.... Tackling this made me so excited, I announced the plugin on my website!


1710347462794.png
I have a smaller function to call by variables, and once set, in game editor,
it just run in parallel automatically for the month, day, hour, min, seconds.
it's not automatically like you do, or a list of to choose, but you have some
extra as well.

now I know why you want it automatically so they just can do "\v[x]" for it,
without calling a parallel on boot.

congrats though on making it work 🙂

if you dont use seconds, you can also update per minute (60 * 60) if your multiplier
allow eval for that 🙂

or use booleans for seconds, or minutes instead of multiplier.
I have a smaller function to call by variables, and once set, in game editor,
it just run in parallel automatically for the month, day, hour, min, seconds.
it's not automatically like you do, or a list of to choose, but you have some
extra as well.

now I know why you want it automatically so they just can do "\v[x]" for it,
without calling a parallel on boot.

congrats though on making it work 🙂

if you dont use seconds, you can also update per minute (60 * 60) if your multiplier
allow eval for that 🙂

or use booleans for seconds, or minutes instead of multiplier.
Not just \v[x]... But how about at 7pm it starts getting dark? Stores close at 6pm? Breakfast is served at 7am and lunch at noon. Vampires only come out at night, and butterflies only during the day.

That is all done with only use of the hours variable. 😛 Simply put that variable in the condition of an event, and it will appear when that hour is present and disappear when another hour is present (which would need an empty tab with that hour in the variables)

So it has to run constantly, so events will get triggered at certain times.

Like this window, of which the curtains open at 7am, and close to at 7pm
1710355211788.png


The lightning is included in the plugin (optional, can be disabled in the parameters) and weather is triggered by transfers, and according to season.

This goes way beyond just having a timestamp. 😛


Edit:

About the multiplier... I chose for a 6000% speed. Other users much want a 2000% speed or a 12000% speed. With this multiplier, anyone can choose the speed of their liking. It has nothing to do with how many times the clock updates. It is just a variable in the machine.
instead of scene map, another way is this one:

which might work too

JavaScript:
const scenebootStart = Scene_Boot.prototype.start
    Scene_Boot.prototype.start = function() {
        scenebootStart.apply(this, arguments);
            CalendarDate();
    };


function CalendarDate() {
    window.setInterval(function time() {
        let today = new Date();
        // your code here

    }, 5000); // 5 seconds or set variable here
};

this doesn't need the scene_Map and once the boot is done, it take the
code every 5 seconds or whatever interval they want in there.
@ShadowDragon - the engine already has a periodic update cycle and established structure separating one playthrough from another. Using setInterval or setTimeout creates a completely separate update schedule, which is likely to cause all kinds of unforeseen behaviour.
not sure, but you need a for...loop, increase it, and it its 20, re-run the code.
I can give an example later, 2-3 hours probably.

here is an example, but there might be better ways though.
JavaScript:
var _Scene_Map_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function () {
        _Scene_Map_update.apply(this);
            let int = 20;
            for (let val = 0; val < int; val++) {
                if (val > int) {
                    //you code here
                    val = 0; // repeat 0 to 20 before reset.
                }
            }
    }
there might be better ways, as like the while loop or val-- to decrease
the value which is also slightly faster than ++ but same result.

ES6 for advanced code are far cleaner and mostly a bit faster and sometimes
the older way is better, depends which you are comfortable with.
That is not how you would want to do it. Setting aside that there's a logic issue inside the loop (the if statement would never actually be true), the bigger issue is that it would stall your entire game while the loop is executing.

updatefunctions repeat automatically (they execute once every frame), so there is no need to create an additional loop. I think you were probably intending something more along these lines:
JavaScript:
(() => {
    var counter = 0;

    var _Scene_Map_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function () {
        _Scene_Map_update.apply(this);

        if (counter < 20) {
            counter++;
        } else {
            counter = 0;
            //Add your custom logic here
        }
    }
})();

Okay... I hope this will shine a little light on HOW I try to do things, even without spoiling WHAT I want to do. 😛

Do, as you can see, I have a large row with a lot of formula's. Each var is used in 2 or more formula's.
I don't need help with the formula's, so I left those out.

in the end, I have a few conditions, that might result in an action. Those actions are simply a "$gameVariables.setValue(x,y)" command.
None of that is really too important in terms of why people keep asking you to explain what you're trying to do. The important part is which game values you're trying to use in your formulas. That would determine whether you should be constantly running the code, as you are now, or if you might be able to only run the code when a specific thing (which causes the values to change) happens.

Using AquaEcho's situation as an example, since the value that she's interested in is player coordinates, there's no need to constantly run her code to check the coordinates, because player coordinates only change when the player moves. So instead of brute forcing it, she could just attach her code to one of the functions that get executed when the player moves. That way, her code only runs when it's actually necessary, rather than constantly consuming resources unnecessarily.

What you're doing right now *will* work, but without knowing which values your formulas are dependent on, it's hard to say whether or not it's the best way to go about it.

*edit* Oops, I missed the part where you already released the plugin.
Okay, I am going to be plain honest here, and say i am not understanding everything I read. I will try the latest piece of code by @Arthran and see how that works out, because that solution I understand the most of. 😛

That is not how you would want to do it. Setting aside that there's a logic issue inside the loop (the if statement would never actually be true), the bigger issue is that it would stall your entire game while the loop is executing.

updatefunctions repeat automatically (they execute once every frame), so there is no need to create an additional loop. I think you were probably intending something more along these lines:
JavaScript:
(() => {
    var counter = 0;

    var _Scene_Map_update = Scene_Map.prototype.update;
    Scene_Map.prototype.update = function () {
        _Scene_Map_update.apply(this);

        if (counter < 20) {
            counter++;
        } else {
            counter = 0;
            //Add your custom logic here
        }
    }
})();


None of that is really too important in terms of why people keep asking you to explain what you're trying to do. The important part is which game values you're trying to use in your formulas. That would determine whether you should be constantly running the code, as you are now, or if you might be able to only run the code when a specific thing (which causes the values to change) happens.

Using AquaEcho's situation as an example, since the value that she's interested in is player coordinates, there's no need to constantly run her code to check the coordinates, because player coordinates only change when the player moves. So instead of brute forcing it, she could just attach her code to one of the functions that get executed when the player moves. That way, her code only runs when it's actually necessary, rather than constantly consuming resources unnecessarily.

What you're doing right now *will* work, but without knowing which values your formulas are dependent on, it's hard to say whether or not it's the best way to go about it.

*edit* Oops, I missed the part where you already released the plugin.
Oh no, the plugin is not released yet. I think it will be a few more hours before everything runs, but I gave myself a few more days. I only announced it (which I actually planned on not doing... 😛 )

I don't use any game variables for my formula's. I only write the outcome in the variables.

The in-game time is based on Date.now(). I save a Date.now() at the start of the game in a const named CC_Start. Then ( Date.now() - cc_Start ) / 1000 is the amount of minutes passed in-game. And yes, this will mean time keeps ticking while the game is closed. That is wht I want to make a boolean so the user can choose to base it on playtime, which is equal to ( Date.now() - cc_Start ) / 1000, but pauses when the game is closed.

Edit: And I need it running all the time. Doesn't need to be every frame, so I will try your solution, but binding it to an action like walking, wouldn't work, because that means everything stand still if you stand still for 5 minutes, you take 1 step and suddenly it is 5 hours later. 😛

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-make-a-plugin-run-without-plugin-command.166725/