Token Movement

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Hello guys,
I'm using tokens in my game. Instead of walking from tile to tile they have this jumping, token-like movement, sort of like how you'd move a piece when you're playing chess.


You can see an example here of token movement I'd be going for. I'd like the token to keep the direction it'd be going for. So the character would be facing south, east, west and north depending on the way he/she would be moving.

As for the movement itself, the token would move one tile at a time.

I think that's about it. I don't know how hard this would be to code, hopefully not too complex as otherwise I doubt anyone would be willing to do it :).

Let me know if you have any questions and I'll do my best to answer them.

Thank you for reading.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
:kaohi: Hi! If this is forced movement (e.g. NPCs) you can simply use a move route with Jump commands. :)

If you want to override the player character's movement, try saving this as a .js file (or download the attachment) and import as a plugin:
Code:
Game_Player.prototype.executeMove = function(direction) {
  switch (direction) {
    case 2: return this.jump( 0,  1);
    case 4: return this.jump(-1,  0);
    case 6: return this.jump( 1,  0);
    case 8: return this.jump( 0, -1);
  }
};
This just replaces the player moves with the built-in "jump" move command, hope that's what you were after! :kaothx:

*bounces off-stage, pursued by a bear*
 

Attachments

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Thanks for the friendly reply.

I do want all the characters in game to move that way.

Out of curiosity why did you use curved brackets here { }? In other words, why did you use template literals?

I'm learning as I'm trying to figure this on my own. I'm still trying to grasp the use of template literals.
I did do an exercise about this and I understood it in context but here I don't get it.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Oh, I've just noticed something that might be an issue with my initial approach: jump ignores tile passability! :kaoback:

Assuming you never need characters to move "normally" rather than bouncing around, here's an alternative version that affects all characters and checks for passability (again, save as .js, import as plugin)~
Code:
Game_CharacterBase.prototype.moveStraight = function(d) {
  this.setMovementSuccess(this.canPass(this._x, this._y, d));
  if (this.isMovementSucceeded()) {
    switch (d) {
      case 2: return this.jump( 0,  1);
      case 4: return this.jump(-1,  0);
      case 6: return this.jump( 1,  0);
      case 8: return this.jump( 0, -1);
    }
  }
};
This version simply replaces the default "move up|down|left|right" code with something that'll make them jump in the appropriate direction instead. So you can set a move route to Move Up, and they'll jump one tile up instead of walking. :)

Out of curiosity why did you use curved brackets here { }? In other words, why did you use template literals?

I'm learning as I'm trying to figure this on my own. I'm still trying to grasp the use of template literals.
I did do an exercise about this and I understood it in context but here I don't get it.
The short answer is: I didn't. :kaoswt:

I believe template literals are an ES6+ feature related to strings, used for substituting values into text? Braces {} are used in JavaScript to declare a code block (see here for more details). In this case I've used blocks for the function contents (the code that overrides the default function) and for the switch statement (which is basically a concise chain of "if" statements based on a single value). :kaopride:
 

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
I believe template literals are an ES6+ feature related to strings, used for substituting values into text?
Yes, yes they are! That's why I was asking the question. I thought curved brackets were used exclusively for substituting values into text. That's exactly the exercise I had to do, which is why seeing it here seemed out of context (for a beginner like me). I've checked your link. I understand what you mean, thank you.

I wonder how you pros determine which library script to call upon. See, for me:
Code:
Game_CharacterBase.prototype.moveStraight
Doesn't tell me it's about character movement. I wonder how you pros figure out that's the right script call for what I'm going for. I would've never guessed it myself.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
I wonder how you pros determine which library script to call upon. See, for me:
Code:
Game_CharacterBase.prototype.moveStraight
Doesn't tell me it's about character movement. I wonder how you pros figure out that's the right script call for what I'm going for. I would've never guessed it myself.
The thing is, a plugin is essentially a mod for the engine. I.e. you need to know not only how JavaScript works, but also how the engine is structured. In this case you can start by searching rpg_objects.js for "Set Movement Route". This'll lead you to the code behind that event command:
Code:
// Set Movement Route
Game_Interpreter.prototype.command205 = function() {
    $gameMap.refreshIfNeeded();
    this._character = this.character(this._params[0]);
    if (this._character) {
        this._character.forceMoveRoute(this._params[1]);
        if (this._params[1].wait) {
            this.setWaitMode('route');
        }
    }
    return true;
};
You can then start following the chain back: forceMoveRoute leads to the _moveRoute property; some hunting around leads to the updateRoutineMove method, which invokes processMoveCommand; among the possible results are calls to moveStraight. :kaojoy:

