Zero-based.
ICJ has the same solution I would have given, more or less. Track a status as long as the player continues on the right course. You might be able to simplify it, though, but just using one variable. Here's kind of how it would work.
X = 0 !Use to indicate player hasn't started the pattern.
X = 1 !Use to indicate player has entered the first room.
X = 2 !If X was 1 and player enters the second room...
!Otherwise if X is already 2, leave it alone.
!Otherwise set X to 0.
X = 3 !If X was 2 and player enters the third room....
!Otherwise if X is already 3, leave it alone.
!Otherwise set X to 0.
...etc
If you also created an array of all the room objects, it would be even easier. You could simply check to see if the player is in a different room than before, and if so, increment X. If room[x] is the player's current room at that point, they're on the right path. Otherwise, they took a wrong turn, so reset and start over.
You'd also have to keep track of when the player completed the pattern, otherwise you'll be accessing out of bound indices for roomlist.
You'd probably also want to make sure the player hasn't already completed the puzzle -- or else, check to make sure it's okay for the player to *start* the puzzle.
Let's see if I can whip up some code:
Code: Select all
array roomlist[4]
global goodroom=0
global maxrooms = 6
global CanDoPuzzle = true
roomlist[0] = First_room, Second_room, \
Third_room, Fourth_room, Fifth_room, Sixth_room
!Then, in your you{} object for actor room-movement,
!or maybe as a routine you call from each_turn in all
!applicable rooms, you'd do something like this:
if (roomlist[goodroom] != location) and (CanDoPuzzle) {
goodroom++
if (roomlist[goodroom] = location) {
if (goodroom = 1) {
!Maybe announce that the puzzle is starting.
} else {
if (goodroom = maxrooms) {
!Congrats! You've solved it!
!Do whatever needs done, here.
CanDoPuzzle = false
}
}
} else {
goodroom = 0
!The user took a wrong turn! Start over!!!
}
}
Zero-based.
ICJ has the same solution I would have given, more or less. Track a status as long as the player continues on the right course. You might be able to simplify it, though, but just using one variable. Here's kind of how it would work.
X = 0 !Use to indicate player hasn't started the pattern.
X = 1 !Use to indicate player has entered the first room.
X = 2 !If X was 1 and player enters the second room...
!Otherwise if X is already 2, leave it alone.
!Otherwise set X to 0.
X = 3 !If X was 2 and player enters the third room....
!Otherwise if X is already 3, leave it alone.
!Otherwise set X to 0.
...etc
If you also created an array of all the room objects, it would be even easier. You could simply check to see if the player is in a different room than before, and if so, increment X. If room[x] is the player's current room at that point, they're on the right path. Otherwise, they took a wrong turn, so reset and start over.
You'd also have to keep track of when the player completed the pattern, otherwise you'll be accessing out of bound indices for roomlist.
You'd probably also want to make sure the player hasn't already completed the puzzle -- or else, check to make sure it's okay for the player to *start* the puzzle.
Let's see if I can whip up some code:
[code]
array roomlist[4]
global goodroom=0
global maxrooms = 6
global CanDoPuzzle = true
roomlist[0] = First_room, Second_room, \
Third_room, Fourth_room, Fifth_room, Sixth_room
!Then, in your you{} object for actor room-movement,
!or maybe as a routine you call from each_turn in all
!applicable rooms, you'd do something like this:
if (roomlist[goodroom] != location) and (CanDoPuzzle) {
goodroom++
if (roomlist[goodroom] = location) {
if (goodroom = 1) {
!Maybe announce that the puzzle is starting.
} else {
if (goodroom = maxrooms) {
!Congrats! You've solved it!
!Do whatever needs done, here.
CanDoPuzzle = false
}
}
} else {
goodroom = 0
!The user took a wrong turn! Start over!!!
}
}
[/code]