Initializing and incrementing a numeric variable

it_master
I'm trying to create a system that will execute a certain command for 10 times, each for everytime the player tries to speak or use that object, and after the 10 times, it will execute afterwards an alternative command in which it will execute no matter how many times the user tries to speak to it again.

The problem here is how am I gonna initialize a numeric variable here and how to increment that variable.

Here's the code for the portion of the "speak to" command I'm trying to create:


drinks = NewStringList()
list add (drinks, "milk")
list add (drinks, "coffee")
list add (drinks, "juice")
list add (drinks, "water")
if (increment<10) {
firsttime {
msg ("<br/>Hello, I'm the decision making robot.<br/><br/>My function is to act as an ordinary human but I will respond in different ways to different answers that you make. <br/><br/>Some of those responses that you'll make, will be stored in my memory drive, so be very careful in making your decisions.<br/><br/>I will only give you a limited time and after at least 10 tries, I'll shut down completely.<br/><br/>Choose wisely and have fun testing!")
}
otherwise {
msg ("<br/>Hello, I'm the decision making robot.")
}
msg ("So, what kind of drink would I interest you:")
ShowMenu ("", drinks, false) {
switch (result) {
case ("milk") {
msg ("test 1 complete")
}
case ("coffee") {
msg ("test 2 complete")
}
case ("juice") {
msg ("test 3 complete")
}
case ("water") {
msg ("test 4 complete")
}
}
}
}
else {
msg ("<br/>You tried speaking to it,<br/><br/>But the Robot gave no response.")
}


This code is part of the text adventure game I'm currently working on as a debug room to help me learn the ropes here.

I also have a great background in programming.

Answers are greatly appreciated, especially relevant ones.

Thanks in advance.

HegemonKhan
these links should help you understand quest's coding struction/syntax:

viewtopic.php?f=18&t=5559 (Attribute Usage and 'if' Script guide)
http://docs.textadventures.co.uk/quest/ (quest's documentation)

ask if you need any help or explanation

The Pixie
Are you working off-line? I will assume so (you do not have an Attributes tab online).

Go to the Attributes tab of your object (or whatever it is that has the attributre with this script), and create a new attribute, "increment". Set it to be an intger, value 0. Then modify your code (I have added the sixth line, and changed the next one; all the rest looks fine):
drinks = NewStringList()
list add (drinks, "milk")
list add (drinks, "coffee")
list add (drinks, "juice")
list add (drinks, "water")
this.increment = this.increment + 1
if (this.increment<10) {
firsttime {

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums