$game_player.passable?(x, y, d) why wont it work?

Hey guys,

Basically im trying to create a conditional branch where the game triggers a specific action when the player is trying to move to a location they cant enter.
Ive tried:
$game_player.passable?(1, 0, 2)
$game_map.passable?($game_player.x, $game_player.y, 2)
$gameMap.isPassable($game_player.x, $game_player.y, 2)
And some other combinations. But i keep getting an error. What am i doing wrong? I think im using it exactly how the page at describes it.

edit: im not sure how i can write the link down normally without showing the entire page. If someone could tell me that too, id appreciate it.
There is nothing such as $game_player. There is only $gamePlayer.
There is nothing such as $game_player. There is only $gamePlayer.
thats strange because that script list says its called "game_player.". Also i tried "gamePlayer." and it still doesnt work 🙁
The best thing you can do is explore the console by f8. Type in for example $gamePlayer. and it will suggest all sorts of things you can find out.
It is $gamePlayer, not gamePlayer. And MV functions don't have ? on the end. Generally, something that was condition? in Ace becomes isCondition() in MV.

So try $gamePlayer.isPassable(x, y, d)
OK this is exactly my event:
◆If:Script:$gamePlayer.isPassable(1, 0, 4)
◆Play SE:Bell3 (90, 100, 0)
◆
:End
And i still get an error.
Ive also looked through the f8 thingy and an ''.isPassable'' did come up. Also the script page thats mentioned above mentions a ''$gamePlayer.isPassable''. What am i doing wrong? Im really looking for a better way for the game to recognize when im standing still or when i cant move because ''$gamePlayer.isMoving()'' isnt really working out for me very well. Any ideas what i could be doing wrong here?
If there was an error, you need to tell us what it said. Don't make us guess.

Better yet, give us a screenshot of the "f8 thingy" so we can see what you're seeing.


Actually, after re-reading your initial post, I think you're going about things the hard way.

Just create an event on that spot, set the priority to Same as Characters, and the trigger to Player Touch. When the player tries to walk on that spot, they won't be able to, and whatever you have in the event commands will run.

If, later, the player should be able to enter that area, just create a second page on the event, leave the priority to Below Characters, and use a switch as the condition - at whatever point access to this area is to be granted, turn on that switch.

So before the switch is on, the player will be blocked, potentially with some sort of message or something. When they do whatever they need to do to gain access, the switch will be turned on and the second page will be made active, and the player will be able to go over the event.
@Shaz Im sorry, im kinda new to using f8. Actually i just heard about it for the first time yesterday. So forgive me for not being clear enough.

this is a screenshot of the error. There is an option to expand it even more, but that just keeps going for i dont know how long.

Also, placing events around all the things that need to trigger this - Is not really an option since im looking for a way to improve my collision detection for my personal dashing system, and since dashing is a big part of my game; i cant really sow events on every single map on all the walls, and other inpassable things.
The problem is that the function you're trying to call does not exist in the Game_Player class.

isPassable(x, y, d) is a function of Game_Map. Here is an example of how to properly use this function:

Code:
var x = $gamePlayer.x;
var y = $gamePlayer.y;
var d = $gamePlayer.direction();
return $gameMap.isPassable(x, y, d);

Please note that is an example and will not be able to be written this way from the conditional branch event command. To use inside the conditional branch, write the following:

Code:
$gameMap.isPassable($gamePlayer.x, $gamePlayer.y, $gamePlayer.direction());

The beautiful thing about scripting is that there are always a number of ways to reach your end result; the excitement comes from the journey.

Alternatively, you could most certainly use the canPass(x, y, d) of the $gamePlayer class, which was inherited by Game_CharacterBase; the parent class we discussed in the other topic. This is just another way to reach the same result; that would look something like this:

Code:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y + 1, $gamePlayer.direction());
@dbchest Wow thanks alot! It actually worked like that. I guess i was confused because apparently in rpg maker vx you also had game_player.passable? or something like that, but i think they changed that to the:
''$gamePlayer.canPass'' that you also mentioned, and which was exactly what needed apparently... Because the "isPassable" one doesnt seem to count events and only the tileset - While canPass does count events.

Im currently still messing around with canPass because
Code:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y + 1, $gamePlayer.direction());
seemed to act extremely weird. But so far
Code:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y + 1) && $gamePlayer.direction() === 2
seems do exactly what i need it to.

Also you seem to really know your way around ''f8 thingy''. Perhaps you would know if there is a script to check whether the player is attempting to move.

Ideally id like to create something like this
Code:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y + 1) && $gamePlayer.direction() === 2 && "player is trying to move down"

I did stumble upon this: ''$gamePlayer.moveByInput()'', but i have no idea how to work with it
Haha, you weren't supposed to copy the $gamePlayer.canPass function verbatim; it was an example of how to use it.

When using that function, you are meant to specify the x and the y coordinates of the tile you want to check, as well as direction you are expected to enter it from.

You should not use the snippet I gave you because it was designed to check only the tile directly beneath the player for passability.

Here is an example:
Code:
$gamePlayer.canPass(the x coordinate of the tile in question, the y coordinate of the tile in question, the direction you will enter from);
just checked ... the function is $gamePlayer.isMapPassable(x, y, d)
@dbchest haha ye i wasnt sure.

@Shaz after i tested it, i think that one works the same way as .isPassable, as in, that it only covers the tileset.

$gamePlayer.canPass also checks if events are in the way. But its still useful to have for later use so thanks!

Anyway since you guys helped me with the issue thats literally in the title, ill just make a new topic with my last issue: About finding a script that checks if the player is getting input to move to any given direction.

So thanks again guys!
Yeah, I think the one I was really after was canPass, as it not only checks the map for passability, but also looks for other events to see if there are any blocking the way.

$gamePlayer.isMapPassable also takes into account that the player might be in a vehicle, and so uses the vehicle's passage settings rather than assuming you're on foot.
@dbchest
Anyway since you guys helped me with the issue thats literally in the title, ill just make a new topic with my last issue: About finding a script that checks if the player is getting input to move to any given direction.

Well, if you use Input.isPressed('down') it'll check whether the player is pressing the 'down' key, so you'll know if the player is trying to move down.

Something like:

Code:
$gamePlayer.canPass($gamePlayer.x, $gamePlayer.y + 1) && $gamePlayer.direction() === 2 && Input.isPressed('down')

Similarly, you can check for 'up'/'left'/'right'.
aye, but i was not looking for the pressed down check, but the actual attempting to move check. But in another topic I was told such a script call does not exist. 🙁
In a situation where the player would be moved by a movement route; Input.isPressed('down') wouldnt be checked, while the player would still move down

Original thread: https://forums.rpgmakerweb.com/threads/game_player-passable-x-y-d-why-wont-it-work.81743/