Dialogue help and setting up a computer

I am trying to create a dialogue tree for a computer where I am checking mail on regular basis. How can one set it up a system like that? I was thinking using ShowMenu and then using CallFunction in order to go from one menu to another. It works well for the first batch of mails I receive, but as soon as the second round needs to come into my inbox, things become extremely complicated and I can't get it to work. This is the script I found here and tried to make it work:

topics = Split ("What mission?;I was born ready!;Err.. what mission?;Actually I am having second thoughts about it.", ";")
ShowMenu ("", topics, true) {
  switch (result) {
    case ("What mission?") {
      msg ("Viconia smiles. 'Oh don't be so coy. Haven't you heard you are going to Gliese 667 Cc?'")
      speak_to_android_female_mission
    }
    case ("I was born ready!") {
      msg ("'Good.'")
      speak_to_android_female_mission
    }
    case ("Err.. what mission?") {
      msg ("'Mission to Gliese 667 Cc.'")
      speak_to_android_female_mission
    }
    case ("Actually I am having second thoughts about it.") {
      msg ("'Oh don't worry about it.'")
      speak_to_android_female_mission
    }
  }
}

I also tried using the ConvLib library made by Pixie. Her library works great with dialogues, but when it comes to a computer, I cant get it to work properly. Namely, I can't make it read follow-on topics. I can consult the computer only once and then the dialogue shuts down. Here is my whole test script, so hopefully someone can help me to get it to work properly. As you can see, the two dialogues are set up identically for character and for consultable, but the consultable part just doesnt work for some reason.

Please help.

<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <include ref="ConvLib.aslx" />
  <game name="Test">
    <gameid>518837ad-aafa-4ad3-94ed-210fde814ac7</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
    <showhealth />
    <showmoney />
    <attr name="feature_asktell" type="boolean">false</attr>
    <feature_lightdark />
    <feature_annotations />
    <feature_advancedwearables />
    <attr name="feature_advancedscripts" type="boolean">false</attr>
    <appendobjectdescription />
    <multiplecommands />
    <defaultfontsize type="int">10</defaultfontsize>
    <menufontsize type="int">8</menufontsize>
    <setbackgroundopacity />
    <turnoffplacesandobjects />
    <statusandcompassattop />
    <showborder type="boolean">false</showborder>
    <shadowbox />
    <feature_pictureframe />
    <clearscreenonroomenter />
    <attr name="autodescription_youarein_useprefix" type="boolean">false</attr>
    <autodescription_description_newline />
    <panestheme>Midnight</panestheme>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <enter type="script">
    </enter>
    <description type="script">
      get input {
        MoveObject (player, room 2)
      }
    </description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
  <object name="room 2">
    <inherit name="editor_room" />
    <enter type="script">
    </enter>
    <beforeenter type="script">
    </beforeenter>
    <object name="mary">
      <inherit name="editor_object" />
      <inherit name="namedfemale" />
      <inherit name="talkingchar" />
      <feature_usegive />
      <displayverbs type="stringlist">
        <value>Look at</value>
        <value>Talk to</value>
      </displayverbs>
      <exchange type="string"></exchange>
      <hideafter />
      <activeconversations />
      <forcedconversations />
      <use type="script">
      </use>
      <object name="mary alibi">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <alias>Where were you yesterday?</alias>
        <exchange><![CDATA[I was in a bar.<br/>]]></exchange>
        <displayverbs type="stringlist">
          <value>Look at</value>
        </displayverbs>
        <hideafter />
        <terminal type="boolean">false</terminal>
        <nowhide type="stringlist" />
        <nowshow type="stringlist">
          <value>mary playing pool</value>
        </nowshow>
      </object>
      <object name="QDoctor">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <alias>How well did you know the doctor?</alias>
        <exchange>I knew him pretty well.</exchange>
      </object>
      <object name="Bye">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <alias>Bye, Mary!</alias>
        <terminal />
        <hideafter type="boolean">false</hideafter>
        <exchange>Goodbye.</exchange>
      </object>
      <object name="mary playing pool">
        <inherit name="editor_object" />
        <inherit name="topic" />
        <exchange><![CDATA[I was playing pool.<br/>]]></exchange>
        <alias>What were you doing?</alias>
        <nowshow type="stringlist" />
      </object>
    </object>
    <object name="computer">
      <inherit name="editor_object" />
      <inherit name="consultable" />
      <displayverbs type="stringlist">
        <value>Look at</value>
        <value>Use</value>
      </displayverbs>
      <feature_usegive />
      <use type="script">
        // You want to re-write this so you can, for example, test the thing is turned on
        if (HasBoolean(this, "switchedon")) {
          if (not this.switchedon) {
            P (DynamicTemplate("ConsultableSwitchedOff", this))
          }
          else {
            Converse (this, DynamicTemplate("ConsultAbout", this))
          }
        }
        else {
          Converse (this, DynamicTemplate("ConsultAbout", this))
        }
      </use>
      <activeconversations type="boolean">false</activeconversations>
      <forcedconversations type="boolean">false</forcedconversations>
      <object name="check_mail">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <visible type="boolean">false</visible>
        <alias>check my mail</alias>
        <terminal type="boolean">false</terminal>
        <hideafter />
        <exchange>You have 2 mails.</exchange>
        <nowshow type="stringlist">
          <value>mail from Joe</value>
          <value>spam mail</value>
        </nowshow>
      </object>
      <object name="spam mail">
        <inherit name="editor_object" />
        <inherit name="topic" />
        <hideafter type="boolean">false</hideafter>
        <terminal type="boolean">false</terminal>
        <exchange>this is spam</exchange>
        <alias>This is just some spam</alias>
        <nowshow type="stringlist" />
      </object>
      <object name="mail from Joe">
        <inherit name="editor_object" />
        <inherit name="topic" />
        <hideafter type="boolean">false</hideafter>
        <terminal type="boolean">false</terminal>
        <exchange>this is a mail from Joe.</exchange>
        <alias>This is mail from Joe</alias>
        <expires type="boolean">false</expires>
      </object>
    </object>
  </object>
