JavaScript questions that don't deserve their own thread

$gameTroop.allMembers().length for what you asked
$gameTroop.aliveMembers().length for if you meant all alive enemies
@Lonewulf123 - a variety of on-map QTEs can be created with no plugins or scripting, e.g.
This might be a bit more effort but it definitely gives you more creative control~

Yeah, I’ve used some of these before. They’ve come in handy. Thank you for the help.

I’ve even come to a good solution for my earlier problem using some simple variables and switches.


New question though, I’m using this code to flip the battle screen for an event I’m planning.

Spoiler: Code
SceneManager._scene.scale.x = -1
SceneManager._scene.position.x += Graphics._width

it works! However all the text and gauges disappear from the screen.

Did I miss something in my code? Maybe there’s another lay to flip as well?
Even if it works shouldn't the text be flipping as well?
Yea, I'd try this instead:
JavaScript:
const c = SceneManager._scene._spriteset._battleField;
c.scale.x *= -1;
c.x = Graphics.boxWidth - c.x;
[Edit: replaced c.x += Graphics.boxWidth; with something to mirror the position instead, in case you want to loop it for a crab rave or something.]
Even if it works shouldn't the text be flipping as well?
The screen flips but all text and gauges disappear.

Yea, I'd try this instead:
JavaScript:
const c = SceneManager._scene._spriteset._battleField;
c.scale.x *= -1;
c.x = Graphics.boxWidth - c.x;
[Edit: replaced c.x += Graphics.boxWidth; with something to mirror the position instead, in case you want to loop it for a crab rave or something.]

I do love a good crab rave
Yeah, I know. I mean if you code works correctly, the text will also be flipped.
That is probably because MZ reworked the window layer render code to give better support for mouse control so you can't treate it like a sprite anymore.
For example, there will be glitches if you scale it or its parent. Things will not be simple if you want to scale a scene along with its windows.
Yeah, I know. I mean if you code works correctly, the text will also be flipped.
That is probably because MZ reworked the window layer render code to give better support for mouse control so you can't treate it like a sprite anymore.
For example, there will be glitches if you scale it or its parent. Things will not be simple if you want to scale a scene along with its windows.
Sorry, I misunderstood your post. My bad. You're definitely correct here, because I tried the code in MV and it everything is flipped (screen and text).

EDIT: searched the forums and found a good screen of it in MV: https://forums.rpgmakerweb.com/index.php?threads/screen-flip.112272/post-994643

Just to further prove you are in fact correct.

For reference, Default battle screen:

Spoiler: Default Screen
1726584421473.png

After running my original code:

SceneManager._scene.scale.x = -1
SceneManager._scene.position.x += Graphics._width

Spoiler: Flipped, but no text or hud images and graphics
1726584547287.png

With caethyril's code:

const c = SceneManager._scene._spriteset._battleField;
c.scale.x *= -1;
c.x = Graphics.boxWidth - c.x;

Spoiler: Flipped, but gauges log, and etc don't flip
1726584859374.png

Ideally, I'm trying to achieve something like this:

1726585042495.png


EDIT: someone else helped me out here

This code will flip everything -

Graphics._canvas.style.transform = 'scale(-1,1)'
Is there a command that would skip movie that is playing?
How can I get the list of troops that were listed on a map's encounters?
Is there a command that would skip movie that is playing?
Untested:
  • MV:
    JavaScript:
    Graphics._video.pause();
    Graphics._onVideoEnd();
  • MZ:
    JavaScript:
    Video._element.pause();
    Video._onEnd();
I'm not sure if more code would be needed to catch errors in edge cases.

How can I get the list of troops that were listed on a map's encounters?
  • MV or MZ:
    JavaScript:
    Array.from($gameMap.encounterList(), function(e) { return e.troopId; });
This should return an array of troop IDs.
Untested:
  • MV:
    JavaScript:
    Graphics._video.pause();
    Graphics._onVideoEnd();
  • MZ:
    JavaScript:
    Video._element.pause();
    Video._onEnd();
I'm not sure if more code would be needed to catch errors in edge cases.
Tested, works just right, thanks a lot!

I have another question. Here AquaEcho wrote a script that stops player movement during parallel events: https://forums.rpgmakerweb.com/index.php?threads/skip-part-of-the-event.171791/page-2#post-1469469

Is it possible to make the same thing for the menu, so when player presses escape menu will not open? And then return to normal with another command.
How would I call a function just before a random encounter happens? And is it possible to get the troop ID before that random encounter as well?
what are you trying to do that you'd need to get it before the encounter?
you could start poking around Game_Player.prototype.executeEncounter or
Scene_Map.prototype.updateEncounter. by the end of the former, the troop id for the BattleManager is already set, and at the end of the latter the battle scene starts
what are you trying to do that you'd need to get it before the encounter?
you could start poking around Game_Player.prototype.executeEncounter or
Scene_Map.prototype.updateEncounter. by the end of the former, the troop id for the BattleManager is already set, and at the end of the latter the battle scene starts
Just wanted to change the Battle BGM for each troop. I'll try this thanks!
Just wanted to change the Battle BGM for each troop. I'll try this thanks!
There's no need to go into code for this. Just leave the Battle Music blank in the System tab of your database, then give each troop a Turn 0 troop event that plays whichever track you like.
There's no need to go into code for this. Just leave the Battle Music blank in the System tab of your database, then give each troop a Turn 0 troop event that plays whichever track you like.
I already did (I saw your comment on another thread), but there's a slight delay to the BGM. That's why I'm trying this.
Code:
Window.prototype._makeCursorAlpha = function() {return this.contentsOpacity/255;};
Oh yeah, about that... It doesn't work. Even after putting it above all my other plugins, it still won't work.
Oh yeah, about that... It doesn't work. Even after putting it above all my other plugins, it still won't work.
Have you also tried below all other plugins?
If that doesn't help, then likely you have something overwriting it for that specific window. Try replacing Window with Window_MenuCommand.
Oh yeah, about that... It doesn't work. Even after putting it above all my other plugins, it still won't work.
Works perfectly fine for me when I provided the answer.

The correct way to test would be to turn off all your other plugins - as @Mac15001900 says, you must have something overwriting it at some level.

(also, you would put it beneath other things, not above - plugins get processed in order, so the lowest on the list gets precedence in case of any conflicts)
I tried both options, even deleted all my plugins (dw I got a backup) and nope, still won't work.
You can see in this screenshot. (too lazy to record)
1727458353992.png
1727458388707.png

Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/