How can I make variables affect what page the player moves on to? (Gamebook)

MythicalFlyingTurtles
24 Mar 2018, 02:45For example, I make a Whack-A-Mole mini game which is affected by the player's choices. (You know, like Smash the Left! or Smash the Right!) When you hit a mole, I can add a script to increase the "points" variable. Now, at the end of the game, if the player has whacked at least 3 moles, I want the player to be given a prize. If they don't, I want them to be directed to a page that tells them they're a loser.
I know I'm supposed to do something with the "if" script, but I have no clue what to do. AMERICA EXPLAIN!

Io
24 Mar 2018, 03:28You don't actually need If at all! You can give the player an Object-type attribute. Call it, say, RoomMove.
So we have Player.RoomMove. And when the player wins or loses, we either do, in psuedocode:
Player.RoomMove=RewardRoom
Or, if we lose:
Player.RoomMove=LoserRoom
And then have:
move object:Player to expression:Player.RoomMove

DarkLizerd
24 Mar 2018, 05:45Wouldn't it be easer to do this???
(if player loose)
move object:Player to expression: LoserRoom
or
(if player win)
move object:Player to expression: RewardRoom
No attribute creation required...

Io
24 Mar 2018, 06:46It would be easier, and probably ideal for the described situation, but the one I included I feel is more flexible; if you decide you want more than a few rooms - such as, you're viewing your stats in an RPG and want to hit back, what room do you go to - you won't want an if-then-else.

MythicalFlyingTurtles
24 Mar 2018, 16:24Okay, your answers were REALLY helpful. THANK YOU!
But... here's another scenario.
What if there was a room filled to the brim with bacon if you hit ALL of the moles?
And there was a room with a box full of bacon if you hit 5 moles,
A room with a bag of bacon if you hit 3 moles,
and a room with a strip of participation award bacon if you hit any less?
How could I use variables to affect the situation?
Alternatively, could I use variables to show only part of a page, or is that impossible?
What I'm saying is, how can I use variables to influence situations that have multiple outcomes (rather than just simply lose or win.)?
Sorry for the confusing reply. Hope you understand this one.

DarkLizerd
24 Mar 2018, 16:44Just expand the options:
For mine:
if hit all moles: goto room:bacon_full
if hit 5 moles: goto room:bacon_box
if hit 3 moles: goto room:bacon_bag
else: goto room:bacon_1
OR, using Io example:
if hit all moles: Player.RoomMove.all
if hit 5 moles: Player.RoomMove.5
if hit 3 moles: Player.RoomMove.3
else: Player.RoomMove.1
move object:Player to expression:Player.RoomMove

MythicalFlyingTurtles
24 Mar 2018, 17:03But.. what if I want to use the "points" variable...?
Is there something I'm not getting? I mean, I now know how to move the player to a specific room, but how do I get the actual result?
Let me re-explain the situation. Here's an example of the actual gameplay.
"You approach the Whack-A-Mole machine. It's rusty and looks like it's been made 30 years ago. You pick up the leather-covered plastic hammer, and the whole machine sparks back to life. Your hear pistons pumping as the machine warms up. Then, the screen that displays your score lights up and the game begins. (I set the "points" to 0.)
Choices:
-Hit the Right!
-Hit the Left!
-Wait!
(the player chooses Hit the Right.)
You whack the right side of the machine. Moles pop up on the left side of the machine, taunting you. You decide to try again.
Choices:
-Hit the Right!
-Hit the Left!
-Wait!
(the player chooses Hit the Left.)
WHAM! You hit a mole with satisfying strength. (Here, I increase Points by 1.)"
And so on. I want the game to keep track of all of my points. Let's say at the end of it all, I have 3 points. How do I make sure I can make the game recognize the amount of points I have, then direct the player to the appropriate room?
Thanks for your time, I'm sorry if I'm getting on your nerves. I'm a n00b at this, okay...

K.V.
24 Mar 2018, 17:41Assuming you're setting the points
attribute on theplayer
object, you could use IF...ELSE IF...ELSE like this:
if (player.points = 3){
// Do whatever happens when the player gets 3 points.
}
else if (player.points = 2){
// Do whatever happens when the player gets 2 points.
}
else if (player.points = 1){
// Do whatever happens when the player gets 1 point.
}
else {
// Do whatever happens when the player gets 0 points.
}
This is case-sensitive, too. You put both points
and Points
in your last post. That's the only reason I bring it up. As far as Quest is concerned, the difference between points
and Points
is equivalent to difference between apples
and oranges
.

MythicalFlyingTurtles
24 Mar 2018, 22:28OML Thank you!
You don't know how happy I am. Posting this on the forum was a good idea. THANK YOU!!!