</asl>```

I would say that the easiest way to do this would be using ShowMenu.

But instead of the Split() command at the start, give the player a stringlist attribute containing the emails they've currently received. That way, whenever some event or action causes a new message to become available, you can just add it to the list. The same switch statement can contain all of the options, even if they're not available to the player at the start.


mrangel, thank you for your reply. I know how to create an attribute like strength, stamina and increase a number on it, but I have never done a stringlist attribute. Can you give me a few pointers? Like, is it similar? Where do I start? Do I need to use "if" statements? Etc.. Maybe if you can make a short script so I can look at it, I would appreciate it very much.


I believe if you're using the desktop version of Quest, you can create attributes easily enough. But I normally use the web version, where you have to put attributes in a script.

The way I'd have to do it would be, in the start script, something like:

player.emails = Split("Make $$$ in you're spare time!;Hi John;Have you seen this;Get your FREE spoon today!")

Then if there's some event where another character sends you an email, the character's "speak to" verb might be something like:

  msg ("Dave says he'll send you the details you want in an email, and storms off.")
  list add (player.emails, "Re: Our conversation this afternoon")

And your "check email" script (whether that's using the computer, or entering a command) would look something like:

msg ("You have {=ListCount(player.emails)} emails.")
ShowMenu ("Which message would you like to read?", player.emails, true) {
  msg ("{b"+result+"}")
  switch (result) {
    case ("Make $$$ in you're spare time!", "Get your FREE spoon today!") {
      msg ("It's just spam. You delete it.")
      list remove (player.emails, result)
    }
    case ("Hi John") {
      msg ("It's an email from Rose. You don't feel like replying to her right now.")
    }
    case ("Have you seen this") {
      msg ("You read a long, rambling email from Pat. You're not sure what point he was trying to make, so you reply to let him know.")
      // You could set a flag here or something to make Pat respond differently next time you speak to him
    }
    case ("Re: Our conversation this afternoon") {
      msg ("It's the details Dave promised to send you. At last!")
    }
    default {
      // We have an error here, to make it easier to catch typos
      error ("Unexpected email: \""+result+"\"")
    }
  }
}

In that case, all the email responses are in one switch statement, but the player can only read the ones that have been added to the list. You can use list add and list remove to add emails to the folder at any point in the game.

There are lost of different ways to handle emails, depending on how you expect the player to use them. But this is probably one of the simplest.


Thanks for your reply. Yes, I am using the desktop version. I tried doing what you wrote here, but I spent around 3 hours searching for start script. There is nothing like that in Quest. I searched every single thing at least 10 times and I just cant find it. I am sorry if I sound stupid, but I am a complete noob. Can you tell me where do I need to click to find the start script?

I can't even do the first step you wrote.


What I did manage to do is put what you call "start script" into "before you enter a room" section where my computer is. Then I copied the rest of your script under "use" in my computer. It seems to work, but it seems to be a bit wonky, because each time I click on something, I get a reply. So my messages keep going up like crazy. I probably didnt put your script in the right place, because I cant find the damn "start script" section. Also, I would like it if I could stay in the computer menu. The way it works currently, I have to click on use computer after reading each mail. I would like to have a button for shutting down computer instead, so that I cant read all e-mails with one "use" command.

This is what I get the way I set it up, but I admit I must have probably misunderstood your advice:

use computer
Dave says he'll send you the details you want in an email, and storms off.
You have 5 emails.
{bMake $$$ in you're spare time!}
It's just spam. You delete it.

use computer
Dave says he'll send you the details you want in an email, and storms off.
You have 5 emails.
{bHave you seen this}
You read a long, rambling email from Pat. You're not sure what point he was trying to make, so you reply to let him know.

use computer
Dave says he'll send you the details you want in an email, and storms off.
You have 6 emails.
{bHi John}
It's an email from Rose. You don't feel like replying to her right now.

use computer
Dave says he'll send you the details you want in an email, and storms off.
You have 7 emails.
{bRe: Our conversation this afternoon}
It's the details Dave promised to send you. At last!

use computer
Dave says he'll send you the details you want in an email, and storms off.
You have 8 emails.
{bRe: Our conversation this afternoon}
It's the details Dave promised to send you. At last!


Click the object called "game" then, in the window to the right, click the tab called "Scripts" .
At the top of that one is where you put your start scripts. (it should say so, top left)
;)


The example I gave for speaking to Dave is an example of how to have someone send you an email.

If you want Dave to send you an email when you speak to him, then put that code inside Dave's "speak to" script.

It you want Dave to send you an email when you give him an item, put that code in his "give to" script.

If you want Dave to send you another email every time you use the computer, then put that code in the computer's "use" script. (This seems to be what you've done)

Here's a modified code to leave the computer turned on:

msg ("You have {=ListCount(player.emails)} emails.")
ShowMenu ("Which message would you like to read?", ListCombine (player.emails, Split("[turn off computer]")), true) {
  msg ("{b:"+result+"}")
  if (result = "[turn off computer]") {
    msg ("Shutting down...")
  }
  else {
    switch (result) {

// all the 'case' statements go here, as before

      default {
        // We have an error here, to make it easier to catch typos
        error ("Unexpected email: \""+result+"\"")
      }
    }
    do (this, "use")
  }
}

here's some links/guides for you:

http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c

(specifically on using lists/dictionaries, see my 'list/dictionary guide' link --- I go into a lot more detail-explanation than what I posted below)


A List (and Dictionary) Attribute is just a bunch of 'items', which you can select an individual item, and/or iterate/cycle through those items, and then perform whatever actions you want on those items

the 'items' are actually just 'inputs-outputs', and so List (and Dictionary) Attributes are just input-output functions in their functionality

item1
-> input
-> output

item2
-> input
-> output

Lists have forced/automatic inputs, 'index numbers', STARTING AT '0' (NOT 1 --- this takes awhile to get used to):

item1
-> input: 0

item2
-> input: 1

item3
-> input: 2

etc etc etc

Dictionaries have custom inputs:

item1
-> input: WHATEVER_STRING_VALUE_YOU_WANT

item2
-> input: WHATEVER_STRING_VALUE_YOU_WANT

etc etc etc

for example:

item1
-> input: "warrior"

item2
-> input: "thief"

item3
-> input: "cleric"

item4
-> input: "wizard"

and a List's/Dictionary's output, is always custom, but it depends on the type of List/Dictionary it is:

Lists:

String List:

item1
-> input: 0
-> output: WHATEVER_STRING_VALUE_YOU_WANT

item2
-> input: 1
-> output: WHATEVER_STRING_VALUE_YOU_WANT

Object List:

item1
-> input: 0
-> output: WHATEVER_OBJECT_(POINTER/REFERENCE)_VALUE_YOU_WANT

item2
-> input: 1
-> output: WHATEVER_OBJECT_(POINTER/REFERENCE)_VALUE_YOU_WANT

Dictionaries:

String Dictionaries:

item1
-> input: WHATEVER_STRING_VALUE_YOU_WANT
-> output: WHATEVER_STRING_VALUE_YOU_WANT

item2
-> input: WHATEVER_STRING_VALUE_YOU_WANT
-> output: WHATEVER_STRING_VALUE_YOU_WANT

Object Dictionaries:

item1
-> input: WHATEVER_STRING_VALUE_YOU_WANT
-> output: WHATEVER_OBJECT_(POINTER/REFERENCE)_VALUE_YOU_WANT

item2
-> input: WHATEVER_STRING_VALUE_YOU_WANT
-> output: WHATEVER_OBJECT_(POINTER/REFERENCE)_VALUE_YOU_WANT

Script Dictionaries:

item1
-> input: WHATEVER_STRING_VALUE_YOU_WANT
-> output: WHATEVER_SCRIPT_VALUE(S)_YOU_WANT

item2
-> input: WHATEVER_STRING_VALUE_YOU_WANT
-> output: WHATEVER_SCRIPT_VALUE(S)_YOU_WANT

for examples:

Lists:

String List:

item1
-> input: 0
-> output: "warrior"

item2
-> input: 1
-> output: "thief"

Object List:

// creating Objects:
// create ("warrior_object")
// create ("thief_object")

item1
-> input: 0
-> output: warrior_object

item2
-> input: 1
-> output: thief_object

Dictionaries:

String Dictionaries:

item1
-> input: "warrior"
-> output: "WARRIOR DESCRIPTION"

item2
-> input: "thief"
-> output: "THIEF DESCRIPTION"

Object Dictionaries:

// creating Objects:
// create ("warrior_object")
// create ("thief_object")

item1
-> input: "warrior"
-> output: warrior_object

item2
-> input: "thief"
-> output: thief_object

Script Dictionaries:

item1
-> input: "warrior"
-> output: player.strength = 5

item2
-> input: "thief"
-> output: player.dexterity = 5


to iterate/cycle through all of the items of LISTS/DICTIONARIES:

foreach (variable_storing_each_item's_input, LIST/DICTIONARY) {
  // scripts/scripting (actions) upon each of those items' inputs
}

to control the iteration/cycling:

http://docs.textadventures.co.uk/quest/scripts/for.html


to get the item's output value from its input value:

http://docs.textadventures.co.uk/quest/functions/#list
http://docs.textadventures.co.uk/quest/functions/#dictionary

(see the links above for their actual syntax and explanation on how to use them --- ask us for help if still confused / having trouble with using them):

ListItem (XXX)
StringListItem (XXX)
ObjectListItem (XXX)
DictionaryItem (XXX)
StringDictionaryItem (XXX)
ObjectDictionaryItem (XXX)
ScriptDictionaryItem (XXX)


the 'start' Script Attribute is a special Script Attribute on the 'game' special Game Settings and Publishing Info Object, which is the first thing that is done when the game starts (making it good for doing an 'introduction' for your game and/or 'character creation' if making an RPG):

in the GUI/Editor:

(left side's "tree of stuff") -> 'game' Object -> 'scripts' Tab -> 'start' Script -> (add your scripts)

in code:

<game name="NAME_OF_GAME">

  <attr name="start" type="script">

    // blah scripts/scripting

  </attr>

</game>

the actual GAME OBJECT itself is the 'asl' tag block:

<asl version="###">

  <!-- YOUR ENTIRE MASS OF GAME CODE/CONTENT -->

</asl>

whereas the 'game' special Game Settings and Publishing Object, is merely a special (and required) Object, within your game:

<asl version="###">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="NAME_OF_GAME">

    <!-- Various Attributes (author, firstpublished, version, start, category, difficulty, cruelty, description, etc) -->

  </game>

  <object name="room">

    <inherit name="editor_room" />

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

  </object>

</asl>

Hey! Mrangel! Thanks! Your solution for sending mails finally worked. I also found the "start" script thanks to CheeseMyBaby, but I don't know where to put the other code for having the computer on? I tried modifying the old code you made, but I just get red letters when I copy/paste it above your previous script. I assume that's where it's supposed to go.

Also, where am I supposed to put the part where you say: "// all the 'case' statements go here, as before."

Before when? What? I really don't understand what you are trying to say. I wasted 8 hours yesterday trying to figure it out, but no matter what I try it doesn't work.

This is the modified version I tried putting under "use" computer:

ShowMenu ("Which message would you like to read?", ListCombine (player.emails, Split("[turn off computer]")), true) {
  msg ("{b:"+result+"}")
  if (result = "[turn off computer]") {
    msg ("Shutting down...")
  }
  else {
    switch (result) {
      case ("Make $$$ in you're spare time!", "Get your FREE spoon today!") {
        msg ("It's just spam. You delete it.")
        list remove (player.emails, result)
      }
      case ("Hi John") {
        msg ("It's an email from Rose. You don't feel like replying to her right now.")
      }
      case ("Have you seen this") {
        msg ("You read a long, rambling email from Pat. You're not sure what point he was trying to make, so you reply to let him know.")
        // You could set a flag here or something to make Pat respond differently next time you speak to him
      }
      case ("Re: Our conversation this afternoon") {
        msg ("It's the details Dave promised to send you. At last!")
      }
      default {
        // We have an error here, to make it easier to catch typos
        error ("Unexpected email: \""+result+"\"")
      }
    }
  }```

