Letting the player set numerical variables
SquirrelUK
13 May 2010, 14:27Hi,
I've only very recently downloaded Quest and have been playing around with it and struggling somewhat, so patience please!
In the Script Editor there is a very helpful option under the 'Other' menu which allows you to "Enter next command into string value". This means, for example, you can get the player to give you their name, which your game can then use in future interactions.
Is there a way of allowing the player to set numerical variables as well? What would I do, for example, if I was making a nation simulation game and wanted the player to set an income tax rate between 1 and 60%?
Any help much appreciated!
I've only very recently downloaded Quest and have been playing around with it and struggling somewhat, so patience please!
In the Script Editor there is a very helpful option under the 'Other' menu which allows you to "Enter next command into string value". This means, for example, you can get the player to give you their name, which your game can then use in future interactions.
Is there a way of allowing the player to set numerical variables as well? What would I do, for example, if I was making a nation simulation game and wanted the player to set an income tax rate between 1 and 60%?
Any help much appreciated!
SquirrelUK
13 May 2010, 14:41I ought to have clarified that in the above example in income tax, I'd want the game to only accept a number between 1 and 60 (ie. not "77" or "none").
Alex
13 May 2010, 18:59You can put the text into a numeric variable using the string variable contents. You could then use a conditional "if" to check the numeric value was in the correct range.
So the commands might be:
[list]
[*]Print -> Print a message: "Please enter a value between 0 and 60"[/*:m]
[*]Other -> Enter next command into a string variable: "stringvalue"[/*:m]
[*]Variables -> Set a numeric variable: Numeric variable name "value", variable contents "#stringvalue#"[/*:m]
[*]If: Conditions:
[list]
[*]Compare two strings, values or properties: String 1 "%value%", comparison "less than", string 2 "0"
[/*:m][*]OR: Compare two strings, values or properties: String 1 "%value%", comparison "greater than", string 2 "60"
[/*:m][*]Then:
[list]
[*]Print a message: "I said between 0 and 60!"[/*:m][/list:u]
[/*:m][*]Else: Whatever you want ...[/*:m][/list:u][/*:m][/list:u]
The final script might look like this within QDK:
or here's the ASL if you want to copy and paste via Notepad:
So the commands might be:
[list]
[*]Print -> Print a message: "Please enter a value between 0 and 60"[/*:m]
[*]Other -> Enter next command into a string variable: "stringvalue"[/*:m]
[*]Variables -> Set a numeric variable: Numeric variable name "value", variable contents "#stringvalue#"[/*:m]
[*]If: Conditions:
[list]
[*]Compare two strings, values or properties: String 1 "%value%", comparison "less than", string 2 "0"
[/*:m][*]OR: Compare two strings, values or properties: String 1 "%value%", comparison "greater than", string 2 "60"
[/*:m][*]Then:
[list]
[*]Print a message: "I said between 0 and 60!"[/*:m][/list:u]
[/*:m][*]Else: Whatever you want ...[/*:m][/list:u][/*:m][/list:u]
The final script might look like this within QDK:
Print "Please enter a value between 0 and 60:"
Put what the player types next into the "stringvalue" string variable
Change the contents of numeric variable "value" to "#stringvalue#"
If "%value%" is less than "0" or "%value%" is greater than "60" Then Print "I said between 0 and 60!"
or here's the ASL if you want to copy and paste via Notepad:
msg <Please enter a value between 0 and 60:>
enter <stringvalue>
set numeric <value; #stringvalue#>
if ( %value% < 0 ) or ( %value% > 60 ) then msg <I said between 0 and 60!>
SquirrelUK
14 May 2010, 00:39Thanks massively, I've now sussed it!