Takes some getting used to. It's a similar idea for most stuff, though I admit move routes are not the simplest example to start with. :kaoslp:
 

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Let's see if I understand this:

1. Ok so what you're saying is that every event command is essentially a shortcut to something you would otherwise need to code from scratch in JavaScript. It just pulls a bunch of code (as a script) from the engine's database.

2. rpg_objects.js is where the javascript code for the events is kept. So if I know a command influences movement, I can check in that .js file to find what the code looks like.

3.
You can then start following the chain back: forceMoveRoute leads to the _moveRoute property; some hunting around leads to the updateRoutineMove method, which invokes processMoveCommand; among the possible results are calls to moveStraight.
This I find harder to understand. I don't understand what do mean by the word "chain'' here. This must be my inexperience speaking.

For instance, if I look at the content of rpg_objects.js I find this on google:
https://github.com/Archeia/RPG-Maker-MV-Game-Player/tree/master/rpg_objects
I can't find any "forceMoveRoute" there.

Is this something I can find information about in the help file or RPG Maker MV?
upload_2019-8-12_6-46-59.png

Feel free to ignore those questions. I'm asking to everyone in general, you've already helped a lot.

P.S.: I've tried your plug-in and it works great. I think there's some kind of graphic glitch however, two character set seem to be merged together?

It seems to be charset of Harold and Marsha merged together. That might not be related to your script however although it's the only thing I've added to the vanilla version.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Let's see if I understand this:

1. Ok so what you're saying is that every event command is essentially a shortcut to something you would otherwise need to code from scratch in JavaScript. It just pulls a bunch of code (as a script) from the engine's database.
Yes. The game itself is entirely HTML/JavaScript; event commands are simply an additional layer on top of that to make RPG Maker easier to use. Custom data for a command (e.g. the text for Show Text) is loaded as part of the map data and referenced by the underlying code as needed. :kaothx:

2. rpg_objects.js is where the javascript code for the events is kept. So if I know a command influences movement, I can check in that .js file to find what the code looks like.
Yes, among other things, rpg_objects.js contains the code for the event interpreter (Game_Interpreter), a class that is responsible for handling everything to do with event commands, i.e. queueing them up, translating them into code, and running that code. :kaopride:

3.

This I find harder to understand. I don't understand what do mean by the word "chain'' here. This must be my inexperience speaking.

For instance, if I look at the content of rpg_objects.js I find this on google:
https://github.com/Archeia/RPG-Maker-MV-Game-Player/tree/master/rpg_objects
I can't find any "forceMoveRoute" there.
A function typically contains code; that code can include a call to another function. Calling one function from another "chains" them together, one after the other, so called because now there's a single "thread" comprising two parts, like a chain with two links in it. :)

forceMoveRoute is a method of Game_Character. Note that the code is also available within your project's js subfolder, but unless you have an app designed for code-editing (e.g. VS Code, Atom, Notepad++, etc) you may find it more convenient to browse via github. :kaoswt:

P.S.: I've tried your plug-in and it works great. I think there's some kind of graphic glitch however, two character set seem to be merged together?

It seems to be charset of Harold and Marsha merged together. That might not be related to your script however although it's the only thing I've added to the vanilla version.
That'll be because of player followers, i.e. the non-leader party members who follow you around on the map: by default a jump gathers the party followers to the same tile as the player.

On the System tab in the database, you can either remove spare party members (select in the list in the top-left and press the Delete key) or uncheck the Show Player Followers option. :kaophew:

Edit: oh, and for learning about the default code files, you may find Trihan's "Jump into JavaScript" tutorials helpful~
 
Last edited:

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Thanks a lot! You can send me your paypal through PM, I can make a donation for your continued help.

