I am very new to IF development (started yesterday), and I am trying to make an IF that involves some word puzzles. So I’d like to be able to define an action like “answer XXX”, where “XXX” can be any string that is to be validated. I looked at a couple TADS tutorials, but it seems like the actions all expect the name of an object. Is there a way to get around this, where I can let the user enter any arbitrary string as input? Thanks to all in advance, your help’s greatly appreciated!
Sure. There’s an article on creating verbs in the TADS 3 Technical Manual. Scroll down to the section “Verbs with a “literal” object”, which explains how to create verbs that take a string of text instead of an object. You might also want to read the section “Verbs with no objects”, since these two kinds of verbs are very similar.
If you still have questions after reading that article, just ask!
Actually I do have a second question now, so I’ve made my action that takes a single literal, now if the user types just “answer” without any parameter, I get “invalid index operation”. I guess the code wasn’t smart enough to handle the empty string case, or something like that. So what should I do? Try catch? Make yet another action Answer that takes no argument at all? (ideally i just want to print “what do you want to answer”)