Pages: 1
I'm trying to modify this code from the RMMV Script Calls page: "$gameMap.isPassable(x,y,direction)"

The modification that I'm trying to make is to have a parallel process NPC check its "up" directional passability before it moves. I'm using the code in a conditional branch. It looks like this, but doesn't work.

$gameMap.events(this._eventId).isPassable($gameMap.events(this._eventId).x, $gameMap.events(this._eventId).y-1, $gameMap.events(this._eventId).directionUp)

I'm getting a TypeError stating that "undefined is not a function." I know I'm probably going about it laughably wrong, but any help would be quite welcome :)
Guardian of the Description Thread
Does VX use the keyword "this"? I thought it was "self". I might be going off VX Ace knowledge, here. Now, if it's MV, (I largely suspect this) then the keyword might be "this".

Anyway, my gut instinct tells me that the context of "this" (or "self", or whatever) is actually an object of Game_Interpreter. The only way I can think of to do what you want is to pass the event id into a function that might look like...

event = $gameMap.events[event_id]
if event.isPassible(event.x, event.y, 2) == true
return true
return false

...this? I could be wrong about the constant used to replace direction, as I'm referring to VX Ace's code on this.
Thanks Marrend. My bad- I thought I clicked RMMV, not VX.

I'm going to try and use your fix but replace it with MV terms.

Sadly, this isn't working either. I've tried simplifying my code, but I'm getting an error stating "unexpected identifier" :

event = $gameMap.events[10]
if event == 10 {
$gameMessage.add ("check")}
Guardian of the Description Thread
Let me think out loud for a second. The way it reads that code is to set an "event" variable to be equal to $gameMap.events[10]. Then, if the value of "event" is 10, put the text "check" into the $gameMessage buffer.

So, I'm not sure about the "unexpected identifier" part, or where it's coming from. Unless the reference is more like "$gameMap._events[10]"? However, I do know that the conditional branch, as written, will never be true. The value of "event" should return an instance of Game_Event (or whatever), and not a property thereof that would return a numeric value. Such as the direction in which the event is facing. I could be wrong, but, I think the conditional branch you wanted to write was something to the effect of "if event.direction == 10", or maybe "if event._direction == 10", depending on how the property is actually defined in MV.
If I understood the problem correctly, I think this is what you're looking for...

$gameMap.isPassable($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y-1, $gameMap.directionUp)

Main problem you were having was the "isPassable" function is on $gameMap, not on an event. So is directionUp
Got it. Thank you both. This fix helps me understand the script calls better overall :)

Pages: 1