RPG Maker MV / MZ Script Call List

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,808
Reaction score
2,868
First Language
EN
Primarily Uses
RMMZ
$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.
 
Last edited:
  • Like
Reactions: Bex

Nafraju

Villager
Member
Joined
Mar 20, 2022
Messages
20
Reaction score
5
First Language
German
Primarily Uses
RMMV
Hi @caethyril
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]
 

Attachments

  • PLUGIN_NAFRAJU_PlayerMovementLocking.rar
    3.3 KB · Views: 1
  • README.txt
    4.2 KB · Views: 1

Spoontardis

The Dingalinguist
Member
Joined
Oct 4, 2015
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMZ
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:

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.
 

Spoontardis

The Dingalinguist
Member
Joined
Oct 4, 2015
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMZ
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.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,808
Reaction score
2,868
First Language
EN
Primarily Uses
RMMZ
//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:
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
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
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,808
Reaction score
2,868
First Language
EN
Primarily Uses
RMMZ
@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?
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
@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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
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
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,808
Reaction score
2,868
First Language
EN
Primarily Uses
RMMZ
@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?
 
Last edited:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
@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.
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,808
Reaction score
2,868
First Language
EN
Primarily Uses
RMMZ
@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:
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,006
Reaction score
2,349
First Language
Dutch
Primarily Uses
RMMV
@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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
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.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,808
Reaction score
2,868
First Language
EN
Primarily Uses
RMMZ
@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:
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
@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.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
715
Reaction score
307
First Language
English
Primarily Uses
RMMV
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.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,853
Reaction score
12,388
First Language
English
Primarily Uses
RMMZ
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.
 

Archeia

Level 99 Demi-fiend
Staff member
Developer
Joined
Mar 1, 2012
Messages
15,659
Reaction score
16,348
First Language
Filipino
Primarily Uses
RMMZ
Updated the script call audio tab with "Change Current BGM Volume" for fellow Horror RPG Maker devs.
 

Latest Threads

Latest Posts

Latest Profile Posts

well here's that concept art!
WIN_20220812_16_53_56_Pro (2).jpg
Whaddya think? Name suggestions?
Some character designs of 'Coin Locker'.
(there may be some future designs along the process.)


Untitled1294_20220813055849.png
1660339609612.png
Really need to come up with better names for my folders.
rpgmakerxp wrote on caethyril's profile.
Hi, I saw you comment a google drive link to add a specific script to a kadowa plugin for battle voices here: https://forums.rpgmakerweb.com/inde...attacking-defending-skills-damage-ect.119148/

I'd like to add "multiple possible battle voices" for stuff too, can you please let me know what to change cause the link isn't working.

Forum statistics

Threads
124,455
Messages
1,163,789
Members
163,276
Latest member
Ciberfreak
Top