Conversation password

I'm using the Conversations Library.
I'd like the user to insert a correct password when they click a conversation item:

Using the Conversations Library I have created 4 conversation topics.
When the user click a topic, I want them to insert a correct password before the conversation is shown.
Can someone help me with that?

I tried opening a topic (an object, as it is) and added an initialisation script asking for a password but that didn't work, and I'm also quite sure I didn't write a correct code anyways.

Carsten.


Hello.

The initialisation script only runs once when the game loads.


Can you post this part of your current code so we can see exactly what we're working with?


Absolutely, I have only just begun creating my game.
Here you have the first 'room' (a garden). They meet a man.
They click 'talk to' and are shown - so far - two conversation topics.
What I need is that when they click a topic a prompt asks them to fill in the correct password and only after that the conversation is shown.

  <object name="have">
    <inherit name="editor_room" />
    <isroom />
    <description><![CDATA[{img:014-creation.jpg}<br/>It looks like a big garden.]]></description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="mand">
      <inherit name="editor_object" />
      <inherit name="namedmale" />
      <inherit name="talkingchar" />
      <exchange type="string"></exchange>
      <forcedconversations />
      <object name="formål adam og eva gartner 1">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <inherit name="switchable" />
        <inherit name="container_closed" />
        <alias>Ask the man: Who are you?</alias>
        <hideafter type="boolean">false</hideafter>
        <exchange><![CDATA[Hi, my name is Adam.<br/>]]></exchange>
        <visible />
        <attr name="feature_startscript" type="boolean">false</attr>
        <attr name="feature_switchable" type="boolean">false</attr>
        <attr name="feature_container" type="boolean">false</attr>
        <nowshow type="stringlist">
          <value>formål adam og eva gartner 11</value>
        </nowshow>
        <attr name="_initialise_" type="script">
        </attr>
      </object>
      <object name="formål adam og eva gartner 2">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <alias>Ask the man: What are you doing?</alias>
        <hideafter type="boolean">false</hideafter>
        <exchange>I'm working</exchange>
      </object>
    </object>
  </object>
</asl>

They click 'talk to' and are shown - so far - two conversation topics.
What I need is that when they click a topic a prompt asks them to fill in the correct password and only after that the conversation is shown.

Sounds like you could modify your talk to stuff. . .


EDIT

Incorrect information removed for the greater good.

PS

Don't change anything in the library file itself. Do this:

https://docs.textadventures.co.uk/quest/overriding.html


Thank you, K.V.
I did what you wrote - I hope - but it doesn't seem to do anything:
1: I right-clicked the first topic and added a password string and as value entered the password.
2: I clicked the bottom-left corner, Filter, and searched for ShowTopic.
3: I found it and created a copy of it.
4: I then entered the script you gave.

Re. #1, see screenshot (link)
Re. #2-4, see screenshot (link)


Ah, you are correct.

Sorry about that. I usually make a note when I post untested code.


EDIT

SCROLL DOWN FOR THE INFORMATION


Thank you! Exactly what I wanted.
Thank you very much for your help.
Btw., I will be using this game as part of a board game, similar to the new Destinies game that combines an app with a classic gameboard. The one entering the password will be a Game Master, who makes sure the players pay the cost of asking questions to NPCs.

Carsten.


The one entering the password will be a Game Master, who makes sure the players pay the cost of asking questions to NPCs.

Did you get that part figured out?


EDIT

SCROLL DOWN FOR THE INFORMATION


If you need help, let us know.

Happy gaming!


K.V., one more thing:
For some reason the game seems to skip the first question's conversation text and instead show the text from the second question. This happens after your otherwise excellent code has been added.
Can you see why that happens?
I click the first question > Enter the correct password > The game shows the second question's conversation text instead of the first.


Oh, whoops!

I guess I should have been paying more attention while testing. I didn't actually read it when it printed the message after entering the password.

I just tried to fix it for 10 minutes, and something about the foreach loop inside of the ShowMenu block is kicking my butt (or at least I think that's what's kicking my butt).

Pixie or mrangel or someone more knowledgeable than yours truly will probably chime in soon. . .


