A lazy way to provide a menu of Ask topics when Speaking to an NPC

K.V.
 <speakto type="script"><![CDATA[
  game.askedthis = this
  ShowMenu ("Try asking " + this.article + " about one of the following:", game.askedthis.ask, true) {
    msg ("You ask " + game.askedthis.article + " about " + result + ".<br/>")
    DoAskTell (game.askedthis, result, "ask", "askdefault", "DefaultAsk")
    game.askedthis = null
  }
 ]]></speakto>

NOTES:

  • Whatever you enter for the key under Ask will be displayed as a menu option
    • This means any alternates you list (i.e., color colors colour colours) will all be displayed.
    • I'm only putting what I want displayed in the menu. Anyone entering direct questions will have to be more precise when 'guessing the topic' this way.
  • You must enable the Ask/Tell option under the Features tab of the game object
  • Pixie's method (creating a topics string list on the NPC) is much more efficient than this. (I'm just being lazy and avoiding revising the string list each time I add, remove, or alter an Ask entry.)

Here's an example game.

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="RH's Ask Dic">
    <gameid>54dd8ac0-f7d8-4914-ab9e-7915856fa645</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <feature_asktell />
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="RH">
      <inherit name="editor_object" />
      <inherit name="namedmale" />
      <look><![CDATA[He's not much to look at...<br/><br/>Maybe you should just {command:speak to the dick}.]]></look>
      <alt type="stringlist">
        <value>rh</value>
        <value>richard headkid</value>
        <value>dh</value>
      </alt>
      <listalias>RH</listalias>
      <speakto type="script"><![CDATA[
        game.askedthis = this
        ShowMenu ("Try asking " + this.article + " about one of the following:", game.askedthis.ask, true) {
          msg ("You ask " + game.askedthis.article + " about " + result + ".<br/>")
          DoAskTell (game.askedthis, result, "ask", "askdefault", "DefaultAsk")
          game.askedthis = null
        }
      ]]></speakto>
      <askdefault type="script">
        msg ("RH shrugs.")
      </askdefault>
      <telldefault type="script">
        msg ("RH nods, but you can tell he's paying you no mind.")
      </telldefault>
      <telltodefault type="script">
        msg ("\"No... You can do that yourself.  Thanks, though,\" says RH.")
      </telltodefault>
      <ask type="scriptdictionary">
        <item key="Life">
          msg ("\"Don't talk to me about life,\" drones RH.")
        </item>
        <item key="The Universe">
          msg ("\"It's big,\" says RH.  \"VERY big.\"")
        </item>
        <item key="Everything">
          msg ("\"Something about the whole general mish-mash,\" RH says, scratching his chin, his brow furrowed.  \"You'll have to consult The Guide on the subject.\"")
        </item>
      </ask>
      <alias>Dick Headkid</alias>
    </object>
  </object>
  <verb>
    <property>speakto</property>
    <pattern>speak to; speak; talk to; talk;converse;converse with;speak with;talk with</pattern>
    <defaultexpression>"You can't speak to; speak; talk to; talk;converse;converse with;speak with;talk with " + object.article + "."</defaultexpression>
  </verb>
</asl>

I've been using Switch Scripts for speaking to NPCs.

For example...

I have an NPC in a room. I make Commands in that room like "Chat" and connect the menu to that NPC.

msg ("<br/>What would you like to talk about?<br/><br/>")
ShowMenu ("", goblinesque woman.chatmenu, true) {

Then I give that NPC the "chatmenu StringList" filled with the conversation topics ((you can even make it so that one pops up at a time, or one topic makes the rest of the topics appear once it's finished)).

When the player clicks that topic you can remove that topic and add the next, or control it how you like.

list remove (goblinesque woman.chatmenu, "Say Hi")
list add (goblinesque woman.chatmenu, "So about the weather.")

etc.

Make sense?

Anonynn.


K.V.

I used something just like that in a "conversational piece" type of game.

I actually ended up using Pixie's library, which output the same results with much less scripting for me (since Pix did all the work up-front).


This example is just my lazy way to do it. Nothing gets changed during play, and the player always has easy access to the NPC's response. (The player can simply ask the question again.)

Not that your way isn't solid and right-on... (It is.) This method just makes it look like you put in the time to provide the player with clickable lists of things to discuss, when you really just wrote one short script.


To manipulate this, I could do something like this:

<item key="This Topic Will Self-Destruct!!!"><![CDATA[
  msg ("Read this while it's on the screen, because you'll never be able to access it again!")
   dictionary remove (this.ask, "This Topic Will Self-Destruct!!!")
]]></item>

I probably wouldn't want the player to enter ASK ABOUT THIS TOPIC WILL SELF DESTRUCT!!! if I wanted to remove it from the list of topics anyway (although, this may not always be the case).


To remove one and add one, I'd do this:

<item key="This Topic Will Self-Destruct!!!"><![CDATA[
  msg ("Read this while it's on the screen, because you'll never be able to access it again!")
  dictionary remove (this.ask, "This Topic Will Self-Destruct!!!")
  Ano => {
    msg ("\"Anonynn rocks,\" replies RH, matter-of-factly.  \"Hell, everyone knows that!\"")
  }
  dictionary add (this.ask, "Anonynn", Ano)
]]></item>

RH's Ask Dic

You are in a room.
You can see Dick Headkid.

> speak to Dick Headkid
Try asking him about one of the following:
1: Life
2: The Universe
3: Everything
4: This Topic Will Self-Destruct!!!


> speak to Dick Headkid
You ask him about This Topic Will Self-Destruct!!!.

Read this while it's on the screen, because you'll never be able to access it again!



> speak to Dick Headkid
Try asking him about one of the following:
1: Life
2: The Universe
3: Everything
4: Anonynn


> speak to Dick Headkid
You ask him about Anonynn.

"Anonynn rocks," replies RH, matter-of-factly. "Hell, everyone knows that!"


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums