Pulling with passable check

Hi guys,

I am trying to make a rock pullable if player can move backward direction

Code:
if ($gamePlayer.direction() == 2 ) {
$gameVariables.setValue(6, 8)
} else if ($gamePlayer.direction() == 4 ) {
$gameVariables.setValue(6, 6)
} else if ($gamePlayer.direction() == 6 ) {
$gameVariables.setValue(6, 4)
} else {
$gameVariables.setValue(6, 2)
}

dx = ($gamePlayer.x)
dy = ($gamePlayer.y)
db = ($gameVariables.value(6))

if ($game_player.passable?(dx, dy, db) ) {
$gameSwitches.setValue(11, true)
} else {
$gameSwitches.setValue(11, false)
}

as you see at first condition i am determining the direction of backwards and at second i am trying to make a switch on if it is passable after this i will move the player and boulder backwards if the switch is on.

in first if clause it's working like a charm but in second if clause i am having a "Syntax Error {" error.

What is the difference between these two? and why i am having this error, as i think these two clause are identical

Thanks for your help in advance.
"Syntax Error" is the computer's way of telling you that you mistyped something. It means code that should not exist at all because it is nonsense-code to the computer.

1) - it would help to get a screenshot of the error message, preferably from the console with the full trace of the error, to see what is the exact error and where.

2) - why are you using scripts here? Everything you do has an event code equivalent (although I have to admit that the one for passability is more difficult to use than the script), and in event commands you can't mistype.
There is no $gamePlayer.passable? function in MV. It's $gamePlayer.canPass.

However, you don't need to go to all that trouble. As Andar said, you don't need scripts at all. But if you really, really do want to use scripts, you can do it in a single line.

$gameVariables.setValue(11, $gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 10 - $gamePlayer.direction()))
Thank you guys for your reply, i did it with Shaz's code

@Andar i tried with event codes but couldn't find a way to check if passable or not so i changed it to script

@Shaz thank you, i changed the gameVariables with gameSwitches and it worked.

i got that function from maybe that document needs an update.

Working Code:

Code:
:When pull
Script: $gameSwitches.setValue(11, $gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 10 - $gamePlayer.direction()))
    If: passable is ON
        Set movement route    : Player(wait)
                            : 1 Step backward
        Set movement route    : This event(skip, wait)
                            : Through ON
                            : 1 Step Backward
                            : Through OFF
    Else
        Text: None, Window, Bottom
        :It's not possible
    End
Yes, sorry about that. I got mixed up. Glad you knew what I meant 🙂
i tried with event codes but couldn't find a way to check if passable or not
I did mention that the event way is a lot more difficult than the script ;-)

If you're interested: get location info allows you to draw map data from any given map position.
But it doesn't have a direct passability check, so you would have to go around the engine to get that data calculated from the data you can get. And that is so difficult that even I usually suggest the script function unless there is very specific need to do it the event way.
2) - why are you using scripts here? Everything you do has an event code equivalent (although I have to admit that the one for passability is more difficult to use than the script), and in event commands you can't mistype.

How would you make an event graphic that is "pullable" using event commands?
How would you make an event graphic that is "pullable" using event commands?
that is the easiest compared to checking passability - I think there are even tutorials about this on this site.
basically the same as pushing an event - just two set move routes in the other direction instead of one.
It is a bit tricky if you never have seen it however...

the first step is to determine if the player wants to push or pull, that can be done in different ways by checking different key presses, simply asking (show choice) or a few other options.

then you need to determine the direction based on player facing and the results from the first step - because you can't use the "move away from player" order, you have to give a directional order.

Then the first step is a set move route targeted on the player to move in the direction, but without waiting or skipping.
Directly followed with a set move route to the event to move in the same direction as soon as the player has moved, and that one might have the wait checked if you want or need to do something after both events moved.

Original thread: https://forums.rpgmakerweb.com/threads/pulling-with-passable-check.121479/