- Joined
- Mar 23, 2016
- Messages
- 159
- Reaction score
- 12
- First Language
- English
- Primarily Uses
So, basically this is a simple movement checker plugin. What it does is it adds a script call you can use to check if a certain block relative to the player/events position is passable or not. Here is an example of the commands it should add. Note that I'll be referring to the player/event as the "instance":
chkpass(x,y,direction)
There should also be an alternative version of the script call which reverses the X and Y values if you wish to go that way.
chkpassi(y,x,direction)
Here's how it works:
The direction determines if it's direction oriented or not. It can be true or false. If it's true, it will actually calculate what co-ordinates to check instead of calculating the ones given based on what direction the instance is facing. You can also put 'left','right','up','down' instead, and it will calculate for that direction. Putting false is equivalent to putting 'up'.
Here's how it calculates the co-ordinates to check. (Sorry if there's flash backs to geometry class, I know some people hate math, but it's essential in programming, and personally I like math, also, sorry if I made errors in my calculation, please correct me if I'm wrong.
)
Up - (x,y)
Down - (-x,-y)
Left - (y,-x)
Right - (-y,x)
Now, here's some example usage:
Let's say the player is facing right, using this script call will check if the space in front of him is passable and return the correct result.
$gamePlayer.chkpass(0,1,true);
Let's say an event is facing in any direction and is running the code, but you want the plugin to assume the event is facing down, this script call will check if the tile below the event is passable, and set switch 1 to the correct result.
chkpass(x,y,direction)
There should also be an alternative version of the script call which reverses the X and Y values if you wish to go that way.
chkpassi(y,x,direction)
Here's how it works:
The direction determines if it's direction oriented or not. It can be true or false. If it's true, it will actually calculate what co-ordinates to check instead of calculating the ones given based on what direction the instance is facing. You can also put 'left','right','up','down' instead, and it will calculate for that direction. Putting false is equivalent to putting 'up'.
Here's how it calculates the co-ordinates to check. (Sorry if there's flash backs to geometry class, I know some people hate math, but it's essential in programming, and personally I like math, also, sorry if I made errors in my calculation, please correct me if I'm wrong.
Up - (x,y)
Down - (-x,-y)
Left - (y,-x)
Right - (-y,x)
Now, here's some example usage:
Let's say the player is facing right, using this script call will check if the space in front of him is passable and return the correct result.
$gamePlayer.chkpass(0,1,true);
Let's say an event is facing in any direction and is running the code, but you want the plugin to assume the event is facing down, this script call will check if the tile below the event is passable, and set switch 1 to the correct result.
Code:
$gameSwitches.setValue(1, $gameMap.event(this.eventId()).chkpass(0,1,'down'));
