Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Magic: asking for some general string detection system

I've been turning it every which way, but all my ideas either involve a lot of conditionals or require advanced scripting knowledge. Maybe here somebody can help me out.

In the story I'm writing, magic is done by intoning three-letter power syllables: meh, bin, sha etc. The player knows a few from the start, and I'd like to be able to add more syllables as the game goes on, so ideally there would be some kind of central list I could update. Now, for the player to cast a spell, he needs to type the right sequence of syllables in the text box available in most situations, like so: bin sha meh for a heal. He discovers these combinations in the course of play. The text box recognizes these combos and puff, stuff happens. This costs some stamina.

Now, up to this point I know the code. But there would be no reason to make such a complex system unless syllables could be combined in creative ways. I want the player to be able to type in that box whatever he wants, and perhaps discover new spells. But this kind of playing with fire is dangerous, so here is how I want that text box to behave:

1) if the text typed contains no legit syllable from the list, nothing happens and the player just wastes the moment.
2) if only one syllable, this produces no effect, but tires the player somewhat.
3) if only two syllables, this hurts the player and tires him.
4) if three syllables, but not any legit combination, this hurts the player and can have a variety of side effects.
5) if more than three syllables, the effect is always disastrous.

Now all these consequences, stamina drain and so on I can write out. What I can't figure out is some general way to register syllables' presence and number in the text input. If you've done something like this, drop me a hint or better your whole system, I don't care to be 100% original. I'll put you on the Special thanks list. 8)

Comments

Sign In or Register to comment.