K.V., it is very kind of you to help me so much! I appreciate that!
While I'm waiting to hear what Pixie or mrangel has to say about the 'foreach' loop, I have one more question to you:

I would like the player to be able to enter the next room only after they have asked a specific question:
The player clicks the questions, and one of the questions has a follow-up question. The next room (they're in a garden, so 'the next part of the garden') is only available after they have clicked that particular question.

Can you help me with this?

Carsten.


Im in love with this game Drift Hunters !! Keep up the amazing work!❤


EDIT

SCROLL DOWN FOR THE INFORMATION


I am not sure I get what is happening here.

When a topic is used, if it has a "talk" script, that will get run; I would guess that is better than overriding Converse.

That said, I do not get when the password is used. Is it part of one specific topic? Or is it required for any topic (in which case, overriding Converse may be best)?


When a topic is used, if it has a "talk" script, that will get run; I would guess that is better than overriding Converse.

Oh!

:o)

I just needed to scroll down to see there was a place for a script.

Duh!


This updated example game (updated to version 0.4) seems to work the way I think we want this to work:

<!--Saved by Quest 5.8.7753.35184-->
<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <include ref="ConvLib.aslx" />
  <game name="example1">
    <gameid>c9d08582-b646-4be2-ab17-06937599abb6</gameid>
    <version>0.5</version>
    <firstpublished>2021</firstpublished>
  </game>
  <object name="have">
    <inherit name="editor_room" />
    <isroom />
    <description><![CDATA[{img:014-creation.jpg}<br/>It looks like a big garden.]]></description>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="mand">
      <inherit name="editor_object" />
      <inherit name="namedmale" />
      <inherit name="talkingchar" />
      <exchange type="string"></exchange>
      <forcedconversations />
      <object name="formål adam og eva gartner 1">
        <inherit name="editor_object" />
        <inherit name="startingtopic" />
        <inherit name="switchable" />
        <inherit name="container_closed" />
        <alias>Ask the man: Who are you?</alias>
        <password>12345</password>
        <hideafter />
        <exchange type="string"></exchange>
        <visible />
        <attr name="feature_startscript" type="boolean">false</attr>
        <attr name="feature_switchable" type="boolean">false</attr>
        <attr name="feature_container" type="boolean">false</attr>
        <nowshow type="stringlist">
          <value>formål adam og eva gartner 2</value>
        </nowshow>
        <talk type="script"><![CDATA[
          OutputTextNoBr ("<span class='password-prompt'>Please enter the password.</span>")
          get input {
            if (result = this.password) {
              JS.uiHide (".password-prompt")
              msg ("Hi, my name is Adam.")
            }
            else {
              msg ("<br/>Incorrect password.")
            }
          }
        ]]></talk>
      </object>
      <object name="formål adam og eva gartner 2">
        <inherit name="editor_object" />
        <inherit name="topic" />
        <alias>Ask the man: What are you doing?</alias>
        <password>56789</password>
        <hideafter type="boolean">false</hideafter>
        <exchange type="string"></exchange>
        <talk type="script"><![CDATA[
          OutputTextNoBr ("<span class='password-prompt'>Please enter the password.</span>")
          get input {
            if (result = this.password) {
              JS.uiHide (".password-prompt")
              msg ("I'm working.")
              continue_to_garden.visible = true
              msg ("<br/>You have unlocked a new exit!")
            }
            else {
              msg ("<br/>Incorrect password.")
            }
          }
        ]]></talk>
      </object>
    </object>
    <exit name="continue_to_garden" alias="north" to="have2">
      <inherit name="northdirection" />
      <visible type="boolean">false</visible>
    </exit>
  </object>
  <object name="have2">
    <inherit name="editor_room" />
    <exit alias="south" to="have">
      <inherit name="southdirection" />
    </exit>
  </object>
</asl>

K.V., that looks good. I tested the script in a new game.
Can you help me place the code in the correct place:

1: Do I place it here (screenshot)

2: And is it this part of your code that I have to insert:

OutputTextNoBr ("<span class='password-prompt'>Please enter the password.</span>")
          get input {
            if (result = this.password) {
              JS.uiHide (".password-prompt")
              msg ("Hi, my name is Adam.")
            }
            else {
              msg ("Incorrect password.")
            }
          }