Edit: oh, and for learning about the default code files, you may find Trihan's "Jump into JavaScript" tutorials helpful~
I've tried to read his tutorials. Although his knowledge is obvious, I find his explanations obscure for a non-initiated. I quickly gave up as I felt he didn't explain the concepts clearly enough for me to understand them. Just a few sentences wasn't enough for me.

That'll be because of player followers, i.e. the non-leader party members who follow you around on the map: by default a jump gathers the party followers to the same tile as the player.

On the System tab in the database, you can either remove spare party members (select in the list in the top-left and press the Delete key) or uncheck the Show Player Followers option. :kaophew:
Ah of course! How silly of me.

What I find the hardest at the moment is the terminology of JavaScript:
-Method
-Function
-Interpreter

Even if I read about it, I'm often confused with the underlying terminology which in turn makes it harder for me to progress.



See some things I don't understand from your code:
#1: I thought = was used to define variables but here it doesn't seem to be a variable.
#2: I thought if was always used with else.

I know some of them:
Operator: +, -, <, >, ===, !===, etc...
That's simple enough to understand.
Function: a reusable block of code that groups together a sequence of statements to perform a specific task.
I think what you coded is a function although I'm not sure.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Oh, I see! You may find this page useful, it introduces the concepts behind objects (including properties, functions, and methods): Working with Objects (MDN).

There's also the notion of inheritance, for example: Game_Event inherits the properties of Game_CharacterBase, which means an event has all the properties and functions of a "base" character (e.g. coordinates, movement, image), plus some extra event-only stuff (e.g. event ID, event commands, trigger). This section may help to illustrate the concept: Object Model - employee example (MDN).

As for what an interpreter is:
  • Game_Interpreter is an object in the game's code; as mentioned, it's the "blueprint", a.k.a. prototype, for the objects that handle everything to do with event commands.

  • The JavaScript interpreter is built into the browser running the game: it compiles the JS into binary as the game runs. (RMMV uses a fairly lightweight Chromium browser for playtest/deployment.) This kind of language is known as "interpreted" or "just-in-time compiled". Lower-level languages (e.g. C/C++) are typically pre-compiled, i.e. the binary executable is produced before the application is started. :kaoswt2:

The = operator is used for assignment. Here it is used to assign a function value to a property of the Game_CharacterBase prototype:
Code:
Game_CharacterBase.prototype.moveStraight = function(d) {
I.e. all Game_CharacterBase instances will now have access to a moveStraight method, which will make them (in this case) bounce in the specified direction. moveStraight is already defined on Game_CharacterBase: the plugin overrides the original definition with this new one.

"If" does not have to have an "else", just like you don't have to check the "else" box for a Conditional Branch command. :) Here it's used to do something (move the character) only if a particular condition is met (can they can pass through the specified tile?). More details here: if...else (MDN).

...aaand here's a link to Expressions and Operators (MDN) in case it helps. :kaoslp:

Hopefully that makes sense and helps clear things up a bit! Programming can be tricky to get into, but you'll probably get the hang of things soon enough if you keep at it. :kaothx:

(Also, the sentiment is appreciated, but no need for donations; I help out here for free~)
 

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
So I've read your comment with great attention.

OBJECT:
According to the link you've provided, an object is "a collection of properties". Hmm... this doesn't really tell me much unfortunately. Maybe I should understand the meaning of the word in a programming frame of reference.

The example of the cup did help however:
In JavaScript, an object is a standalone entity, with properties and type. Compare it with a cup, for example. A cup is an object, with properties. A cup has a color, a design, weight, a material it is made of, etc. The same way, JavaScript objects can have properties, which define their characteristics.
So rpgobjects.js is sort like a figurative 'cup', with its own properties.

PROPERTY:
An association between a name and a value. Now I think I know what a value is.
Here's an example:
upload_2019-8-13_0-59-14.png
I think in the example above, 'rows' and 'columns' are values.

Here's something I don't understand (I'll get back to the rest of your message after that:


upload_2019-8-13_1-27-16.png

Question:
So if I take:
Game_CharacterBase.prototype.moveStraight
Is 'Game_CharacterBase' an object, followed by 'prototype' which is a property of that object? What about 'moveStraight' in that case? Is it a property of 'prototype'? I'm just trying to wrap my head around this.

This is so confusing! :) I'll get there though! I just feel stuck with all the jargon. I don't feel like I have a grasp on any word-concept just yet.
 

Trace

A Rieri Fan :3
Member
Joined
Jun 7, 2014
Messages
10
Reaction score
9
First Language
Indonesia
Primarily Uses
RMMV
Maybe I can answer your question...

Game_CharacterBase.prototype is something you called when an object is created based on them
Let's say you create an object

Code:
var character = new Game_CharacterBase()
and that Game_CharacterBase class contains a function

Code:
Game_CharacterBase.prototype.moveStraight = function(d) {
  etc
  etc
};
so when you access your created object (that character var), you can access the moveStraight function
example

Code:
character.moveStraight(4);
then, you can move the character object as the moveStraight function is called


well, if you're not sure, function is something like car starter
you only have to put the car key ("d" in the moveStraight function), and rotate it (this is called as call)
then your car is ignited

but in the process, the ignition of a car is a lot of work process in it and in a program's view, it's a
block of program that run after it being called (like character.moveStraight(4))

I said "d" is the key to the moveStraight function is because when you put wrong key, they won't
work, and may causing an error...

Hope that helps you...
:kaoluv:
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
So I've read your comment with great attention.

OBJECT:
According to the link you've provided, an object is "a collection of properties".
Yes, though like you say re the cup example, it is often helpful to think about it in less abstract terms! :)

