Commands getting confused
SquirrelUK
14 May 2010, 01:00Hi,
I'm trying to create a simple simulation game where every time the player advances a turn, the player's gold increases according to the tax rate he has set. I have created two separate commands, one for moving to the next turn, the other for setting the tax rate. The problem, is the game only seems to use one command or the other, based on which is the higher up on the list on the Commands menu! ie. if #change tax rate# is first, the game will run the tax rate script whenever the player enters "next turn" and if #next turn# is first, the game will run the "next turn" script when the player enters "change tax rate".
Any help much appreciated!
My game code is below:
' "Sim Government"
' Created with QDK Lite 4.1.2
!include <stdverbs.lib>
define game <Sim Government>
asl-version <410>
start <Government Room>
game info <Created with QDK Lite 4.1.2>
command <#change tax rate#> {
msg <Please enter a number between 0 and 60 to reflect your preferred percentage income tax.>
enter <tax rate>
set numeric <tax rate; #tax rate#>
if ( #tax rate# < 0 ) or ( #tax rate# > 60 ) then msg <The tax rate must be between 0 and 60.>
}
command <#next turn#> inc <turn; 1>
define variable <turn>
type numeric
value <0>
display <turn !>
onchange {
set numeric <tax revenue; %tax rate% * 1000>
set numeric <gold; %gold% + %tax revenue%>
}
end define
define variable <gold>
type numeric
value <0>
display <gold !>
end define
define variable <tax rate>
type numeric
value <25>
display <tax rate !>
end define
end define
define options
debug on
panes on
abbreviations on
end define
define menu <Game>
end define
define room <Government Room>
prefix <the>
end define
I'm trying to create a simple simulation game where every time the player advances a turn, the player's gold increases according to the tax rate he has set. I have created two separate commands, one for moving to the next turn, the other for setting the tax rate. The problem, is the game only seems to use one command or the other, based on which is the higher up on the list on the Commands menu! ie. if #change tax rate# is first, the game will run the tax rate script whenever the player enters "next turn" and if #next turn# is first, the game will run the "next turn" script when the player enters "change tax rate".
Any help much appreciated!
My game code is below:
' "Sim Government"
' Created with QDK Lite 4.1.2
!include <stdverbs.lib>
define game <Sim Government>
asl-version <410>
start <Government Room>
game info <Created with QDK Lite 4.1.2>
command <#change tax rate#> {
msg <Please enter a number between 0 and 60 to reflect your preferred percentage income tax.>
enter <tax rate>
set numeric <tax rate; #tax rate#>
if ( #tax rate# < 0 ) or ( #tax rate# > 60 ) then msg <The tax rate must be between 0 and 60.>
}
command <#next turn#> inc <turn; 1>
define variable <turn>
type numeric
value <0>
display <turn !>
onchange {
set numeric <tax revenue; %tax rate% * 1000>
set numeric <gold; %gold% + %tax revenue%>
}
end define
define variable <gold>
type numeric
value <0>
display <gold !>
end define
define variable <tax rate>
type numeric
value <25>
display <tax rate !>
end define
end define
define options
debug on
panes on
abbreviations on
end define
define menu <Game>
end define
define room <Government Room>
prefix <the>
end define
Alex
15 May 2010, 10:30The problem is you've entered the commands like this:
command <#change tax rate#>
command <#next turn#>
When you put # characters around some text, that becomes a variable, which can be any text. It's so you can create commands like "put #object# on #surface#", which will match "put cup on table", "put book on shelf" etc.
In this case both of your commands are entirely variable, so they will both match any text the player ever types. Not a good thing!
All you need to do is remove the # characters:
command <change tax rate>
command <next turn>
command <#change tax rate#>
command <#next turn#>
When you put # characters around some text, that becomes a variable, which can be any text. It's so you can create commands like "put #object# on #surface#", which will match "put cup on table", "put book on shelf" etc.
In this case both of your commands are entirely variable, so they will both match any text the player ever types. Not a good thing!
All you need to do is remove the # characters:
command <change tax rate>
command <next turn>
SquirrelUK
15 May 2010, 11:21<slaps face> How frustrating to think I've spent so long trying to get this to work when the problem was such a simple thing! Oh well.
Thanks a million again, Alex.
Thanks a million again, Alex.