MZ What am I doing wrong here?

So I'm trying to rewrite a bunch of conditional events into JavaScript because I need a little fine-tuning with how well they work. It has lag because it reads everything 1 line at a time and it doesn't flow in game like I want it to. However I'm very new to JavaScript so I'm learning as I go.

So I was having an issue having it load into a variable but I think I figured that part out.

$gameVariables.setValue(19, Math.randomInt(100) + 1);

Let me know if I've done something wrong here.

Now my issue is the IF statements... I have:

If $gameVariables.value(11) > = 1 {the code I placed up top}

But I can't seem to trigger it to make that variable work in the IF statement... Am I writing something incorrect? And how would I go about fixing it?
The correct syntax is:
JavaScript:
    if ($gameVariables.value(11) >= 1) {
        console.log('do stuff!')
    }
I would recommend checking out codecademy or something similar. You don't need advanced JavaScript knowledge to start out. A foundational understanding combined with an understanding of the default script files will go a long way.
The correct syntax is:
JavaScript:
    if ($gameVariables.value(11) >= 1) {
        console.log('do stuff!')
    }
I would recommend checking out codecademy or something similar. You don't need advanced JavaScript knowledge to start out. A foundational understanding combined with an understanding of the default script files will go a long way.
Why console.log? In every script call list I've seen it doesn't reference this?
and I'll definitely check that out thanks!
Why console.log?
If you aren't familiar with console.log or its purpose in the context of my reply, then that's a sure sign you need to learn some basics before you tackle anything else.
It has lag because
lag is caused by bad logic design, not by either event commands or javascript.
switching a bad logic to javascript will not remove the cause for the lag.

you should show us what is lagging in your game and ask for help in optimization instead of trying to learn javascript for that.
Hey,

Thanks for the advice. I went back through my event and had a few pesky wait events tied to the move picture plugin. That created a sense of lag between 1 action to the next.
lag is caused by bad logic design, not by either event commands or javascript.
switching a bad logic to javascript will not remove the cause for the lag.

you should show us what is lagging in your game and ask for help in optimization instead of trying to learn javascript for that.
had a few pesky wait events
yes and no
a lot of people fail to understand what the wait command really does, and that can lead to lag if used wrong.

all events are handled by the main game loop, usually once per frame/per loop.
the wait command basically says "skip processing this event for x frames"

now, if you have a single sequence event (like a touch trigger or action trigger), that will result in a real wait for that specific event - and if nothing else happens that might look like lag.

If you have a parallel process however, that skipping the parallel process for a number of frames can have two different outcomes depending on the number of waits and the intention of the parallel process.
if the parallel process checks on slowly changing data, adding a number of waits reduces the lag of processing. for example if you check for a change of equipment to change the sprite, there is no need to check sixty times per second because the player rarely changes the actor equipment. So reducing the number of checks to once per 20 frames reduces processing and lag.
having a wait of 120 frames on the other hand can look as if the computer needs up to two seconds to react to a change - and a lot of people interpret that as lag when it is in reality not lag but a too long delay for the check.

That is why we never tell you a specific number of waits when saying that waits reduce lag on parallel processes - it always depends on the event and your game to decide which number is the best compromise between preventing real lag and creating pauses/fake lag.
and the advice that waits reduce lag never applies to the single process trigger where the waits are really waits.

Original thread: https://forums.rpgmakerweb.com/threads/what-am-i-doing-wrong-here.138127/