JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 153 of 171 View original ↗
  1. caethyril said:
    @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.

    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?
  2. Even if it works shouldn't the text be flipping as well?
  3. 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.]
  4. utunnels said:
    Even if it works shouldn't the text be flipping as well?
    The screen flips but all text and gauges disappear.

    caethyril said:
    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
  5. 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.
  6. utunnels said:
    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:

    Default Screen
    1726584421473.png

    After running my original code:

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

    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;

    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)'
  7. Is there a command that would skip movie that is playing?
  8. How can I get the list of troops that were listed on a map's encounters?
  9. ElvenNeko said:
    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.

    Fionn23 said:
    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.
  10. caethyril said:
    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.
  11. 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?
  12. 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
  13. Robro33 said:
    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!
  14. Fionn23 said:
    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.
  15. ATT_Turan said:
    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.
  16. ATT_Turan said:
    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.
  17. DecastarDaDumy said:
    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.
  18. DecastarDaDumy said:
    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)
  19. 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.png1727458388707.png
  20. @DecastarDaDumy Are you using the correct engine? The question was asked for RPG Maker MZ and your profile says you use MV. MZ and MV do not use the same code for windows.