Extra dialogue

Can I add a number of different dialogues to the same person in the same room?
There are a number of houses in a city.
There are inhabitants/persons in each house.
My users/players can move around the city, visiting all houses, using the Transit System (http://docs.textadventures.co.uk/quest/transit_system.html).

Now, my users will be visiting the city 7 times, though not during the same playthrough (I'm using this as part of a board game).
Each of the 7 times they visit the city - and the rooms and persons - they are on a new mission, with new dialogues (I'm using the ConvLib library).

I could of course create one Quest version with all the rooms and persons and the dialogue for the 1st time they visit the city and move around. I could then copy that version 6 times and change the dialogue in each version.
But: Is there an easier way to do this in Quest, with just one version of the city?
Is it possible to maybe have a start screen where they click what mission they are on and then after that, when they visit the rooms and persons, the dialogue choices (still using ConvLib) change accordingly, because Quest knows they're now on Mission 5?

"If Mission 5 then > this dialogue string"
"If Mission 3 then > another dialogue string"
...or something like that?

Thank you.


Hello.

Can I add a number of different dialogues to the same person in the same room?

You should be able to use if/then statements to handle it.

I'll post a blind example of code, which you'll have to interpret to apply in your game.

If that doesn't help, you could post one bit of the code your using for one of the character's dialogue, and I could be more specific.


Is it possible to maybe have a start screen where they click what mission they are on and then after that, when they visit the rooms and persons, the dialogue choices (still using ConvLib) change accordingly, because Quest knows they're now on Mission 5?

Most assuredly, but I don't quite understand what you're doing. (I also don't know that much about ConvLib, but that probably won't matter on this one.)

Does the player start on Mission 1, then progress mission by mission throughout the game until completing the final mission?

If yes, the easy way to handle everything would be setting an integer (number) attribute on the game object. I'd call the attribute current_mission and set it to 1 (or 0, if the game begins without a current mission).

Then, in the code for anything which changes depending upon the current mission (like dialogue, etc.), I'd have:

if (game.mission = 1) {
  //Code here for mission 1
}
else if (game.mission = 2) {
  //Code here for mission 2
}
else if (game.mission = 3) {
  //Code here for mission 3
}
else if (game.mission = 4) {
  //Code here for mission 4
}
else if (game.mission = 5) {
  //Code here for mission 5
}
else {
  //Code for no current mission
}

You could also use a switch script in place of the if/else, if you prefer.


OR, you might want the player to actually be able to choose which mission at the beginning of the game.

If so, you should be able to just use ShowMenu or show menu to give the player the choices.


Sorry, I'm not 100% sure what you're wanting to do, but I think I get the general gist.

If this doesn't help, or if you just need more help, just let us know.

I think ConvLib is one of The Pixie's libraries. If so, and I haven't helped you, Pixie will show up sooner or later with the information you seek.


K.V., thank you. I'll try to clarify:
I'm a teacher. I have a curriculum where my students go on 7 "missions" during the year.
I have created a Quest game with a lot of rooms, like a map of a big city.
As part of my teaching the students will go on these 7 mission in this Quest "city."
I teach the students and then, at some point, ask them to go on Mission 1 on the Quest page (I'll probably have them scan a QR code with their phones).
They then move around, visiting houses/rooms, asking questions, until they find what they are looking for.
That concludes the first mission.
A week later I ask them again to open the Quest page, but this time not on the same Mission as last week, but Mission 2. It's the same "city", with the same inhabitants in the rooms, but with new dialogue because it's a new mission.

Now, I have created all the rooms/houses and placed characters in them.
My question is: Can I, using ConvLib, just have one Quest file where the character dialogues are different depending on what Mission my students are on (hence the need to maybe have a start screen where they enter what Mission they're on), or do I have to create 7 copies of my Quest file to give the characters in the rooms 7 different dialogue strings.

Carsten.


A week later I ask them again to open the Quest page, but this time not on the same Mission as last week, but Mission 2.

Now you got me thinking of weird ways to make sure they select the right mission :)
If you're using a QR code, you could add something like #mission1 to the end of the URI and use javascript to access that within the game. Or if it's a week later, you could have it choose a mission based on the date.

Or, of course, just give them a menu to choose the mission.

But whichever way you do it, I assume you're setting an attribute to the current mission.

You could always use if statements as KV suggests; but if what you're doing is showing and hiding topics, it might be easier to do this when the mission is first selected.

So you could give each topic an extra attribute called "mission" which is a string containing something like 5 or 1;2.
And then after choosing the mission, you could have a script like:

foreach (topic, FilterByType (AllObjects(), "topic")) {
  if (HasString (topic, "mission")) {
    if (not ListContains (Split (topic.mission), mission)) {
      HideTopic (topic)
    }
  }
}

This will disable any topics whose mission attribute doesn't match the mission variable.

If you wanted to hide NPCs and objects as well, you could change it to:

foreach (obj, AllObjects ()) {
  if (HasString (obj, "mission")) {
    if (not ListContains (Split (obj.mission), mission)) {
      if (DoesInherit (obj, "topic")) {
        HideTopic (obj)
      }
      else {
        obj.visible = false
      }
    }
  }
}

This lets you give both topics and objects a mission attribute; any object with a mission attribute will be hidden unless the appropriate mission is selected.
Note that if you want to use this to hide exits, you would want to change AllObjects () to ListCombine (AllObjects(), AllExits()) and I think it should work fine.


Amazing! Thank you, mrangel.
As a test I have created two conversations for a character in one of the rooms and added a 'mission' attribute to each ('1' for the first conversation, '2' for the second).
I'm not a programmer, so what would a simple showMenu script look like, when entering the game, that lets the user choose between Mission 1, 2, 3, 4, 5, 6, or 7 and then Quest knows that the 'mission' attribute now equals the number they chose?
And is it possible to show a dropdown menu where the user chooses a number between 1 and 7?

After choosing the mission I'll add the foreach script you suggested.

Thank you!


I'm not a programmer, so what would a simple showMenu script look like, when entering the game, that lets the user choose between Mission 1, 2, 3, 4, 5, 6, or 7 and then Quest knows that the 'mission' attribute now equals the number they chose?

I'd say something like:

ShowMenu ("Which mission is this?", Split ("1;2;3;4;5;6;7"), false) {
  game.currentmission = result
  foreach (obj, AllObjects ()) {
    if (HasString (obj, "mission")) {
      if (not ListContains (Split (obj.mission), result)) {
        if (DoesInherit (obj, "topic")) {
          HideTopic (obj)
        }
        else {
          obj.visible = false
        }
      }
    }
  }
  // code here to move the player to the appropriate starting room if necessary
}

I set the attribute game.currentmission in case you want to use the attribute for anything later in the game.

A lot of games start the player in an empty "menu room", so that objects visible in the starting room don't show up in the sidebar while they're handling menus like this. If you do that, the last instruction in the script would simply be moving the player to the start room


It works... almost!
If I use the menu and choose 'Mission 2' and then go to my test room where I have created two conversations, Quest correctly only shows the conversation for Mission 2.
That is awesome, but I think I may have inserted your code the wrong place because I keep getting this error:

Error running script: Error compiling expression 'not ListContains (Split (topic.mission), mission)': Unknown object or variable 'mission'

I tried to insert the code in two different places:
Under "game > Start scripts". That gave the above error message. I then inserted it in the first room where the player is under "After entering the room -scripts". Same error message.

This is what I inserted:
ShowMenu ("Which mission is this?", Split ("1;2;3;4;5;6;7"), false) {

  game.currentmission = result
  foreach (obj, AllObjects ()) {
    if (HasString (obj, "mission")) {
      if (not ListContains (Split (obj.mission), result)) {
        if (DoesInherit (obj, "topic")) {
          HideTopic (obj)
        }
        else {
          obj.visible = false
        }
      }
    }
  }
  // code here to move the player to the appropriate starting room if necessary
}
foreach (topic, FilterByType (AllObjects(), "topic")) {
  if (HasString (topic, "mission")) {
    if (not ListContains (Split (topic.mission), mission)) {
      HideTopic (topic)
    }
  }
}

Aah, my bad. I added too much code. I just removed this:

foreach (topic, FilterByType (AllObjects(), "topic")) {
if (HasString (topic, "mission")) {
if (not ListContains (Split (topic.mission), mission)) {
HideTopic (topic)
}
}
}


Either location should work.

The first script I posted would go inside the ShowMenu block if you're using a menu. So when I posted the ShowMenu script in my latest post, I included it (just with mission changed to result because it's a menu)

The error is coming because you have a duplicate copy of the script.

ShowMenu ("Which mission is this?", Split ("1;2;3;4;5;6;7"), false) {

  game.currentmission = result
  foreach (obj, AllObjects ()) {
    if (HasString (obj, "mission")) {
      if (not ListContains (Split (obj.mission), result)) {
        if (DoesInherit (obj, "topic")) {
          HideTopic (obj)
        }
        else {
          obj.visible = false
        }
      }
    }
  }
  // code here to move the player to the appropriate starting room if necessary
}
foreach (topic, FilterByType (AllObjects(), "topic")) {
  if (HasString (topic, "mission")) {
    if (not ListContains (Split (topic.mission), mission)) {
      HideTopic (topic)
    }
  }
}

Also, because it's been buzzing around in my head for a while, I thought I'd give this a shot off the top of my head:

JS.eval("$.each(window.location.hash.match(/(?<=^#mission)\\d+/i), function (a,i) { ASLEvent('ShowMenuResponse',i);})")

Placed immediately after the ShowMenu block (not inside it), it should cause a menu option to be chosen automatically if you add #mission2 or similar to the end of the game's address. That way if you're giving students a QR code for the game, you can make a code which selects the right mission automatically.


mrangel, thank you for going above and beyond on this!
I appreciate your help and the people on this Forum.
I look forward to testing your JavaScript later today when I create a couple of QR codes.

Carsten.


mrangel, I couldn't wait so I tested your JavaScript right away:
It's working!
I uploaded the game, and when I add #mission2 or similar to the URL the script makes sure that the correct dialogue strings are opened in the test room.

Thank you again!


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

Support

Forums