RPG Maker MV / MZ Script Call List

Leonard

Warper
Member
Joined
Oct 27, 2015
Messages
4
Reaction score
1
First Language
Spanish
Had to do the correction here.   And I assume that 1 is the Character Number in the database.  If that's the case I'm good.

Now to find out what calls out the character's Level.
Yes, the 1 in 'if(entry._actorId==1)' (line 3) is the id in the database for the actor you are looking for. 

After the execution of this code the variable actor1Lvl will contain the level of the specified actor if it is currently part of the party otherwise it will contain -1.

Hope Its clearer now :)
 
Last edited by a moderator:

NoInkling

Veteran
Veteran
Joined
Oct 2, 2015
Messages
39
Reaction score
10
First Language
English
Primarily Uses
@ksjp17 Yeah in the console tab. If you're getting a syntax error it just means that whatever you're typing isn't valid javascript. It depends what you're trying to test/debug of course, but you should just be able to type a dollar sign and follow the autocomplete trail from there for basic stuff.

There are more advanced ways of debugging of course, but I won't go into those here. I suggest you just play around and get familiar with things, maybe look for a really basic video tutorial on the Chrome developer console if you want. I only say this because a lot of the questions here could be solved just by playing around and seeing what methods are available.
 

DavidFoxfire

Veteran
Veteran
Joined
Feb 28, 2014
Messages
224
Reaction score
44
Primarily Uses
Yes, the 1 in 'if(entry._actorId==1)' (line 3) is the id in the database for the actor you are looking for. 

After the execution of this code the variable actor1Lvl will contain the level of the specified actor if it is currently part of the party otherwise it will contain -1.

Hope Its clearer now :)
So it does two birds with one stone.  If the Actor is in the party, it'll return its level, and if it's now, it'll return -1.

So in theory, I can do this: 

