Having trouble creating a message which includes an object link [Solved!]

I want to print a message where the captain (object) is a clickable hyperlink (with a Look At verb option). I have hyperlinks enabled for the game and they work fine elsewhere, but I can't seem to get this one message to show up correctly. I've tried:

msg ("The vital sign sensors all indicate that {object:captain} is stable.")
msg ("The vital sign sensors all indicate that <object verbs=\"Look at/Examine\">Captain Picker</object> is stable.")
captainObjDesc = FormatObjectList ("The vital sign sensors all indicate that ", captain.parent, "and", " is stable.")
msg (captainObjDesc)

But all three approaches yield the same result:

The vital sign sensors all indicate that Captain Picker is stable.
The vital sign sensors all indicate that Captain Picker is stable.
The vital sign sensors all indicate that Captain Picker is stable.

Where Captain Picker is not show as a hyperlink...

What am I doing wrong?


Do you have hyperlinks enabled for the game? The {object:captain} notation (which FormatObjectList outputs) only works if game.enablehyperlinks is true. (In the GUI, I think this is a tickbox on the Display tab of the game)

If you want to do it without setting the enablehyperlinks flag for some reason, you might be able to use something like:

msg ("The vital sign sensors all indicate that <a id=\"" + ProcessTextCommand_GetNextLinkId() + "\" class=\"cmdlink elementmenu\" data-elementid=\"captain\">Captain Picker</a> is stable.")

I don't know if the link will work properly in this case; but it might.


Mr. Parser

Is the captain object in the same room as the PC AND visible?

If not, the "Captain Picker" hyperlink(s) will not be active in your first and last msg().


Your second msg() will never create a hyperlink. You could use something like this for the link <a style="color:Blue" class="cmdlink elementmenu" data-elementid="captain" data-verbs="Look at">Captain Picker</a>, but this would still only work if the captain object were visible and in the same room as the player.


Yes, hyperlinks are enabled, I use them all over the place.

The object is set to visible, but it is inside an Openable/Closable container. I'm essentially trying to create a 'list children when looked at' script for the container. Maybe the fact that it is in the container and not directly in the room is the problem?

I'm using Openable/Closable instead of a normal container because it was the only way I found to print a custom message when the player tries to open the container when I don't want them to succeed. I don't want to show "You can't open it." or "It is locked."


Mr. Parser

The object is set to visible, but it is inside an Openable/Closable container.

If that container is closed and not transparent, the captain object is technically visible, but Quest treats it as if it were not visible unless the container is open (or transparent).

The player cannot interact with an object inside of a closed container, unless you add the object to scope (which I advise against).

http://docs.textadventures.co.uk/quest/advanced_scope.html


I'm using Openable/Closable instead of a normal container because it was the only way I found to print a custom message when the player tries to open the container when I don't want them to succeed. I don't want to show "You can't open it." or "It is locked."

I advise against this, too (mostly), but you can modify the attribute openscript, printing whatever message you desire. Just make sure to modify isopen yourself when applicable!

...and you can easily change the nokeymessage attribute from the GUI.

Here is an example game:

You are in a room.
You can see a captain holder and a key.

> open captain holder
This is my custom LOCKED message!

> take key
You pick it up.

> unlock holder
Unlocked.

> l
You are in a room.
You can see a captain holder.

> open holder
This is my custom "CAN'T OPEN" message!

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="captainholder">
    <gameid>5aeedd0b-27b3-498d-a2f5-ce461d6726d7</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="captain holder">
      <inherit name="editor_object" />
      <inherit name="container_closed" />
      <inherit name="container_lockable" />
      <feature_container />
      <open />
      <openscript type="script">
        if (not this.locked) {
          msg ("This is my custom \"CAN'T OPEN\" message!")
        }
        else {
          msg ("This is my custom LOCKED message!")
        }
      </openscript>
      <keycount type="int">1</keycount>
      <nokeymessage>This is my custom "CAN'T UNLOCK THIS" message.</nokeymessage>
      <key type="object">key</key>
      <take />
      <autounlock type="boolean">false</autounlock>
      <autoopen type="boolean">false</autoopen>
      <listchildren />
      <object name="captain">
        <inherit name="editor_object" />
        <inherit name="namedmale" />
        <alias>Captain Picker</alias>
      </object>
    </object>
    <object name="key">
      <inherit name="editor_object" />
      <take />
    </object>
  </object>
</asl>

You can never open the captain holder in this example, but you could add code to the openscript to handle it, OR change the openscript when a certain in-game event takes place.

...and you will still have the issue with the captain's hyperlink when the container is closed and not transparent.


NOTE: If you make the container transparent or add the captain to the advanced scope script, you will be opening yourself up for more default messages which will print during play.


I was going to suggest taking the captain out of the container and making him scenery; or making the container transparent.


Mr. Parser

I was going to suggest taking the captain out of the container and making him scenery

This is the best bet, IMHO.


Thank you for your help!

Is the nokeymessage attribute for the entire game? I only want to change the message for this one container...

From your example, I think changing openscript is what I was trying to achieve (the wrong way). It looks like that can be changed for just the one container? But I'm a bit confused as to where I need to put the code.

I changed the container type back to Closed Container, so that I get "List children when object is looked at or opened", which works fine. Now where do I configure the openscript (I'm using the web editor) to change the "It is locked." message?

I don't understand what making the captain into scenery would achieve... I want him in the container so that he can be seen inside (when the container is looked at) and then looked at himself, but not otherwise (until he comes out of the container later on). If he is scenery outside the container, he can't be looked at right?


I've added an Initialisation Script for the captain's container (captain_pod), which looks like this:

captain_pod.openscript => {
 if (not this.locked) {
    msg ("This is my custom \"CAN'T OPEN\" message!")
  } else {
    msg ("An error chimes sounds from the ship's computer.<br/>\"Life support at critical levels. Restore main power in order to revive additional crew members.\"")
  }
}

This seems to be working, although I have to do some more testing.

Does this look right?


After further testing, this is working! Thanks for your help!


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

Support

Forums