Moving through "Dungeons"
|map>[(display: "Map")]
|=
(link-repeat: "Up")[{
(set: _row to $dungeon's ($positionX) )
(if: _row's ($positionY - 1) is not 1)[
(set: $positionY to it - 1)
]
(replace: ?map)[(display: "Map")]
}]
=|=
(link-repeat: "Left")[{
(set: _row to $dungeon's ($positionX) )
(if: _row's ($positionX - 1) is not 1)[
(set: $positionX to it - 1)
]
(replace: ?map)[(display: "Map")]
}]
=|=
(link-repeat: "Right")[{
(set: _row to $dungeon's ($positionX) )
(if: _row's ($positionX + 1) is not 1)[
(set: $positionX to it + 1)
]
(replace: ?map)[(display: "Map")]
}]
=|=
(link-repeat: "Down")[{
(set: _row to $dungeon's ($positionX) )
(if: _row's ($positionY + 1) is not 1)[
(set: $positionY to it + 1)
]
(replace: ?map)[(display: "Map")]
}]
|==|{
<!-- First, we will begin the process of creating an HTML table -->
(set: $dungeonTable to "<table>")
<!-- We need to know where (Y) we are in the array -->
(set: $i to 0)
<!-- For each inner-array, set it to "row" -->
(for: each _row, ...$dungeon) [
<!-- Increase the row count per row -->
(set: $i to it + 1)
<!-- Prepare to add data through creating a table row element -->
(set: $dungeonTable to it + "<tr>")
<!-- Reset the (X) position per row -->
(set: $j to 0)
<!-- For each inner value, set it to "col" -->
(for: each _col, ..._row) [
<!-- Increase the inner-array position counter -->
(set: $j to it + 1)
<!-- Test if positions match counters -->
(if: $i is $positionY and $j is $positionX)[
(set: $dungeonTable to it + "<td>P</td>")
]
(else:) [
<!-- Positions did not match -->
<!-- Test for '0' and place '.' -->
(if: _col is 0) [
(set: $dungeonTable to it + "<td>.</td>")
]
]
<!-- Test for '1' and place '#' -->
(if: _col is 1)[
(set: $dungeonTable to it + "<td>#</td>")
]
]
<!-- Close the table row element -->
(set: $dungeonTable to it + "</tr>")
]
<!-- Close the table element -->
(set: $dungeonTable to it + "</table>")
<!-- Show the updated HTML table -->
$dungeonTable
}{
(set: $dungeon to (array: (a: 1,1,1,1,1),
(a: 1,0,0,0,1),
(a: 1,0,0,0,1),
(a: 1,0,0,0,1),
(a: 1,1,1,1,1) ) )
(set: $positionX to 2)
(set: $positionY to 2)
}