Hello, I'm interested in making plugins, however, I'm working with events and script calls by now.
I'm coding a script that enables or disables a Switch if the two nearest spaces behind the player are passable or not, but when I check if it works, the game keeps throwing me "Unexpected" SyntaxErrors.
This is my first time doing something in Javascript. I have programmed in C# and Java, so I think I know what I'm doing with this script.
I will appreciate it if anyone points me the issue in these.
As a script call (where 3 is the Switch I want to manage):
As a script call inside a condition
Thanks for your time and sorry for my english if something is wrong.
I'm coding a script that enables or disables a Switch if the two nearest spaces behind the player are passable or not, but when I check if it works, the game keeps throwing me "Unexpected" SyntaxErrors.
This is my first time doing something in Javascript. I have programmed in C# and Java, so I think I know what I'm doing with this script.
I will appreciate it if anyone points me the issue in these.
As a script call (where 3 is the Switch I want to manage):
var AllowRegroup = false;
var Direction = $gamePlayer.direction();
var x = $gamePlayer.x;
var y = $gamePlayer.y;
switch (Direction)
{
default: break;
case 2: AllowRegroup = $game_player.passable?(x,y-1,2) && $game_player.passable?(x,y-2,2); break;
case 8: AllowRegroup = $game_player.passable?(x,y+1,8) && $game_player.passable?(x,y+2,8); break;
case 4: AllowRegroup = $game_player.passable?(x+1,y,4) && $game_player.passable?(x+2,y,4); break;
case 6: AllowRegroup = $game_player.passable?(x-1,y,6) && $game_player.passable?(x-2,y,6); break;
}
$gameSwitches.setValue(3, AllowRegroup);
var Direction = $gamePlayer.direction();
var x = $gamePlayer.x;
var y = $gamePlayer.y;
switch (Direction)
{
default: break;
case 2: AllowRegroup = $game_player.passable?(x,y-1,2) && $game_player.passable?(x,y-2,2); break;
case 8: AllowRegroup = $game_player.passable?(x,y+1,8) && $game_player.passable?(x,y+2,8); break;
case 4: AllowRegroup = $game_player.passable?(x+1,y,4) && $game_player.passable?(x+2,y,4); break;
case 6: AllowRegroup = $game_player.passable?(x-1,y,6) && $game_player.passable?(x-2,y,6); break;
}
$gameSwitches.setValue(3, AllowRegroup);
As a script call inside a condition
$gamePlayer.direction() == 2 && $game_player.passable?($gamePlayer.x,$gamePlayer.y-1,2) && $game_player.passable?($gamePlayer.x,$gamePlayer.y-2,2) ||
$gamePlayer.direction() == 8 && $game_player.passable?($gamePlayer.x,$gamePlayer.y+1,8) && $game_player.passable?($gamePlayer.x,$gamePlayer.y+2,8) ||
$gamePlayer.direction() == 4 && $game_player.passable?($gamePlayer.x+1,$gamePlayer.y,4) && $game_player.passable?($gamePlayer.x+2,$gamePlayer.y,4) ||
$gamePlayer.direction() == 6 && $game_player.passable?($gamePlayer.x-1,$gamePlayer.y,6) && $game_player.passable?($gamePlayer.x-2,$gamePlayer.y,6)
$gamePlayer.direction() == 8 && $game_player.passable?($gamePlayer.x,$gamePlayer.y+1,8) && $game_player.passable?($gamePlayer.x,$gamePlayer.y+2,8) ||
$gamePlayer.direction() == 4 && $game_player.passable?($gamePlayer.x+1,$gamePlayer.y,4) && $game_player.passable?($gamePlayer.x+2,$gamePlayer.y,4) ||
$gamePlayer.direction() == 6 && $game_player.passable?($gamePlayer.x-1,$gamePlayer.y,6) && $game_player.passable?($gamePlayer.x-2,$gamePlayer.y,6)
Thanks for your time and sorry for my english if something is wrong.