DarkLizerd
25 Mar 2018, 00:40" points and Points"...
That is one thing I don't like about Quest...
BASIC is not case sensitive...
But, for a room to room, move and explore, I have not found anything easer.
hegemonkhan
25 Mar 2018, 03:18(filler for getting my edited post, updated/posted)
you can take a look at this code too for ideas (it's done for a Text Adventure, but much of the scripting is the same, aside from using 'pages' vs 'objects'), that I did for someone (Separoo) wanting a 'skeeball' game, using these particulars:
http://textadventures.co.uk/forum/quest/topic/yttvba_5o0katld5xx8zua/help-with-tickets-attributes (the thread of/on it)
"Unsure how I'm supposed to apply attributes correctly, where to add them to, etc. Need some help.
My plan is to create a game including an arcade, where the player gains tickets through playing minigames and cash them in for prizes.
I don't want the tickets to be a hold-able object until the player gets his first 50 tickets from a friendly stranger. I Want the player to be able to Look At the tickets they have and see the total amount they have. So I wanna be able to +add and -decrease tickets based on winning tickets and using them to buy stuff, any advice? I'm fairly new to coding so I have no real idea. (Sheparoo)"
// --------------------------
"How do I make the code so that the player recieves tickets for playing the arcade game?
(I plan on making Skee Ball, for example, and no matter what, the player gets tickets depending on performance)
There will be 7 skee balls and therefore 7 attempts to score the highest score possible. I want there to be two verbs, one to throw the ball straight (random chance of 50,40,30,20, or 10 points) and another to throw the ball diagnally (75%chance10points,25%100points).
SO, I'd like there to be 5 different ranges of tickets you can get. For instance:
~ 70-100pts = Exquisitely Lame - 5 tickets
~110-190pts = Bad - 10 tickets
~200-340pts = Good - 25 tickets
~350-540pts = Awesome - 50 tickets
~550+ pts = Unbelievable - 150 tickets
How would I code those outcomes (just one for an example)?
And how can I hide the tickets until the player wins/finds their first tickets? (Sheparoo)"
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="example_game">
<gameid>14940bcf-bfa0-45ad-8c7c-4ec787b5586b</gameid>
<version>1.0</version>
<firstpublished>2017</firstpublished>
<author>HegemonKhan</author>
<category>DEMO</category>
<description>This demo game is 100% publically available to anyone/everyone, feel free to use it or parts of it, and/or modify it or parts of it, and then use it or parts of it. Again, in direct terms: It's 100% publically available for anyone/everyone to modify and use</description>
<attr name="start" type="script">
player.parent = arcade_room
</attr>
</game>
<object name="room">
<inherit name="editor_room" />
</object>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="parent" type="object">room</attr>
</object>
<object name="tickets_object">
<inherit name="editor_object" />
<attr name="parent" type="object">player</attr>
<attr name="take" type="boolean">false</attr>
<attr name="drop" type="boolean">false</attr>
<attr name="tickets" type="int">0</attr>
<attr name="view_tickets" type="script">
ClearScreen
msg ("Tickets: " + tickets_object.tickets)
wait {
ClearScreen
}
</attr>
</object>
<object name="arcade_room">
<inherit name="editor_room" />
<attr name="alias" type="string">Arcade</attr>
</object>
<object name="skee_ball">
<inherit name="editor_object" />
<attr name="parent" type="object">arcade_room</attr>
<attr name="alias" type="string">Skee Ball</attr>
<attr name="attempts" type="int">0</attr>
<attr name="points" type="int">0</attr>
<attr name="view_skee_ball_stats" type="script">
ClearScreen
msg ("Attempts: " + skee_ball.attempts)
msg ("Points: " + skee_ball.points)
wait {
ClearScreen
}
</attr>
<attr name="straight_throw" type="script">
if (skee_ball.attempts = 7) {
do (skee_ball, "points_handling")
} else {
integer_variable = (10 * GetRandomInt (1,5))
msg ("You scored " + integer_variable + " points")
skee_ball.points = skee_ball.points + integer_variable
msg ("Points: " + skee_ball.points)
wait {
ClearScreen
}
skee_ball.attempts = skee_ball.attempts + 1
}
</attr>
<attr name="diagonal_throw" type="script">
if (skee_ball.attempts = 7) {
do (skee_ball, "points_handling")
} else {
if (RandomChance (75)) {
skee_ball.points = skee_ball.points + 10
msg ("You scored 10 points")
} else {
skee_ball.points = skee_ball.points + 100
msg ("You scored 100 points")
}
msg ("Points: " + skee_ball.points)
wait {
ClearScreen
}
skee_ball.attempts = skee_ball.attempts + 1
}
</attr>
<attr name="points_handling" type="script">
<![CDATA[
msg ("Points: " + skee_ball.points)
if (skee_ball.points > 549) {
tickets_object.tickets = tickets_object.tickets + 150
msg ("You got +150 tickets")
} else if (skee_ball.points > 349) {
tickets_object.tickets = tickets_object.tickets + 50
msg ("You got +50 tickets")
} else if (skee_ball.points > 199) {
tickets_object.tickets = tickets_object.tickets + 25
msg ("You got +25 tickets")
} else if (skee_ball.points > 109) {
tickets_object.tickets = tickets_object.tickets + 10
msg ("You got +10 tickets")
} else {
tickets_object.tickets = tickets_object.tickets + 5
msg ("You got +5 tickets")
}
skee_ball.attempts = 0
skee_ball.points = 0
msg ("Tickets: " + tickets_object.tickets)
wait {
ClearScreen
}
]]>
</attr>
</object>
<verb>
<property>straight_throw</property>
<pattern>straight_throw</pattern>
<defaultexpression>You can't throw that straight!</defaultexpression>
</verb>
<verb>
<property>diagonal_throw</property>
<pattern>diagonal_throw</pattern>
<defaultexpression>You can't throw that diagonally!</defaultexpression>
</verb>
<verb>
<property>view_skee_ball_stats</property>
<pattern>view_skee_ball_stats</pattern>
<defaultexpression>You can't view that!</defaultexpression>
</verb>
<verb>
<property>view_tickets</property>
<pattern>view_tickets</pattern>
<defaultexpression>You can't view that!</defaultexpression>
</verb>
</asl>