Suppose the player acquires a few items in the course of the game I later want to remove or transform. E.g. silk pants, silk shoes and silk hat. I would normally record the fact that he has them with <<set $silkpants to 1>> or similar, but I could also write it down to a string - <<set $silkpants to "silkpants">>. I'm thinking this might be useful if I decide to remove all items beginning, or containing, "silk". I could do it with a separate variable change for each, but if there are 20 different silk items, and if I haven't finished giving them all to the player, might add some later, then it's a real drag. So, is it possible to reference string content?
Comments
Yes. You can use the Javascript string function
indexOf()
to determine whether or not a substring exists. An example would be: The -1 is the result of the indexOf function if it cannot find the value in the string.