Do I place it here (screenshot)

You can right-click this link and save the file: https://gist.githubusercontent.com/KVonGit/5035562176805eb5e09d83aa8b01a416/raw/63d8931d6bac409c45ea768f4580f9b73cca28de/example1.aslx

Open that file with Quest, and you'll be able to see the example live in the editor.


I used your objects from your code to make it easier to see what the code is doing.


I am not being mean at all here, but you are wanting to include some slightly complex stuff in your first text adventure.

I highly (and strongly, very strongly) advise you complete the tutorial in its entirety before really getting into creating your game.

https://docs.textadventures.co.uk/quest/tutorial/creating_a_simple_game.html

The process might seem tedious, but once you have created a game following the tutorial, you will know 90% of what you will need to know to create your own game. Plus, you will be familiar with a lot of the inner-workings of Quest.


is it this part of your code that I have to insert:

That is the block of code which belongs in the first topic's script. I don't know what will happen when you have text in the field above that script, though.

Also, I updated the code in that post. The big change is this in both scripts: msg ("<br/>Incorrect password.")


If you plan to have more than a handful of topics in your game, you will probably want to alter that script to use it in a function. That way, you won't have to paste the same code over and over again.

You will learn about functions (and much more) from the tutorial.


K.V., thank you for going above and beyond! Opening your code in the editor helped me see how it is done and where the scripts and commands are placed.
And thank you for pointing me to the fact that I have jumped into deep waters trying to already create a game that needs complex code to function a certain way.

Carsten.


I have jumped into deep waters trying to already create a game that needs complex code to function a certain way.

We all do that.

:)


The tutorial seems like it might take forever at first, but it really only takes an hour or so to get through it.


A simple text adventure has things you can pick up and drop, no matter what, and it has exits that work no matter what. The text that prints is always the same, too -- unconditionally.

A good, simple text adventure can be difficult to create (mostly due to time-consumption).

...but, once you have introduced conditional actions (and/or exits), you have created a monster which will seldom behave as you would initially expect. Plus, once you get one thing working, you will later find that made something else behave unexpectedly.

I enjoy troubleshooting, but it gets a little frustrating when I don't know how everything is supposed to work in the first place. Also, I don't really know what to ask or what to share when seeking assistance when I'm working with something new.

The tutorial will enlighten you. You won't know how to do everything, but you'll know what you want -- which, as G.I. Joe will tell you (repeatedly, whether you want him to or not), "knowing is half the battle."


If you have any questions, be sure to ask!

I wasn't trying to dissuade from that. I just realized that I had written a lot of code that might end up in your game, and my code examples are more like a rough sketch of how to start coding things than they are finalized version to use in an otherwise carefully crafted text adventure.


edited, from two to one question
K.V., thank you.
I have completed the tutorial and I have created my first game! Since I'm using this as part of a board game I am going to copy that game several times and insert new characters and conversations in each. The players scan a QR code and open the game/conversation corresponding to where they are at in the board game.
While I created the first game I came across one thing that I hope you can help me with:

1: Can the game give a warning when the player has used too much time?
I'm using the option to track time, as described here:
http://docs.textadventures.co.uk/quest/time.html
It's working just fine, but I wondered if it is possible to add something that will give a warning when the player has used too much time? Maybe even, after the warning, stop the game, making it impossible to do more.


Hello!

This is probably your time turn script:

if (not HasInt(game, "time")) {
  game.time = 60 * 10 + 23
  if (not HasAttribute(game, "statusattributes")) {
    game.statusattributes = NewStringDictionary()
  }
  dictionary add (game.statusattributes, "timeasstring", "Time: !")
}
else if (not game.notarealturn) {
  game.time = game.time + 1
}
hours = (game.time / 60) % 24
minutes = game.time % 60
if (hours = 0 and minutes = 0) {
  game.timeasstring = "Midnight"
}
else if (hours = 12 and minutes = 0) {
  game.timeasstring = "Noon"
}
else if (hours < 12) {
  game.timeasstring = hours + ":" + minutes + " am"
}
else {
  game.timeasstring = (hours - 12) + ":" + minutes + " pm"
}
game.notarealturn = false

