Sure- there are several ways to approach something like this!
The "in" operator can be used to check a string against a hardcoded list of valid options:
on click do if display.text in ("Keyword1","Keyword2","Keyword3") go[display.text "SlideLeft"] else alert["404: Page not found."] end end
And it is also possible to obtain a list of valid card names from the deck; deck.cards is a dictionary from card names to cards:
on click do if display.text in deck.cards go[display.text "SlideLeft"] else alert["No such card, I'm afraid."] end end
It might be a good idea to make the comparison case-insensitive if a user is typing free input. The easiest way to handle this would be to make sure the card names are all lowercase and then to convert the user input to lowercase with the "format" operator before doing any checks:
on click do t:"%l" format display.text if t in keys deck.cards go[t "SlideLeft"] else alert["I don't know anything about that."] ends end
Yet another option is to make a dictionary to associate one or more keywords with destination cards; this provides more options for "forgiveness" in input handling:
on click do words["reindeerflotilla" ]:"puzzle1" words["reindeer flotilla"]:"puzzle1" words["reindeer" ]:"puzzle1" words["smashthestate" ]:"puzzle2" words["smash the state" ]:"puzzle2" t:"%l" format display.text if t in words go[words[t] "BoxIn"] else alert["that's bogus!"] end end
Does that make sense?