So rpgobjects.js is sort like a figurative 'cup', with its own properties.
Ah, technically not. rpg_objects.js is simply a file containing code; the code is split into separate files only to help keep things organised for humans. It contains text (code) but the file structure itself is largely irrelevant when it comes to interpreting that code. :kaoswt:

However, instances of Game_Event or Game_Map etc are like cups in that sense: they are code objects with properties, much like a cup has a size, shape, pattern, contents, etc. :kaojoy:

PROPERTY:
An association between a name and a value. Now I think I know what a value is.
Here's an example:
View attachment 121114
I think in the example above, 'rows' and 'columns' are values.
In a sense. rows and columns are their names, the values are the numbers (presumably) associated with those names. In this case a more typical name is "variable" or (since these are being passed as function inputs) "parameter", but they work just the same as properties~ :kaothx:

So if I take:
Game_CharacterBase.prototype.moveStraight
Is 'Game_CharacterBase' an object, followed by 'prototype' which is a property of that object? What about 'moveStraight' in that case? Is it a property of 'prototype'? I'm just trying to wrap my head around this.
Yes, mostly. In JavaScript (and many other programming languages) the dot is used to access properties. moveStraight is a property of Game_CharacterBase.prototype...imagine a "tree" or "chain" structure, kind of like having one folder inside another. Game_CharacterBase has a property called prototype, and that property has its own property/function called moveStraight. You may see the terms parent & child used in this context, e.g. Game_CharacterBase (parent) has a child property prototype.

The prototype property is made special by the way it is used, namely the Prototype Model (MDN). (Warning, this is going to get a bit technical, and probably isn't necessary to understand, particularly when you're just starting out! :kaoswt2:) Reference excerpt from RMMV's code:
Code:
Game_Event.prototype = Object.create(Game_Character.prototype);
Game_Event.prototype.constructor = Game_Event;
Here we see the Game_Event.prototype is assigned to an instance of Game_Character.prototype, i.e. "events" inherit all "character" properties. Then the prototype's constructor is set to the Game_Event object, which means that when the "new" operator is used to make a new event, it'll clone the prototype and add all the properties defined on Game_Event.

This is so confusing! :) I'll get there though! I just feel stuck with all the jargon. I don't feel like I have a grasp on any word-concept just yet.
I'm not surprised! I don't know what sort of background you have or what your area of expertise is, but you seem to be picking it up quite quickly. :D