What am I doing wrong?

hegemonkhan, thanks for your reply, but man... what you wrote sounds like alien language to me. Can't you like "simplify" it a bit? Code means absolutely nothing to me. You might as well be writing hieroglyphic. I can navigate fine around Quest interface - that is fairly easy and I had no problem figuring out how to move from room to room, use objects, even speak to people in very simple terms. However when you start sepaking in code language I just go blank. For example:
GUI/Editor - what the hell is a GUI/Editor?
(left side's "tree of stuff")? - Hunh?...
The rest I can't even begin to comprehend.

Sorry, but I just dont understand these terms. If not for simple explanation from CheeseMyBaby, I would have never found the "start script". Can you please not bombard me with information and perhaps just give me a simple answer for a very specific problem? I think If i can get the script to work the way it's supposed to work, I can maybe begin to understand how script commands work. Until then... I can't make heads or tails from your message.


The gui and the editor is the the same thing. It's names for the edit part view.

I believe the first post is just Hegemon explaining lists, attributes, and strings. In the second post, he's talking about the start script, and then explaining how the game code in code view works.


You have a couple of lines missing from the end of the code there. It turns red because the { and } lines don't match up.

msg ("You have {=ListCount(player.emails)} unread emails.")
ShowMenu ("Which message would you like to read?", ListCombine (player.emails, Split("[turn off computer]")), true) {
  msg ("{b:"+result+"}")
  if (result = "[turn off computer]") {
    msg ("Shutting down...")
  }
  else {
    switch (result) {
      case ("Make $$$ in you're spare time!", "Get your FREE spoon today!") {
        msg ("It's just spam. You delete it.")
        list remove (player.emails, result)
      }
      case ("Hi John") {
        msg ("It's an email from Rose. You don't feel like replying to her right now.")
      }
      case ("Have you seen this") {
        msg ("You read a long, rambling email from Pat. You're not sure what point he was trying to make, so you reply to let him know.")
        // You could set a flag here or something to make Pat respond differently next time you speak to him
      }
      case ("Re: Our conversation this afternoon") {
        msg ("It's the details Dave promised to send you. At last!")
      }
      default {
        // We have an error here, to make it easier to catch typos
        error ("Unexpected email: \""+result+"\"")
      }
    }
    do (this, "use")
  }
}

I'm assuming that's the "use" script for the computer.
If that still fails, there might be a typo in there somewhere.


Hi Mrangel! I tried copying your script under "use" and finally there is no red text. However, upon testing the script the computer just does the same thing as before and I get an error. This is what I get after choosing to read one of the mails:

use computer
You have 4 unread emails.
Hi John
It's an email from Rose. You don't feel like replying to her right now.
Error running script: Error compiling expression 'this': Unknown object or variable 'this'

Bummer :(

Also in your previous post you mentioned this code below. I still cant figure out where to put this code. You just said to put it "here as before", but I have no ideas where "here as before" actually is. Not sure if that has anything to do with it. I do notice you put it all the way below, but I am not sure if that's what you meant or if I am also supposed to put it under the start script or maybe somewhere else.

        // We have an error here, to make it easier to catch typos
        error ("Unexpected email: \""+result+"\"")
      }
    }
    do (this, "use")
  }
}```

That's the second half of the code from the last post.


Thanks Mrangel! I Finally figured it out! Not a bad code. I think I might even use it for dialogues. I actually removed some parts of your code and made it a bit simpler. And for shutting down I made my own modification:

        case ("Shut down your computer") {
          msg ("You shut down your computer.")
          ClearScreen
          ShowRoomDescription
        }

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

Support

Forums