Burgerland

Veteran
Veteran
Joined
Sep 26, 2015
Messages
345
Reaction score
95
First Language
English
Primarily Uses
N/A
I'm using

$gamePlayer.terrain_tag===1

but player keeps phasing over the tagged tiles without anything happening. So what's the correct script call?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,158
Reaction score
10,731
First Language
Czech
Primarily Uses
RMMV
What's happening?
Machine only tells you what you tell it to do. It doesn't have any implicit knowledge as to what you want it to do. Therefore if you ask it to search for a wrong variable, it will search for wrong variable.
I can't tell you the exact name now, but search the core scripts for terrain and maybe you'll find out how terrain tags are called.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,169
Reaction score
15,542
First Language
English
Primarily Uses
RMMV
$gamePlayer.terrainTag() === 1

I'm surprised that's not actually causing your game to crash, the way you have it. Unless there's a try/catch by default.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,158
Reaction score
10,731
First Language
Czech
Primarily Uses
RMMV
@Shaz That's how javascript works.
If you have a top level variable that is undefined, Javascript reports an error and the game crashes.
If you have an undefined attribute of an object, Javascript, unlike Ruby or Python, is completely fine.
You just can't use methods or attributes of undefined methods or attributes.
For example:
You can't use terrainTag if it's not defined. Even if you try a code
Code:
if (!!terrainTag)
, which is supposed to convert the undefined value to false, JS will throw an error, because terrainTag is not defined.

Of course you can't use
Code:
$gamePlayer.terrainTag()
if it's not defined, because undefined is not a function.

However, using
Code:
$gamePlayer.terrainTag
is completely fine even if terrainTag is undefined. This is how JS handles potentially undefined attributes.

What is not fine though is
Code:
$gamePlayer.terrainTag.value

// or
$gamePlayer.terrainTag.setValue ()
if terrainTag is undefined. It will result in a crash.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,169
Reaction score
15,542
First Language
English
Primarily Uses
RMMV
@Poryg - so $gamePlayer.terrain_tag is okay because it's a variable, even though it isn't defined, but you couldn't do $gamePlayer.terrain_tag() because it's a function call and the function isn't defined?

Talk about confusing! How do you pick up typos like the OP has made then - apart from the fact that the game doesn't do what you expect?
 

Burgerland

Veteran
Veteran
Joined
Sep 26, 2015
Messages
345
Reaction score
95
First Language
English
Primarily Uses
N/A
What's happening?
Machine only tells you what you tell it to do. It doesn't have any implicit knowledge as to what you want it to do. Therefore if you ask it to search for a wrong variable, it will search for wrong variable.
I can't tell you the exact name now, but search the core scripts for terrain and maybe you'll find out how terrain tags are called.

Alright, I'll check.

$gamePlayer.terrainTag() === 1

I'm surprised that's not actually causing your game to crash, the way you have it. Unless there's a try/catch by default.

I think you added a try/catch to your script, I used the ace-to-mv converter script.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,158
Reaction score
10,731
First Language
Czech
Primarily Uses
RMMV
@Shaz Simple. It's exactly due to the fact that what I expect doesn't happen. Then I can open the console, print appropriate objects and see for example that a sprite's x is NaN. So that means I must have used an undefined variable for math.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,169
Reaction score
15,542
First Language
English
Primarily Uses
RMMV
I used the ace-to-mv converter script

The Ace-to-MV converter does not convert script calls. That's up to you to do. It does provide a list of all places where script calls are used, but you've got to fix them manually.

Ace uses $game_player; MV uses $gamePlayer.
Ace uses .terrain_tag; MV uses .terrainTag().
Ace uses ==; MV uses ===.

What you have there is a script call that's half Ruby and half Javascript. It looks like you started to do it manually, but only did part of it.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,158
Reaction score
10,731
First Language
Czech
Primarily Uses
RMMV
MV uses both == and ===. == means is equal to in value and === means is identical to, in other words is equal both in value and in type. I use === only in cases when I need to find undefined variables though.

But yes, quite often in ruby the variables are typed like
$game_player
$game_actor

while in JS it's not _ with lowercase, but these two are replaced by an uppercase.

$gamePlayer
$gameActor
terrainTag instead of terrain_tag

and so on.
 

Burgerland

Veteran
Veteran
Joined
Sep 26, 2015
Messages
345
Reaction score
95
First Language
English
Primarily Uses
N/A
The Ace-to-MV converter does not convert script calls. That's up to you to do. It does provide a list of all places where script calls are used, but you've got to fix them manually.

Ace uses $game_player; MV uses $gamePlayer.
Ace uses .terrain_tag; MV uses .terrainTag().
Ace uses ==; MV uses ===.

What you have there is a script call that's half Ruby and half Javascript. It looks like you started to do it manually, but only did part of it.

I know it doesn't convert script calls, that's why I have half JS - I've been trying to find the correct script call and only found part of it. Also, $gamePlayer.terrainTag()==1 works. Thank you for providing it.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,169
Reaction score
15,542
First Language
English
Primarily Uses
RMMV
I get confused with JS's == and === so I just use === all the time.

I know it doesn't convert script calls
I thought you were saying the converter did that :)

If you get stuck with something like that, you can always look for an event command that does it (in this case Get Location Info) and take a look at rpg_objects.js at the Game_Interpreter.prototype section way down at the bottom, and see what it does behind the scenes. In most cases, if you find Game_Interpreter.prototype (to get to the beginning of that class definition) you can then search for the exact text that shows on the event command button.
 

Burgerland

Veteran
Veteran
Joined
Sep 26, 2015
Messages
345
Reaction score
95
First Language
English
Primarily Uses
N/A
I get confused with JS's == and === so I just use === all the time.


I thought you were saying the converter did that :)

If you get stuck with something like that, you can always look for an event command that does it (in this case Get Location Info) and take a look at rpg_objects.js at the Game_Interpreter.prototype section way down at the bottom, and see what it does behind the scenes. In most cases, if you find Game_Interpreter.prototype (to get to the beginning of that class definition) you can then search for the exact text that shows on the event command button.

No, I said your script must have a try/catch in it so wrong scripts don't crash the game.

I'll check out GI too.
 

Sauteed_Onion

Mmm Tasty
Veteran
Joined
Dec 13, 2017
Messages
554
Reaction score
3,668
First Language
English
Primarily Uses
RMMV
So much useful information for this subject.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,169
Reaction score
15,542
First Language
English
Primarily Uses
RMMV
No, I said your script must have a try/catch in it so wrong scripts don't crash the game.

My script runs in Ace. It would have no effect on whether the command would crash in MV or not.
 

Latest Threads

Latest Profile Posts

Have you ever been truly comfortable? This weekend I experienced it for the first time in my 33 years on this planet. Try to get comfy, friends.
Every once in a while I check to see if my planned game titles are taken or trademarked. Still okay. I plan to take my time for the sake of quality, but at the same time it feels like a race against some hidden dev out there who also plans to publish or register the same title.
Who else here likes frogs? I sure do like them squishy beings! :rwink:

froggy.png
Only the goggles are imported ... not the eyes
a lot of my maps and battlebacks are me redrawing base rpg maker mv stuff to match with my own artwork... sometimes it comes out ok lol.

Forum statistics

Threads
117,191
Messages
1,105,338
Members
153,319
Latest member
RhemeChan
Top