Edit: ninja'd! :p
 

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
var character = new Game_CharacterBase()
1. So creating a variable is creating an object? So a variable is a type of object? Am I using the right word in saying "creating" or should it be something else?
2. So Game_CharacterBase() is a variable? It was created beforehand by someone else?
3. What kind of function is (d)? I'm using to seeing numbers and strings there. What is d in this context? It's a value? In this case? What value does it refer to?
4.
then, you can move the character object as the moveStraight function is called
I don't understand this sentence despite having read it multiple times. I'm sorry :(. So everything an object then? A variable is an object, a variable is an object? I didn't understand the car analogy either :(.
Ah, technically not. rpg_objects.js is simply a file containing code; the code is split into separate files only to help keep things organised for humans. It contains text (code) but the file structure itself is largely irrelevant when it comes to interpreting that code. :kaoswt:
5. So rpg_objects.js is just a file then. What do you mean it's split into separate files? What kind of files are contained into rpg_objects.js?
In a sense. rows and columns are their names, the values are the numbers (presumably) associated with those names. In this case a more typical name is "variable" or (since these are being passed as function inputs) "parameter", but they work just the same as properties~ :kaothx:
6. I don't understand this either. I thought rows and columns were values. Then I'd later on change those values to numbers in order to call the function to get a result. What's a function input then? I really need to get that vocabulary sorted out in my head.
7. Regarding your next paragraph, it's like GameCharacterBase (why don't you use camel casing here? Should the "g" be in smallcaps?) is the tree. Prototype is a branch and moveStraight is an extension of the prototype branch. It's sort a main folder with a subfolder which has another subfolder inside it. Why do you say property/function? Are they interchangeable in terms?

I'm still reading on inheritance, your message about it. I don't understand it but I'll keep reading about it.

8. Suppose I wanted to change the way the battles are in my little project. I would need to do just like you suggested that I do with the bouncing script. I would need to find how it's already handled by the library and modify what's there to suit my needs.



REVIEW:
a) Declaring a variable is the equivalent of creating a variable.
For example when I type in the following line of code:

const plantNeedsWater
I declare(create) the variable plantNeedsWater
b) There are different ways to declare variables such as: var, const and let.
c) Using these different words will influence the type of variable we're going to create.
d) Declaring a variable without a value would make that variable
undefined.
e) a variable name is essentially an identifier grammatically speaking. That's why variables should have representative names.
f) There are 5 main types of values. Namely:

1. Strings: "6", "apples", "I like candy"
2. Number: 6
3. Boolean: False & true values.
4. Null: I don't really get that one. Unless it means non-existent.
5. Undefined: For when you don't define your variable.

f) Just like there are various types of values, there are various types of operators.

1. Assignment Operator: assigns the value of the operand to the right to the operand to the left.
For example:
var a=1

2. Comparison Operators:
=== : equality (the same as)
!== : inequality (different than)
<, >, >=: greater than, lesser then, etc...

3. Arithmetic Operators:
+,-,*,/: this one is fairly simple.


g) Refactoring means rewriting code to make it more streamlined.
One way to refactor is to use a concise body.

 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
1. So creating a variable is creating an object? So a variable is a type of object? Am I using the right word in saying "creating" or should it be something else?
Yep, "create" is a common term in that context. Another possibility is "declare". I think "create" is more common, but the meaning remains intact, use whichever terms you prefer~ :kaothx:
2. So Game_CharacterBase() is a variable? It was created beforehand by someone else?
Game_CharacterBase is a variable whose value is an object, it's defined in the base code; Game_CharacterBase() is a function used to initialise the properties of new instances of that object's prototype:
Code:
function Game_CharacterBase() {
    this.initialize.apply(this, arguments);
}
new Game_CharacterBase() is a special statement that tells the game to create a new object using Game_CharacterBase as the prototype. The result is a new variable (distinct from Game_CharacterBase) whose value is an object.
3. What kind of function is (d)? I'm using to seeing numbers and strings there. What is d in this context? It's a value? In this case? What value does it refer to?
Here, d is a "function input", or more formally a "function parameter" or "function argument". It is a variable used inside the function, and its value is assigned when the function is called. For example:
Code:
$gameMap.event(1).moveStraight(4);
This calls the moveStraight function of the specified event with d = 4. Incidentally, the same principle is used with the event function here: we pass the value 1 into the function so that it'll return the Game_Event object for event ID 1. The result: event 1 will try to move one step to the left. (Directions are based on a standard numpad layout: 2 is down, 4 is left, 6 is right, 8 is up.)
4.
I don't understand this sentence despite having read it multiple times. I'm sorry :(. So everything an object then? A variable is an object, a variable is an object? I didn't understand the car analogy either :(.
Some value types are called "primitive": you've outlined the common ones in your Review section. Everything else is an object! :kaojoy:
5. So rpg_objects.js is just a file then. What do you mean it's split into separate files? What kind of files are contained into rpg_objects.js?
Ah, I should have been clearer there. I meant that the game code is split into files, and rpg_objects.js is one of those files. :kaoswt: You can easily open a project's folder through the editor by going to Game > Open Folder from the menu bar; from there, you can find all the code files (including rpg_windows.js, rpg_managers.js, etc) in the js subfolder. :)
6. I don't understand this either. I thought rows and columns were values. Then I'd later on change those values to numbers in order to call the function to get a result. What's a function input then? I really need to get that vocabulary sorted out in my head.
I think I've caused confusion by being too technical. A variable has a name, a.k.a. key, by which it is referred in code (e.g. "rows"); it also has a value assigned to it (e.g. 5). Function inputs are basically just variables used within a function, I mentioned them earlier in this post.
7. Regarding your next paragraph, it's like GameCharacterBase (why don't you use camel casing here? Should the "g" be in smallcaps?) is the tree. Prototype is a branch and moveStraight is an extension of the prototype branch. It's sort a main folder with a subfolder which has another subfolder inside it. Why do you say property/function? Are they interchangeable in terms?
Yes! Game_CharacterBase is defined in the default code, so we're just using the name it's been given. It's a common modern programming standard to name classes in PascalCase and objects (i.e. instances of those classes) in camelCase, cf. Coding style (MDN). You can name stuff whatever you like, though, as long as it's not a reserved keyword.

