<showscore />
<command name="LookAroundCommand">
<pattern>look around</pattern>
<script>
msg("Some text describing the room.")
if (game.state = 0) {
game.state = 1
} else {
game.state = 0
DecreaseScore(1)
}
</script>
</command>
<command name="GoThroughDoorCommand">
<pattern>go through door</pattern>
<script>
game.pov.parent = NextRoom
if (game.state = 1) {
IncreaseScore(1)
msg("Well done! Have a cookie!")
} else {
game.state = 0
DecreaseScore(1)
}
</script>
</command>
if (game.pov.parent = look around room) {
if (game.state = 1) {
IncreaseScore (1)
msg ("Well done! Have a cookie!")
}
else {
game.state = 0
DecreaseScore (1)
}
if (ListContains(ScopeVisible(), lookaroundroomdoorobject)) {
MoveObject (player, test look around room)
}
else {
if (RandomChance(1)) {
MoveObject (player, test look around room)
}
else {
msg ("You bumped into something.")
}
}
}
else if (game.pov.parent = test look around room) {
if (ListContains(ScopeVisible(), testlookaroundroomdoorobject)) {
MoveObject (player, pull room)
}
else {
if (RandomChance(1)) {
MoveObject (player, pull room)
}
else {
msg ("You bumped into something.")
}
}
}
if (game.pov.parent = look around room) {
firsttime {
MakeExitVisible (lookaroundroomdoor)
MakeObjectVisible (lookaroundroomdoorobject)
msg ("You see a door.")
if (game.state = 0) {
game.state = 1
}
else {
game.state = 0
DecreaseScore (1)
}
}
otherwise {
firsttime {
MakeObjectVisible (piece of paper)
msg ("You notice a piece of paper.")
}
otherwise {
}
}
}
else if (game.pov.parent = pull room) {
firsttime {
msg ("You see the lever.")
}
}
else if (game.pov.parent = test look around room) {
MakeExitVisible (testlookaroundroomdoor)
MakeObjectVisible (testlookaroundroomdoorobject)
msg ("You see a door.")
}
else {
msg ("")
}
Almost clear... what happens if you look and then look again and then look again? Is the state 3 at that point?
I think the state thing might need to be local as well. If the player makes a misstep early on (e.g. looks twice before going out the door), then they would never be able to "catch up" and begin scoring again, as their initial double take would put them forever out of sync. If that makes sense... (I'm speculating on what happens after "go through door".)
If this is what you want, then we need to be clear of one thing: the player should not end up in a state where they are no longer able to take the right step. For example, if the next expected step is "look around" and they then type "go through door" such that they are no longer able to look around, then the scoring gets stuck - they end up not being able to advance because they are no long able to perform the next expected step. There need to be constraints such that they eventually will continue along the desired path.. So as long as that is understood (and what I've described is what you want), then I can whip something up.
Or is score computed per room? (If I make the right steps in the current room, I get a +1 for this room, else I get -1 when I leave.) And then your score would be the sum of the room scores?
Use cases... Assuming an ideal sequence of A B C D, what would your score be for the following:
1) A B C D
2) A A B C D
3) B A B C D
4) A B D C D
5) A B D C C D
6)A A A B B B C C C D
<enter type="script">
this.state = 0
this.score = 1
</enter>
<onexit type="script">
IncreaseScore(this.score)
</onexit>
<command name="LookAroundCommand">
<pattern>look around</pattern>
<script>
room = pov.parent
msg("Some text describing the room.")
if (room.state = 0) {
// Ok so far. Go to next state.
game.state = 1
} else {
// Fail!
room.score = -1
// To prevent a good message on the look/look case.
room.state = -1
}
</script>
</command>
<command name="GoThroughDoorCommand">
<pattern>go through door</pattern>
<script>
room = pov.parent
if (room.state = 1) {
// They made it!
msg("Well done! Have a cookie!")
} else {
// Fail!
room.score = -1
}
// Go to next room. This will update the score on exit.
game.pov.parent = NextRoom
</script>
</command>
1) Code to reset the state and room score on entry to the room
2) Code to apply the room score to the overall score when the player leaves the room
if (room.state = 0) {
// Ok so far. Go to next state.
game.state = 1
} else {
// Fail!
room.score = -1
// To prevent a good message on the look/look case.
room.state = -1
<onexit type="script">
IncreaseScore(this.score)
</onexit>
4) *Per-room* commands
So should I create state and score variables for every room to do that? Or is it done once I did it with EDITevery EDIT ENDroom? (I myself believe not, but I wouldn't be surprised if that was the case) Or are they already in the default room? Is it necessary to use "this.score" and "this.state" or is that just a name and I could rename it whatever I feel like?
is problematic, if I understood it correctly, because it will only increase the score by 1 if I wouldn't add any commands to the already existing ones.
can that be done in editor mode?
if (ListContains(ScopeVisible(), testlookaroundroomdoorobject)) {
MoveObject (player, pull room)
}
else {
if (RandomChance(1)) {
MoveObject (player, pull room)
}
else {
msg ("You bumped into something.")
}
}
if (testlookaroundroom.state = 1) {
testlookaroundroom.score = 1
}
else {
testlookaroundroom.score = -1
}