RPG Maker MV / MZ Script Call List

● ARCHIVED · READ-ONLY
Started by Archeia 569 posts Page 21 of 29 View original ↗
  1. Nafraju said:
    $gameMap.eventsXy(199,150).length == 1
    Just to be sure: that checks if there is exactly 1 event on tile (199, 150). It ignores other characters (player, followers, vehicles) and will be false if there are 2 or more events there. It is also a check, rather than a trigger, i.e. by itself it doesn't cause anything to happen.

    If you only need to check for events, consider this instead:

    $gameMap.eventsXy(199, 150).length > 0
    Or just get the event ID using $gameMap.eventIdXy or the Get Location Info event command.

    If you did need to check for other character types as well, those would have to be done separately, e.g.

    [$gamePlayer, $gameMap.boat(), $gameMap.ship(), $gameMap.airship()].concat($gameMap.events(), $gamePlayer.followers()).some(function(char) { return char.pos(199, 150); })
    I.e. "loop through all characters [player, boat, ship, airship, map events, followers] and return true if at least one of them is on tile (199, 150); otherwise return false". :kaophew:

    Edit: corrected "other character types" code snippet to use concat for the events & followers, since they're arrays.
  2. Hi @caethyril
    caethyril said:
    Just to be sure: that checks if there is exactly 1 event on tile (199, 150). It ignores other characters (player, followers, vehicles) and will be false if there are 2 or more events there. It is also a check, rather than a trigger, i.e. by itself it doesn't cause anything to happen.
    Yes.
    And it will be also false if there are 0 (zero) events there.

    If you have 1 event on tile (199, 150) with "passage on" and another event moves on this tile (199, 150) you have $gameMap.eventsXy(199,150).length == 2 as true.

    I my case it should only detect events. (for event triggers event by touching)

    But YOU ARE RIGHT for checking if the tile is free ...
    ... of events = you do $gameMap.eventsXy(199, 150).length > 0
    ... free of anything = you do need to check for other character types as well

    The case ... free of anything I did have it until now.
    But for this there must be another directcode = to do it without loops.

    Where ever it is possible - particularly by RPG MAKER - DO NOT USE LOOPs !
    Because
    a loop takes time. And by RPG MAKER you have different timelines
    - scripttimeline
    - JSON access timeline
    - eventcontentprogressing timeline
    - rendering timeline
    - ...

    If you want avoid bugs avoid loops.

    Many other are also using waitloops for fixing the players avatar.
    I tried this and it causes many issues.

    Therefor I wrote a plugin which only do not execute the execute.move command.

    You can find it here:
    [on RPG MAKER discord]
    Discord - Group Chat That’s All Fun & Games
  3. Archeia said:
    This Script Call list applies to both RPG Maker MV and RPG Maker MZ.
    Link here to see the entire list.



    Supplementary Material for RPG Maker MZ:
    RPG Maker MZ Data and Script Call Reference
    Have fun eventing~

    This here is SUPER HELFUL. I stumbled into this a few days ago googling a crap ton of stuff about how to call certain things in RPG Maker Scripting because I know 0 javascript. or rather I knew 0. now I know enough to do some interesting things in RPG Maker MZ.
  4. I figured out a code that isn't in the excel sheet. if someone needs to see if a self switch is on, they can with:

    //return self switch value on Map 2, Event 1, SelfSwitch 'B'
    $gameSelfSwitches.value([2, 1, 'B'])

    This is direct from my game and functioning checking the 1st event in the 2nd map if self switch B is active. I didn't know if it would actually work or not because it wasnt listed as a viable script call in the google doc. Is posting here a good place to get it added or is there some other way to reach out to get the sheet updated with this.
  5. Spoontardis said:
    //return self switch value on Map 2, Event 1, SelfSwitch 'B'
    $gameSelfSwitches.value([2, 1, 'B'])
    ...wow, I'm amazed I missed that. Thanks! Just added it to the sheet as Get Self Switch, under "Switches & Variables" (currently row 551).

    And yes, this is a good place to post that kind of feedback. Let us know if you find anything else missing! :kaohi:
  6. I am trying to convert this Ruby scriptcall into JavaScript and it is not working. I do not know if this is because I have the wrong syntax or if it is because I need a different script call to achieve what I want.

    My objective is to show a battle transition image on map as part of my custom inn scene. The Ruby event is:
    1655275206521.png

    My JavaScript attempt, simplified for testing purposes is:

    1655275283730.png

    The event 'works' in that the fadeout, inn ME and fadein all happen, but not the battle transition image.

    Can anyone help me with this?
    Thank you
  7. @Kes - unfortunately I think you'll need a different approach: the MV/MZ core scripts don't have a native "transition" option available.

    If you can't fake the effect with Show/Move Picture commands, consider looking for a (time-dependent) screen filter or transition plugin. This one for MV looks ideal:
    For MZ the closest I found with a quick search was this, by the same author:
    The key thing is the WebGL fragment shader, which determines how each pixel is drawn. You might be able to get the GradientWipe plugin working in MZ via FOSSIL if need be?
  8. @caethyril Huge thanks for pointing these out to me. I'm going to have such fun using them, they open up so many possibilities, and looking at the second one I can already see the answer to something I was going to query later on.

    Your help is much appreciated.
  9. Using a set movement route command, I have the following script call for an event which will be run on the parallel process which runs when the map is loaded.

    moveto(15,15.5)

    The event does not budge. Is moveto not a valid JS script call?

    Thanks
  10. @Kes - moveto isn't a core script MV/MZ script call, no. Try one of these instead:
    • In a move route - place the character who is being moved at (15, 15.5):

      this.locate(15, 15.5);
    • In a "standalone" Script command - place "This Event" at (15, 15.5):

      this.character(0).locate(15, 15.5);
    • Anywhere - place map event ID 2 at (15, 15.5):

      $gameMap.event(2).locate(15, 15.5);
    Not sure how VX Ace handles this, but in MV/MZ character sprites automatically "slide" to their actual location. locate(15, 15.5) places the character at (15, 16) and their sprite at (15, 15.5). To make the sprite stay put you'll have to run this script call every frame. It may be simpler to make a new sprite with an appropriate offset?
  11. @caetthank you very much for this.

    EDIT
    Just thought through the implications of your final paragraph, which is going to be a tricky thing for me, as I used moveto for a variety of purposes.

    • If I wanted more than one event on a tile, but not exactly on top of the lower one, then moveto was the only way I knew of getting multiple events in the same place and the offset was then needed for aesthetic/gameplay purposes.
    • Having a sprite hanging off the edge of a cliff realistically.
    • Having a sprite (e.g. town guard) lurking where there isn't room for it to be a full tile back.
    • Having 2 sprites walking together holding hands without having to create a new 'double' sprite.
    • Similarly with 2 sprites hugging without having to create a kissing sprite.
    • etc. etc.
    I need the sprites to stay put unless/until I specifically want them to move away from that offset position. Making new sprites each time is not going to be realistically possible, particularly if I need the sprite to then move in a normal way.

    As it is, with the instance I'm concerned with now, I can see the sprite slide back to a full tile right under the eye of the player.
  12. @Kes - in that case consider a plugin, e.g. something to change the movement system (half-tile or pixel movement) or something that lets you assign character offsets. This one looks promising:
  13. @caethyril Having just had a quick look, it seems very promising indeed.
    Thank you so much for your help.
  14. @Kes
    if you use MV, there is one by YEP as well (paid) found [here]
    YEP_EventSpriteOffset, if you use MZ, the CTB can help, no sure
    if it works with FOSSIL though, but worth a try too.
  15. I want all followers to turn a certain way. I tried this:
    Code:
    $gamePlayer.followers.each {|follower|follower.setDirection(4)}

    It didn't work and the console showed this:
    SyntaxError: Unexpected token '{'

    Can someone advise me please what it should be.

    Thank you.
  16. @Kes - try one of these instead:
    • MZ:
      for (const follower of $gamePlayer.followers().data()) { follower.setDirection(4); }
      $gamePlayer.followers().data() gets an array of followers, then JavaScript's for...of statement is used to loop over those.

    • MV:

      $gamePlayer.followers().forEach(function(follower) { follower.setDirection(4); });
      (Technical note: this forEach is a method of Game_Followers, not Array.)
    Note that $gamePlayer.followers returns a function, but $gamePlayer.followers() (with brackets) evaluates that function and returns the result.

    Thanks for mentioning it! I'll consider adding these to the list as an "all followers" example. :kaohi:

    Also, a heads-up - for script call questions not directly related to stuff in the list, there's this thread:
  17. @caethyril Thanks for the reply.
    Also thanks for the heads up about the other thread. I'll be heading over there shortly with another query.
  18. Kes said:
    I want all followers to turn a certain way. I tried this:
    Code:
    $gamePlayer.followers.each {|follower|follower.setDirection(4)}

    It didn't work and the console showed this:
    SyntaxError: Unexpected token '{'

    Can someone advise me please what it should be.

    Thank you.
    That's Ruby syntax, but MV and MZ are written in Javascript. The JS equivalent of {|param|param.stuff()} is param => param.stuff() (or the function(param) syntax caethyril showed), and in JavaScript there is no option to call a function without parentheses, so you need to surround the entire construct in parentheses.

    This might be helpful to know if you have other pre-MV code you need to convert to work in MV or MZ.
  19. Back with another query.

    How do I check if any member of the party is inflicted with a particular state? I want to use it as script call in one conditional rather than having to do individual checks for each actor every time.

    Thank you.
  20. Updated the script call audio tab with "Change Current BGM Volume" for fellow Horror RPG Maker devs.