Technically speaking, like variables, a property has a key (a.k.a. name) and a value; that value may be a function.
I'm still reading on inheritance, your message about it. I don't understand it but I'll keep reading about it.
I wouldn't worry about it too much, I don't understand it all that well either! Unless you want to start making entirely new scenes/windows etc rather than just modifying the existing ones, you'll probably never have to use the concept.
8. Suppose I wanted to change the way the battles are in my little project. I would need to do just like you suggested that I do with the bouncing script. I would need to find how it's already handled by the library and modify what's there to suit my needs.
Yes! I would suggest experimenting with smaller-scale things first, though; RMMV's battle system is somewhat notoriously convoluted (Scene_Battle, BattleManager, various windows, etc). :kaoswt2:
 
Last edited:

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Again, thanks so much. Remember to let me know if you change your mind regarding a gift or if you'd like me to make a donation to something you care about. Or if you need pixel art assets.

Yes! I would suggest experimenting with smaller-scale things first, though; RMMV's battle system is somewhat notoriously convoluted (Scene_Battle, BattleManager, various windows, etc). :kaoswt2:
Could I have a suggestion as to what I could start experimenting with? Theory helps but practice helps me a lot.


Technically speaking, like variables, a property has a key (a.k.a. name) and a value; that value may be a function.
Ohhh! If I assign:
Code:
var myVar = 87
Then is myVar called a key then? I mean it's the name and the value in this case would be 87. Please tell me I'm right!
So the value of a property can be a function, it doesn't have to be just one of the regular 5 value types (string, number, etc...)

Function inputs are basically just variables used within a function, I mentioned them earlier in this post.
So the variables that are used within a function would be called function inputs.

Ah, I should have been clearer there. I meant that the game code is split into files, and rpg_objects.js is one of those files. :kaoswt: You can easily open a project's folder through the editor by going to Game > Open Folder from the menu bar; from there, you can find all the code files (including rpg_windows.js, rpg_managers.js, etc) in the js subfolder

upload_2019-8-14_9-48-33.png

Ahhh! So you mean this then? So all of those are the files that make up the code which we'll call upon. So anything I want to program in the game, I can just call upon those files right there.

