Asking YES or NO questions without 'get input' (or 'ask') - A complete waste of time?

  <command name="walk_around_cmd">
    <pattern>walk around;walk around #object#</pattern>
    <synonyms type="stringlist">
      <value>walk</value>
    </synonyms>
    <script><![CDATA[
      // <SETG AWAITING-REPLY 16>
      // <ENABLE <QUEUE I-REPLY 2>>
      // <TELL "Did you have any particular direction in mind?" CR>>
      global.awaiting_reply = 16
      EnableQueue (i_reply, 2)
      msg ("Did you have any particular direction in mind?")
    ]]></script>
  </command>
  <turnscript name="i_reply">
    <istyle />
    <enabled type="boolean">false</enabled>
    <script>
      global.awaiting_reply = 0
    </script>
  </turnscript>
  <function name="EnableQueue" parameters="turnscript, i"><![CDATA[
    turnscript.turncount = 0
    if (not GetBoolean(turnscript, "enabled")) {
      turnscript.enabled = true
    }
    turnscript.triggerturncount = i
  ]]></function>
  <function name="SetUpITurnscripts"><![CDATA[
    foreach (turnscript, ObjectListSort(AllTurnScripts(), "name")) {
      if (GetBoolean(turnscript,"istyle")) {
        turnscript.turncount = 0
        turnscript.timeoutturnscript = turnscript.script
        SetTurnScript (turnscript) {
          if (not this.triggerturncount = -1) {
            this.turncount = this.turncount + 1
          }
          if (this.triggerturncount = -1) {
            invoke (this.timeoutturnscript)
          }
          else if (this.turncount = this.triggerturncount and not this.triggerturncount = -1) {
            invoke (this.timeoutturnscript)
            if (this.turncount = this.triggerturncount and not this.triggerturncount = -1) {
              DisableTurnScript (this)
            }
          }
        }
      }
    }
  ]]></function>
  <command name="yes_cmd">
    <pattern>yes;y</pattern>
    <script>
      switch (global.awaiting_reply) {
        case (1) {
          DoWalk ("south")
        }
        case (3) {
          msg ("Well, tough.")
        }
        case (4) {
          msg("TODO! Case 4")
          // take item dropped at party
        }
        case (5) {
          msg ("So do I.")
        }
        case (6,8,11,13,14,15) {
          msg ("That was just a rhetorical question.")
        }
        case (7,9) {
          msg ("Well, good for you!")
        }
        case (10) {
          Perform (enjoy_cmd, QuickParams("object",Ford))
        }
        case (12) {
          EnableQueue (i_engineer, 2)
          msg ("\"Well, let's see the malfunctioning equipment.\"")
        }
        case (16) {
          msg ("Then type it.")
        }
        case (18,19) {
          msg ("\"Well, leave me alone then! I'm busy!\"")
        }
        default {
          msg ("You sound rather positive.")
        }
      }
    </script>
  </command>
  <command name="no_cmd">
    <pattern>no;negative</pattern>
    <script>
      switch (global.awaiting_reply) {
        case (2) {
          DoWalk ("south")
        }
        case (3,10) {
          msg ("I should think not.")
        }
        case (4) {
          msg ("The word \"no\" is not in our hostess' vocabulary.")
        }
        case (5) {
          global.awaiting_reply = 3
          invoke (yes_cmd.script)
        }
        case (6,11) {
          global.awaiting_reply = 6
          invoke (yes_cmd.script)
        }
        case (7,8,13,15) {
          global.awaiting_reply = 3
          invoke (yes_cmd.script)
        }
        case (9) {
          msg ("I disagree.")
        }
        case (12) {
          msg("TODO: Create EngineerLeave,engineer, and global.roars_off")
          // EngineerLeave
          // msg("\"Think you're funny, huh?\" The " + engineer.alias + global.roars_off + ", making sure to spray you with his Sub-Ethon exhaust.")
        }
        case (14) {
          msg ("Then stop.")
        }
        case (16) {
          msg ("I didn't think so.")
        }
        case (18,19) {
          invoke (yes_cmd.script)
        }
        default {
          msg ("You sound rather negative.")
        }
      }
    </script>
  </command>

That seems quite a complex way of doing it; having a big 'switch' list like that is also prone to errors, as the same event is split between parallel lists in several places. It works if you have the whole game planned out in advance; but for most people I would say that keeping the code related to a particular event together is beneficial.

I believe we already have a modification which allows the player to answer ShowMenu choices by typing in the option. In that case, it would be perfectly legitimate to use the existing menu options - you could put a script into game.menucallback without necessarily displaying a menu, and process the result there.

Alternatively, you could make a separate "yes" or "no" command for each of these situations. Have them moved to the current location when the question is asked, and give them some flag so that a turnscript can put them away again after the player performs an action. I think this would be considerably simpler.

Or even have yes and no commands, but instead of setting a flag, set the scripts directly:

  <command name="walk_around_cmd">
    <pattern>walk around;walk around #object#</pattern>
    <synonyms type="stringlist">
      <value>walk</value>
    </synonyms>
    <script><![CDATA[
      // <SETG AWAITING-REPLY 16>
      // <ENABLE <QUEUE I-REPLY 2>>
      // <TELL "Did you have any particular direction in mind?" CR>>
      EnableQueue (i_reply, 2)
      msg ("Did you have any particular direction in mind?")
      yes_cmd.script => {
        msg ("Then type it.")
      }
      no_cmd.script => {
        msg ("I didn't think so.")
      }
    ]]></script>
  </command>

That seems quite a complex way of doing it; having a big 'switch' list like that is also prone to errors, as the same event is split between parallel lists in several places. It works if you have the whole game planned out in advance; but for most people I would say that keeping the code related to a particular event together is beneficial.

Yeah.

This code was written by Infocom. It was definitely planned out. (Most of it is in alphabetical order and stuff, too.)


Ooh! I like your script idea!


Log in to post a reply.

Support

Forums