Version 3 features
So far, this year, I have added the following interesting capabilities to ChatScript.
1. Rule tags- Every rule can be accessed by knowing the topic name, the index of what top level rule it is, and which rejoinder of the rule it is. Normally, you don’t have to know them yourself. The system can be asked which rule (which tag) generated a particular output and you can save that information. One way this can be used, is you can “intercept” a rule. For example:
t: (AGE_TEST()) I like to drink wine.
You can write a topic to verify a user’s age. If the age is already known, this test allows the gambit to be said immediately. If the age is not known, you can “memorize” the tag of the current rule, then invoke a topic to ask about their age. Some number of volleys later, if you are satisfied they are of appropriate age, you can then return to execute the tag you saved.
2. ^popen() - this function acts like its corresponding Linux C code. You write as its arguments the string the OS should execute, and you get back the lines of text that were the result of that call. You get to execute a function on each line of text returned. This allows for all sorts of interactions with external resources.
3. ^log() now can take a filename to write to, so you can dump information into any place you want, instead of just the user’s log file.
4. ^export() now allows an argument to choose to append to the exported file, rather than overwrite it. You can use this to accumulate facts over time into a file.
5. :document will allow your bot to “read” thru a file, sentence by sentence. This significant capability is not for chat but for document analysis. What you look for when you read is up to you.
6. ^available() allows you to ask if a rule has been erased yet or not. You might use this to find out if the user has been thru some particular section of a topic or not. Maybe you don’t want to start on this topic until they have been elsewhere. You could, of course, write user variables when you pass thru a rule, and query that instead, but this is less complicated and makes the script less messy.