function CharcterLevel (PCnumber){ var actor1Lvl=-1; $gameParty.allMembers().forEach(function(entry){ if(entry._actorId==PCnumber) actor1Lvl=entry._level; });return (actor1lvl);//If the player is in the party, it would return the Level of the character, if the character isn't part of the party, it would return -1}That'll be perfect.   Thanks :)
 
Last edited by a moderator:

rpglover88

Rpg & Anime Maniac
Veteran
Joined
May 12, 2013
Messages
169
Reaction score
24
First Language
French
Primarily Uses
@NoInkling: Thank you sooooo much! It worked perfectly! :D
 
Last edited by a moderator:
Joined
Oct 26, 2012
Messages
31
Reaction score
5
First Language
Indonesia
Primarily Uses
No one answered my request ;_;

I guess I just ask new one then

What is the script call for removing an actor from a certain slot?

Like I want to remove actor from slot 2 from the party.
 

Leonard

Warper
Member
Joined
Oct 27, 2015
Messages
4
Reaction score
1
First Language
Spanish
@Emje-noeg. 

//Remove a party member by slot id. (First slot is 0).var removeActorBySlot=function(slotToRemove){ $gameParty.removeActor($gameParty.allMembers()[slotToRemove].actorId());};This should work. :)
 
Joined
Oct 26, 2012
Messages
31
Reaction score
5
First Language
Indonesia
Primarily Uses
@Emje-noeg. 

//Remove a party member by slot id. (First slot is 0).var removeActorBySlot=function(slotToRemove){ $gameParty.removeActor($gameParty.allMembers()[slotToRemove].actorId());};This should work. :)
I try copy paste it, but did nothing... ;_;

Edit: I use only $gameParty.removeActor($gameParty.allMembers()[slotToRemove].actorId())

and it worked! Thank you Leonard~
 
Last edited by a moderator:

DCF

Villager
Member
Joined
Feb 6, 2014
Messages
24
Reaction score
15
First Language
English
You almost got it:

$gameSelfSwitches.setValue([$gameMap.mapId(), this.eventId(), 'A'], true)The second array element is just an ID, not an object. If you did want the event object you would just use "this" on its own from the movement route editor.

this.character() only works from within the normal event command context, not in a movement route one. The above command should work in both contexts though (even though "this" refers to something different in each one), though I'm not sure why someone would use it over a standard event command unless they were in an auto-movement route like you are.
Thank you. I was able to successfully flip the self switch with that script. The explanation was also very helpful. The syntax makes a lot more sense now that I see the correct calls for returning ids versus objects.

Is there a commented object definition that's accessible in the MV files I could use as a reference?

Thanks!

-DCF
 

zadck

Villager
Member
Joined
Apr 11, 2013
Messages
21
Reaction score
1
Primarily Uses
Just to clarify here.

For example, checking if an actor knows a skill. On the left column it has:

"# Checking Availability # ----------------------------------------------$game_actors[X].skills.include?($data_skills[Y]) # Checks if the actor X has learned skill YThis is the same as VX Ace?

On the right column it has:

$gameActors.actor(actorId).skills().contains($dataSkills[n])A_B structure isn't in MV. So I'm supposed to use the second one? Is the old one just listed for reference?
 

Blithe

The One
Veteran
Joined
Feb 4, 2015
Messages
41
Reaction score
31
First Language
English
Primarily Uses
RMMV
I was just wondering, since @zadck mentioned the script call to check for learned skills, is there a difference between using 

this:

$gameActors.actor(actorId).skills().contains($dataSkills[n])

or:

$gameActors.actor(actorId).isLearnedSkill(skillID)

I used the latter when attempting to script a custom action sequence and it gave me the result I was looking for. Should I have not used that?

Also does anyone know if there is a specific syntax to follow for processing the results of a scripted Show Choices? I recall in VX ACE that it was considered by many to be a bad idea to try to script that particular event command. Something to do with the branching if I remember correctly? I'm curious if it's still as big of a choir to script it now that it's a different scripting language.
 

NoInkling

Veteran
Veteran
Joined
Oct 2, 2015
Messages
39
Reaction score
10
First Language
English
Primarily Uses
Is there a commented object definition that's accessible in the MV files I could use as a reference?
Most of this kind of stuff is defined in rpg_objects.js, but no, other than a brief introduction for each class, most things aren't commented. You have to work out what methods/properties do from their name and code, or you can often look at the Game_Interpreter.prototype.commandxxx methods (luckily these are commented with their corresponding event command) to give you some helpful hints as well. "this" in an event page context is an instance of this Game_Interpreter class by the way.

On top of that you have to deal with inheritance so some methods will be defined elsewhere on superclasses, not necessarily in the same file. And the files are very long, it makes finding stuff a little annoying (ctrl + f is your friend).

This is partly why I recommend getting used to the F8 console - as long as you can get a reference to some object, adding a dot after it will pop up an autocomplete list of every property/method available on that object, and you can view those method definitions and execute them from right there in the console. Sometimes you may have to assign a variable to an object for this to work (i.e. if the object is returned by a method itself), e.g:

// In the console:> $gameMap.event(1). // won't give you an autocomplete popup> var blah = $gameMap.event(1)> blah. // will give you an autocomplete popupIf there's a specific object that you want to check out and play around with, but isn't accessible from global variables (at least easily), you can do a script command from within the editor to assign it to one. For instance, if we want the Game_Interpreter instance for an event page accessible in the console, we could add a script command at the top of that event page to assign "this" to a global variable:

window.blah = this // global variables are actually just properties on the window object// if we used `var blah = this` the resulting variable wouldn't be available in the console because it's limited to the current scopeThen all you have to do is activate that event ingame, and "blah" will be available in the F8 console just like it was in the event example. Note that this is all for testing/debugging purposes, it's bad practice to be assigning global variables and leaving them lying around normally.

There are also a bunch of methods that just print out data to the console that you can use in script commands, like console.log(...), console.warn(...), etc. Or you can use alert(...) to pop up an alert window with some information.

And then there's slightly more advanced methods like setting breakpoints, or using a "debugger" call (basically a breakpoint set from within the editor).

Anyway yeah, sorry for the wall of text, console use should probably have its own topic or something, but yeah I find it invaluable for discovering script commands, which is why I think it's relevant.
 

NoInkling

Veteran
Veteran
Joined
Oct 2, 2015
Messages
39
Reaction score
10
First Language
English
Primarily Uses
@Blithe I would definitely say your way is cleaner. As a general rule, if a specific method is provided by the engine and does what you want, you should use it. If you're using things like ".contains()" and array accessor notation, that's a hint that you may be re-implementing functionality that's already wrapped up in a method, and may be more optimized. That's not always true of course.

If you look at the "isLearnedSkill" method definition you'll see that it actually looks quite similar:

function (skillId) { return this._skills.contains(skillId);}Another example is people doing $gameMap.events()[1] instead of $gameMap.event(1). Functionally they're the same, but the very fact that the latter method is provided means that it's the one they intend for people to use (and it looks nicer).

As for Show Choices... at a quick view it still looks pretty complex.
 
Last edited by a moderator:

DCF

Villager
Member
Joined
Feb 6, 2014
Messages
24
Reaction score
15
First Language
English
Most of this kind of stuff is defined in rpg_objects.js, but no, other than a brief introduction for each class, most things aren't commented. You have to work out what methods/properties do from their name and code, or you can often look at the Game_Interpreter.prototype.commandxxx methods (luckily these are commented with their corresponding event command) to give you some helpful hints as well. "this" in an event page context is an instance of this Game_Interpreter class by the way.

On top of that you have to deal with inheritance so some methods will be defined elsewhere on superclasses, not necessarily in the same file. And the files are very long, it makes finding stuff a little annoying (ctrl + f is your friend).

This is partly why I recommend getting used to the F8 console - as long as you can get a reference to some object, adding a dot after it will pop up an autocomplete list of every property/method available on that object, and you can view those method definitions and execute them from right there in the console. Sometimes you may have to assign a variable to an object for this to work (i.e. if the object is returned by a method itself), e.g:

// In the console:> $gameMap.event(1). // won't give you an autocomplete popup> var blah = $gameMap.event(1)> blah. // will give you an autocomplete popupIf there's a specific object that you want to check out and play around with, but isn't accessible from global variables (at least easily), you can do a script command from within the editor to assign it to one. For instance, if we want the Game_Interpreter instance for an event page accessible in the console, we could add a script command at the top of that event page to assign "this" to a global variable:

window.blah = this // global variables are actually just properties on the window object// if we used `var blah = this` the resulting variable wouldn't be available in the console because it's limited to the current scopeThen all you have to do is activate that event ingame, and "blah" will be available in the F8 console just like it was in the event example. Note that this is all for testing/debugging purposes, it's bad practice to be assigning global variables and leaving them lying around normally.

There are also a bunch of methods that just print out data to the console that you can use in script commands, like console.log(...), console.warn(...), etc. Or you can use alert(...) to pop up an alert window with some information.

And then there's slightly more advanced methods like setting breakpoints, or using a "debugger" call (basically a breakpoint set from within the editor).

Anyway yeah, sorry for the wall of text, console use should probably have its own topic or something, but yeah I find it invaluable for discovering script commands, which is why I think it's relevant.
This was very informative. Thank you for taking the time to type this out. I've started testing with the F8 console and it's a big help.
 

DCF

Villager
Member
Joined
Feb 6, 2014
Messages
24
Reaction score
15
First Language
English
Using the F8 console I ran some tests and managed to string some code together and port it back in MV.

Purpose: Designing a moving event that damages the player on contact. I noticed that the event touch detection capability in MV is a little weak. The moving event damaged the player if the player moved into it but did not trigger if the event moved into the player. I switched to the parallel trigger and generated a conditional script to detect event touch.

Code below can be pasted into the conditional branch event command (script) to trigger subsequent event commands when the event is within 1 square of the player.

Math.abs($gameMap.event(this._eventId).deltaXFrom($gamePlayer.x))<=1 && Math.abs($gameMap.event(this._eventId).deltaYFrom($gamePlayer.y))<=1A small tweak can make the detection only occur when the event overlaps the player.

$gameMap.event(this._eventId).deltaXFrom($gamePlayer.x)==0 && $gameMap.event(this._eventId).deltaYFrom($gamePlayer.y)==0Also added a wait to the end of the triggered sequence to prevent the code from running multiple times for a single event touch.

This framework can be easily customized with different ranges and allows for events with through turned on to still trigger the effect.
 

Noferatsi

Level 10
Veteran
Joined
Dec 15, 2013
Messages
63
Reaction score
11
First Language
English
Awesome! I can start studying, now.  :D   :D
 

kewitt

Villager
Member
Joined
Feb 9, 2015
Messages
26
Reaction score
5
First Language
kewitt
Primarily Uses
There are 10 actors in my game and only 4 in the party at any given time.

There is a trial my actors need to go threw.  it a set of 5 battle,  If they Die no issue they get kicked back out but they loss 1/2 of the Gold and EXP they gain in the trial.

I want to do.

$gameVariables.setValue(x, $gameParty.leader()._exp), 1

But

$gameParty.leader()._exp

returns

Object {x: exp}

I'm not sure howto get the value of just EXP

I would just do set control variable in normal way but I can't get game data EXP for leader.  just an actor and I don't know which actor will be in the group.
 
Last edited by a moderator:

NoInkling

Veteran
Veteran
Joined
Oct 2, 2015
Messages
39
Reaction score
10
First Language
English
Primarily Uses
@kewitt Since $gameParty.leader()._exp is an object itself, you access it's properties like any other object: $gameParty.leader()._exp.x

However in this case I think "x" is actually a class ID which is numeric, so you have to use bracket notation to access it (just a quirk of JS): $gameParty.leader()._exp[1]

But don't do that anyway, just use the methods provided:

$gameParty.leader().currentExp()$gameParty.leader().changeExp(exp, show) // Absolute value (not just + or -, you have to calculate it based on current EXP). // When `show` is true, a level up message will show if the character levelled up (but not if they levelled down).Some other EXP related methods that might be useful to people:

Code:
.nextRequiredExp().currentLevelExp().nextLevelExp().expForLevel(level).gainExp(exp)        // Meant for use by battles, adjusts based on EXP rate (this means 0 by default for reserve members)..initExp()           // Resets EXP for current level
 
Last edited by a moderator:

kewitt

Villager
Member
Joined
Feb 9, 2015
Messages
26
Reaction score
5
First Language
kewitt
Primarily Uses
@kewitt Since $gameParty.leader()._exp is an object itself, you access it's properties like any other object: $gameParty.leader()._exp.x

However in this case I think "x" is actually a class ID which is numeric, so you have to use bracket notation to access it (just a quirk of JS): $gameParty.leader()._exp[1]

But don't do that anyway, just use the methods provided:

$gameParty.leader().currentExp()$gameParty.leader().changeExp(exp, show) // Absolute value (not just + or -, you have to calculate it based on current EXP). // When `show` is true, a level up message will show if the character levelled up (but not if they levelled down).Some other EXP related methods that might be useful to people:

.nextRequiredExp().currentLevelExp().nextLevelExp().expForLevel(level).gainExp(exp) // Meant for use by battles, adjusts based on EXP rate (this means 0 by default for reserve members)..initExp() // Resets EXP for current level

Thank I had just found it myself.  under __proto__  
 

NoInkling

Veteran
Veteran
Joined
Oct 2, 2015
Messages
39
Reaction score
10
First Language
English
Primarily Uses
Thank I had just found it myself.  under __proto__  
Yup, or you can type Game_Actor.prototype to find the same thing.

Or just rely on autocomplete like I've mentioned in my previous posts. Has the benefit of searching up the prototype inheritance chain, but that gives you more methods to look through to find the one you want. You can manually look at the prototype's .__proto__ (and so on) to find inherited methods if you prefer that way.
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Noriko_Human.png
Worked on some face-sets. Need to finish up the lot and cut some out of the game. She's looking pretty cute.
Even though I'm not going for the first time in...ten years or something...ordered my Gen Con dice!
Will be focusing on map making today and adding locked chests :LZSsmile:Screenshot 2021-09-16 095316.png
It's hard to stay consistent for at least a week
new enemies for the game I'm working on...

Forum statistics

Threads
115,106
Messages
1,087,269
Members
149,572
Latest member
Hosogawa
Top