Scripting thoughts

Have "sets" of triggers that group related triggers together, and are attached together. (Okay, now a set is a "script")

Each set can be attached together with parameters, specified in the object template. (Not added yet)


  #okay, we DO want 'only runs once' behavior, right? so i figure
  # triggers should be a static structure, not "currently running scripts"
  # hmm... but need to have LOCAL "running" data. maybe hash keyed
  # by trigger id

so structure loaded from disk, contains sets of triggers, keyed on /-names, individual triggers should have ids for local running records to specify which triggers are running.

(running trig records contain REFS to trigger structures, so it changes as soon as the trigger completes)

Trigger thingies: Object manipulation commands should have special hooks to check for triggers on their actions. Also should have triggers for commands, period, so that we can implement, say, "tag mym".

---- Language notes

{ } are used simply for checks like "if condition false, skip this block."

Sample script:

"path" VCREATE "elem" VCREATE
"to 4305 to 4389 ocloth e ccloth rest poscheck" >path
WHILE path {
  path CAR >elem
  path CDR >path
  elem SWITCH {
    "ocloth" CASE  "open cloth" DO BREAK
    "ccloth" CASE "close cloth" DO BREAK
    "poscheck" CASE
      self "room" GET 4373 != IF {
        "say Hmm, I seem to be lost." DO
        "semote utters the words, 'inset candusqirr'" DO
        "sgoto 4373" DO
        "semote appears in the middle of the room" DO
      }
    BREAK
    DEFAULT elem DO BREAK
  }
  10 WAIT
}

Commands
VCREATE ( name -- ) create variable
VDELETE ( name -- ) delete variable
>varname ( value -- ) set variable
WHILE ( -- ) begin while loop
CAR ( instr -- outstr ) first word of string
CDR ( instr -- outstr ) all but first word of string
SWITCH ( value -- ) Switch structure - jump to next matching CASE
CASE ( label -- ) Case
BREAK ( -- ) Jump to SWEND
DO ( str -- ) execute MUD command
GET ( object fieldname -- value ) get field of an object
IF ( flag -- ) if flag false, jump to ENDIF or ELSE
ELSE ( -- ) marker for IF
WAIT ( time -- ) pause script for time/10 seconds
- ( a b -- c ) subtraction
RAND ( max -- num ) random integer from 0 to max-1
W_CNT ( str -- cnt ) count words in string
W_GET ( index str -- word ) get index'th word from string
EXIT ( object direction -- destobject ) get object linked to exit
FSET? (object flagname -- bool ) is obj or room flag set on object?
NOT ( bool -- bool ) logical not
