RPG Maker Forums

Hey guys,

It seems that labels arent an actual thing in javascript, so i tried to replicate it with a loop:

Code:
    for (var i = 0; i = 1;) {
        if (G_dirpressed.search(/[1]/)>=0 && $gameMap.regionId($gamePlayer.x-1, $gamePlayer.y+1) !== G_cantpass) {if ($gamePlayer.canPassDiagonally($gamePlayer.x, $gamePlayer.y, 4, 2)) {dire = "4, 2"; break;}};
        if (G_dirpressed.search(/[3]/)>=0 && $gameMap.regionId($gamePlayer.x+1, $gamePlayer.y+1) !== G_cantpass) {if ($gamePlayer.canPassDiagonally($gamePlayer.x, $gamePlayer.y, 6, 2)) {dire = "6, 2"; break;}};
        if (G_dirpressed.search(/[7]/)>=0 && $gameMap.regionId($gamePlayer.x-1, $gamePlayer.y-1) !== G_cantpass) {if ($gamePlayer.canPassDiagonally($gamePlayer.x, $gamePlayer.y, 4, 8)) {dire = "4, 8"; break;}};
        if (G_dirpressed.search(/[9]/)>=0 && $gameMap.regionId($gamePlayer.x+1, $gamePlayer.y-1) !== G_cantpass) {if ($gamePlayer.canPassDiagonally($gamePlayer.x, $gamePlayer.y, 6, 8)) {dire = "6, 8"; break;}};
        if (G_dirpressed.search(/[2]/)>=0 && $gameMap.regionId($gamePlayer.x, $gamePlayer.y+1) !== G_cantpass) {if ($gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 2)) {dire = "2"; break;}};
        if (G_dirpressed.search(/[4]/)>=0 && $gameMap.regionId($gamePlayer.x-1, $gamePlayer.y) !== G_cantpass) {if ($gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 4)) {dire = "4"; break;}};
        if (G_dirpressed.search(/[6]/)>=0 && $gameMap.regionId($gamePlayer.x+1, $gamePlayer.y) !== G_cantpass) {if ($gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 6)) {dire = "6"; break;}};
        if (G_dirpressed.search(/[8]/)>=0 && $gameMap.regionId($gamePlayer.x, $gamePlayer.y-1) !== G_cantpass) {if ($gamePlayer.canPass($gamePlayer.x, $gamePlayer.y, 8)) {dire = "8"; break;}};
        if (G_dirpressed.length === 1) {$gamePlayer.setDirection(Number(G_dirpressed))}
        break;
    };
dont pay attention to the actual contents of the if statement - The bottomline is: the game checks if the first if statement passes, if it does it executes the code inside and it breaks the loop because it doesnt have to check further, if it doesnt it goes to the next if statement in line, and repeats the process, until it reaches the bottom and it breaks the loop.

My question is: is this even a good way to actually deal with this problem? and are there alternative more efficient methods?

Thanks in advance!

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top