Okay, so, game.time returns the time the game has been played in minutes.

If I want the game to end an hour of game-time after play begins, I want to know if (game.time > 60).

If I wanted to do something when an hour had passed, I'd add this code after line 9 of the turn script:

if (not HasInt(game, "time")) {
  game.time = 60 * 10 + 23
  if (not HasAttribute(game, "statusattributes")) {
    game.statusattributes = NewStringDictionary()
  }
  dictionary add (game.statusattributes, "timeasstring", "Time: !")
}
else if (not game.notarealturn) {
  game.time = game.time + 1
  // ADDED CODE BEGINS
  if (game.time > 60){
    CustomFinishScript
  }
  // ADDED CODE ENDS
}
hours = (game.time / 60) % 24
minutes = game.time % 60
if (hours = 0 and minutes = 0) {
  game.timeasstring = "Midnight"
}
else if (hours = 12 and minutes = 0) {
  game.timeasstring = "Noon"
}
else if (hours < 12) {
  game.timeasstring = hours + ":" + minutes + " am"
}
else {
  game.timeasstring = (hours - 12) + ":" + minutes + " pm"
}
game.notarealturn = false

Now, it will call a function named CustomFinishScript when the game-time hits 61 minutes. You must create that function.

To tell the player they've taken too long and end the game, make the script of your CustomFinishScript something like this:

msg("You suck, and the game is over. Don't dawdle so much next time!")
finish

If you wanted to have a warning at 50 minutes or something, modify the added code something like this:

  // ADDED CODE BEGINS
  if (game.time = 50) {
    msg("")
    msg("You only have 10 minutes of game-time left!")
    msg("")
  }
  if (game.time > 60){
    CustomFinishScript
  }
  // ADDED CODE ENDS

Alternatively, you could make a function to handle the 50 minute stuff.

You could also completely leave this turn script as is, and you could create a totally separate turn script with only the added code. That would do the same thing, too, but with more chance of something misfiring (although the chance would be very low).


That's awesome, thank you!
It works like a charm.
I noticed one thing: The timer only shows how many minutes/hours have passed whenever the player goes to a new room.
The player is in a room and converses with a character there, but it's only after they choose to go to the next room that the scripts show the time that has passed.
Maybe it's because Quest does not count clicking a conversation topic as a 'turn' or that only entering a new room is defined as a turn?
Is it possible to show -1 for everything they do in a room? For example: They see 4 conversation topics. They click one and the script shows: 1 minute/hour passed. They click another and again the script shows: 1 minute/hour passed.


The timer only shows how many minutes/hours have passed whenever the player goes to a new room.

How are you telling Quest to print the time?

Is it in the room descriptions? That's what it sounds like without being able to see your code. If that is the case, room descriptions only print when you change rooms or use the LOOK command.


If you want the time to print every turn, add code to the turn script to have it print the time when the turn script runs.


Thank you!
I just tested the game using my phone's browsers. I can see that I run into the same problem others have mentioned here in the Forum: The mobile UI. The player using a phone can't see the sidebar with the countdown, inventory, etc.
They can only see it if they click the + next to the command bar.
I have read through some of the posts on the Forum about this, and as far as I can see there's no real workaround for this yet?
I found a post about moving the sidebar to the bottom of the screen, and there was some JavaScript but as far as I can see it's not working. I tried to upload the game after adding the JavaScript, but it doesn't seem to do anything?


Yeah. . .

When I first found Quest, I thought the UI was the bee's knees. Now, I don't even use hyperlinks or panes or anything. All that cross-browser compatibility stuff is too frustrating for me, and, as soon as you get an idea on how to handle every possibility, the browsers all get updates that mess something else up.

If I wanted the player to see the time and all that each turn, I would have a turn script that printed the information along with all the other in-game text.


Note that Quest is not the culprit (this time), either.

This is just what you have to deal with when publishing websites (HTML, CSS, and JS), which is what a Quest game mostly is.


Log in to post a reply.

Support

Forums