you almost got it... (and very good job!, as understanding that you need to set~make your input into a Type:Integer, is the more difficult concept~logic part for people new to coding, hehe. You only are missing the proper syntaxing of how to do it).
the 'ToInt (result)', must be set to something... as it is an Expression:
......................................................................../
.......................................................................V
Object_name.Attribute_name = Value_or_Expression
~OR~
variable_string_name = Value_or_Expression
so... in the below example:
variable_string_name = Expression
result2 = ToInt (result)
msg ("How Many ?")
get input {
// the 'get input' automatically (hidden from you) sets its built-in Variable: result = your_typed_in_input
// this method however will have an error if the person playing the game doesn't type in a non-decimal number...
// but now we need to convert it to being an Integer (and have to set it again to another VARIABLE, for this example, a local Variable, which I'm labeling~naming~calling it as 'result2', but you can call it whatever you want):
result2 = ToInt (result)
// now, we can use our 'result2' local Variable below:
if (player.money <= 10 * result2) {
msg ("You cant afford it")
}
else {
bricks.count = bricks.count + result2
AddToInventory (bricks)
}
}
I think this way would work too instead of the above way using a 2nd Variable (result2), but you still got the same issue~error if the person doesn't type in a non-decimal number:
msg ("How Many ?")
get input {
if (player.money <= 10 * ToInt (result)) {
msg ("You cant afford it")
}
else {
bricks.count = bricks.count + ToInt (result)
AddToInventory (bricks)
}
}
alternatively (and better coding design: 'Error and Exception Handling' pre-emptive coding), you can check the input if it's an Integer:
http://docs.textadventures.co.uk/quest/ ... isint.htmlmsg ("How Many ?")
get input {
if (IsInt (result)) {
if (player.money <= 10 * ToInt (result)) {
msg ("You cant afford it")
} else {
bricks.count = bricks.count + ToInt (result)
AddToInventory (bricks)
}
} else {
msg ("Wrong input, try again, using a non-decimal number this time, please.")
}
}