Hello!
I used .push() for a card drawing skill system before.
But when I try to do something similar and store movement commands (numbers) inside an array then I get ".push()" is not a function.
What did I do wrong? I just do not see it:
Note that it is intended that I mirror the direction numbers. Because "backfinding" is all the commands from "pathfinding" backwards.
Thanks in advance! 🙂
Edit:
Nevermind, I found the issue. I was defining $backfinding wrong.
What I did:
What I should have done:
I used .push() for a card drawing skill system before.
But when I try to do something similar and store movement commands (numbers) inside an array then I get ".push()" is not a function.
What did I do wrong? I just do not see it:
Code:
if ($gameMap.regionId($gameMap.event($turn_number).x-1,$gameMap.event($turn_number).y) == 8) {
$look_dir[$turn_number] = 17;
$backfinding[$turn_number].push(18);
console.log("look_dir: left");
}
if ($gameMap.regionId($gameMap.event($turn_number).x+1,$gameMap.event($turn_number).y) == 10) {
$look_dir[$turn_number] = 18;
$backfinding[$turn_number].push(17);
console.log("look_dir: right");
}
if ($gameMap.regionId($gameMap.event($turn_number).x,$gameMap.event($turn_number).y-1) == 1) {
$look_dir[$turn_number] = 19;
$backfinding[$turn_number].push(16);
console.log("look_dir: up");
}
if ($gameMap.regionId($gameMap.event($turn_number).x,$gameMap.event($turn_number).y+1) == 17) {
$look_dir[$turn_number] = 16;
$backfinding[$turn_number].push(19);
console.log("look_dir: down");
}
Note that it is intended that I mirror the direction numbers. Because "backfinding" is all the commands from "pathfinding" backwards.
Thanks in advance! 🙂
Edit:
Nevermind, I found the issue. I was defining $backfinding wrong.
What I did:
Code:
$backfinding = [0, 0, 0, 0, 0]
What I should have done:
Code:
for (var i = 4; i > 0; i--) {
$backfinding[i] = []
}