custom attribute = integer chosen by player
![](https://i.imgur.com/t1XUS1Kb.jpg)
Jennifer Wren
04 Jul 2023, 20:19I wanted to make a cusytom command that would allow the player to choose an integer for a status attribute. I wasn't at all sure where to begin, so I tried
http://docs.textadventures.co.uk/quest/tutorial/custom_commands.html
even though, technically I knew it would probably not work with actual integer value attribution.
This is the error I got for it:
Error running script: Error compiling expression '#text#': DateTimeLiteralElement: String was not recognized as a valid 'DateTime'
Does anyone know how I can allow players to choose an integer, type in an integer, and then have that integer become the current value of the custom attribute, like money. Someone types in "5" or "money 5" and they can have a five dollar loan from the "bank"?
![](https://i.imgur.com/t1XUS1Kb.jpg)
Jennifer Wren
04 Jul 2023, 21:32Maybe, I mistyped something and it does actually work? I think I may have mistyped the attribute name.
mrangel
05 Jul 2023, 11:04That seems like a bizarre error message; I can't understand how that would happen. It looks like #text#
is somewhere that it's being treated as an expression rather than a command pattern.
If you're using a player-input text as a number, remember to use both IsInt
and ToInt
. So a command that gives the player a requested amount of money might look like:
if (IsInt (text)) {
msg ("You gain $" + text + ".")
game.pov.money = game.pov.money + ToInt (text)
}
else {
msg ("The amount of money must be a number.")
}
(A common mistake is to assume that the player typed a number without checking)
![](https://i.imgur.com/t1XUS1Kb.jpg)
Jennifer Wren
05 Jul 2023, 18:26Thank you for the advice. If I actually get the script to work, I will have sure use the Is Int and To Int to keep it neat, too. I had never heard of them, before.