Game_CharacterBase is a variable whose value is an object, it's defined in the base code; Game_CharacterBase() is a function used to initialise the properties of new instances of that object's prototype:
Here, I don't get what you mean by the word 'prototype'. I mean, I know what a prototype means but it's general meaning doesn't apply in the current context.
I mean this meaning of prototype:
upload_2019-8-14_9-52-48.png
This calls the moveStraight function of the specified event with d = 4. Incidentally, the same principle is used with the eventfunction here: we pass the value 1 into the function so that it'll return the Game_Event object for event ID 1. The result: event 1 will try to move one step to the left. (Directions are based on a standard numpad layout: 2 is down, 4 is left, 6 is right, 8 is up.)
Oh my god, I would've never guessed that in a thousand years.
I still don't get that part however. I mean why the letter d, that's what I don't get.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Could I have a suggestion as to what I could start experimenting with? Theory helps but practice helps me a lot.
I'm the same! Not sure what to suggest...I think the first plugin I wrote was one to change how much the audio volume "steps" when you press left/right in the in-game options. So, maybe stuff like that: very small changes, where you can guess at the location of the relevant code (rpg_windows.js in this case) and easily check whether the result works as expected in-game. What I do is try searching each code file for likely-sounding terms, e.g. "volume" in this case. Then you can try to track it down to (hopefully) a single method. Was super cool getting my first plugin to work, even if it was such a tiny thing. xP

Trihan's tutorials might make more sense now, if you want some idea of where to find stuff in the code. Also Poryg, a user here, has been posting some plugin-writing tutorial videos lately over on the MV Tutorials board, you may want to see if those are helpful/inspirational (not sure how "beginner level" they are): https://forums.rpgmakerweb.com/index.php?search/13549070/
Ohhh! If I assign:
Code:
var myVar = 87
Then is myVar called a key then? I mean it's the name and the value in this case would be 87. Please tell me I'm right!
Yep, the key is "myVar" and the value is 87. The terminology doesn't really matter too much if you understand how it all works, though. :kaothx:
So the value of a property can be a function, it doesn't have to be just one of the regular 5 value types (string, number, etc...)
Yes, values can either be objects (a function is technically a kind of object) or primitives (string, number, boolean, etc).
So the variables that are used within a function would be called function inputs.
Yes. As mentioned, though, "function parameters" or "function arguments" are more formal terms. :)
So all of those are the files that make up the code which we'll call upon. So anything I want to program in the game, I can just call upon those files right there.
Yes, all the code that makes it an RPG Maker game is in those files! :kaojoy:
Here, I don't get what you mean by the word 'prototype'. I mean, I know what a prototype means but it's general meaning doesn't apply in the current context.
Prototypes are used as a basis for creating multiple objects with the same properties. When a new object is created, a prototype can be specified: the newly-created object will then have properties and methods that match those of the prototype. The prototype itself isn't directly accessed: it's used as a base for creating "clones".

As an example, here's a couple of lines of code from rpg_objects.js (in case you're interested, this initialize method gets called when a new map is created):
Code:
Game_Map.prototype.initialize = function() {
    this._interpreter = new Game_Interpreter();
This creates a new instance of the Game_Interpreter object and assigns it to the _interpreter property of the map object. this is a special keyword used to refer to the current object, rather than the prototype.
Oh my god, I would've never guessed that in a thousand years.
It makes sense once you see it but yea, not obvious at first sight. :kaoslp:
I still don't get that part however. I mean why the letter d, that's what I don't get.
It's d for "direction". Technically you could call it whatever you like, e.g. d, dir, direction, cheese, etc. I think it's d just because the programmer didn't want to type more than necessary. :p
 
Last edited:

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Suppose I was to tweak how messages are displayed on screen (font size, the actual font, the way it's displayed etc...) should I go in rpg_windows? According to my research, yes, but I just wanted to make sure.

I'd like to search and experiment with this. I was wondering if this was the right place to go.

Thanks!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,115
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
I think so, yes. :)

Windows are arranged in scenes (e.g. Scene_Menu is the pause menu), so if you want to change the actual positions and such you may need to look in rpg_scenes.js~
 

Zizka

Veteran
Veteran
Joined
Oct 6, 2017
Messages
127
Reaction score
25
First Language
English
Primarily Uses
RMMV
Prototypes are used as a basis for creating multiple objects with the same properties.
So a prototype is like an original for future clones in other words.

When a new object is created, a prototype can be specified: the newly-created object will then have properties and methods that match those of the prototype.
So when you create a new object, you can tell it to be just like the prototype.

Do you think I should explore rpg_scenes.js first? Is it more simple to understand? I don't really want to modify code, I just want to understand what's being written.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top