Turn room descriptions on and off

Hey. Is there code to turn room descriptions on and off during play?
Thanks.


You could set the room description as a {once:.....} then you would only see the description on your first entry...


You can certainly due as DL suggests, or you can use a If to check for a set flag. It all depends on what you want to do. If the player is carrying a certain item, set flag and when they enter that room you can print description 1 and if not then description 2. Just a thought.


K.V.

DL's and XM's suggestions are safest.

You could also do this to actually turn room descriptions on and off:


Add this line to the game's start script (IMPORTANT!):

// Backup the game's initial room description setting.
game.autodescription_description_backup = game.autodescription_description

To toggle off room descriptions:

// Turn off the room descriptions for the ENTIRE GAME.
game.autodescription_description = 0

To turn room descriptions back to the game's initial setting (this depends on the line added to the start script; the value is 4 by default, by the way):

game.autodescription_description = game.autodescription_description_backup 

To add to KV's reply, everything you set on the game object in the editor is an attribute on the game object. If you are using the desktop version, you can see them all listed on the Attributes tab. Some only get used when the game starts (many on the Display tab and all on the Interface tab), but the rest can be changed during play to change how your game goes.


Uh, K.V., I tried what you said, But I don't want to turn of descriptions right at the start.


Nevermind, I had automatically generate descriptions on, when I thought they were off...


I think your looking for something like this...
Add an ondescription attribute to the room, that is the same as the description attribute at beginning of game.
Then when you want to turn it off use:

room.description = 0

Then to turn it on use:

room.description = onroomdescription

If the room has objects that contain in room descriptions, this will not stop their descriptions from showing up.


"Add an ondescription attribute to the room"

How do I do this?


On the left side of quest you see a tree to hold rooms and objects.
click on the room in question
now on the main page of quest with all the tabs, click attributes
on the new page look at the box titled attributes, click add
A box will pop up asking for a name, type in onroomdescription
this will add the attribute.
Another box will appear under the attributes box that says string. it is a drop down box but the description you add under it will be a string so leave it saying string.
add the description you want the room to have. Just copy the one you use on the room tab under description.
these will be the same for now until you want to turn off the description.

obviously you want to turn on and off during game play.

use this line in your script to turn on

room.enter  = msg("{room.onroomdescription"}

that will print the onroomdescription after entering the room. Don't type room, type the name of the room you want.

NOTE: Newbie writing on the fly here so scripts may be faulty.

Somebody tell us if I'm even close here!


To toggle the ON/OFF settings of room descriptions, I simply insert one of the following two lines as needed:

Descriptions off:

SetObjectFlagOff (game, "autodescription")

Descriptions on:

SetObjectFlagOn(game, "autodescription")

Well, Proudly Humble's code worked.

Thanks!


Sweet!


K.V.

My room descriptions still print after this: SetObjectFlagOff (game, "autodescription"), but it doesn't show the room name, exits lists, or objects list -- just the room description.

I believe I was confused as to what our purposes were, but, I see the post stating that Proudly Humble's code does what you want, so that is sweet.


K.V.

For completion's sake:

There are four, individual attributes on the game during play which effect the order of each of these:

Displayed text Attribute name Default value (integer)
Room Name: autodescription_youarein 1
Exits List: autodescription_youcango 2
Objects List: autodescription_youcansee 3
Description: autodescription_description 4

You can set any one of these to 0 to turn them off during play.


Example:

// First, backup the current setting:
game.autodescription_description_backup = game.autodescription_description
// Now, change the value to 0, turning it off:
game.autodescription_description = 0

That turns off the actual room description (the text you enter under the description of the room).

To turn it back on:

// Check to see if the setting has been backed up.
if (HasAttribute(game, "autodescription_description_backup")){
  // The setting has been backed up, so we use that attribute to reset it.
  game.autodescription_description = game.autodescription_description_backup
}
else {
  // The setting has not been backed up, so we set it to Quest's default value.
  game.autodescription_description = 4
}
// Now, make sure it is on. If it is 0 at this point, set to Quest's default value.
if(autodescription_description = 0){
  //  It is still disabled, so set to Quest's default value.
  game.autodescription_description = 4
}
  

To turn off the exits list:

// First, backup the current setting:
game.autodescription_youcango_backup = game.autodescription_youcango
// Now, change the value to 0, turning it off:
game.autodescription_youcango = 0

I'd be leery of turning off the objects list, but I'm sure everyone can see how to manipulate it now.


To turn off everything which is automatically generated by Quest (the room name, the objects list, and the exits list, but NOT THE ROOM DESCRIPTIONS YOU HAVE ENTERED FOR ANY ROOMS):

I advise against this. If you disable the automatically generated Objects List, and the player drops something, that object will more than likely be lost forever unless the Places and Objects pane is visible.

game.autodescription = false

To turn them back on:

game.autodescription = true

Wait, if you can turn the auto descriptions back on, what's the problem? Why do you need to warn against it.

Also, I'm turning off the auto descriptions for cut scenes. I need the player to stay in place during important cut scenes in the new game I'm working on.

Nice information by the way! I figured it out eventually, but only after trying Proudly Humble's solution, and then reading your posts a second time.


K.V.

Wait, if you can turn the auto descriptions back on, what's the problem?

I assume they are being turned off before entering a certain room, then being turned back on when exiting that same room.

So, if the player were to drop something in that room (and the Places and Objects pane wasn't displayed), nothing would ever print to let the player know that the object was in that room. Hence, the object could be lost forever, unless the player entered GET ALL in that room (or simply remembered dropping it there).


I'm turning off the auto descriptions for cut scenes. I need the player to stay in place during important cut scenes in the new game I'm working on.

I'd probably create a room for each cut scene, then do something to initiate the cut scene:

(revision 2)

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Cut Scenes">
    <gameid>6948c387-223a-4f55-b739-4c9a8b044eb0</gameid>
    <version>0.0.2</version>
    <firstpublished>2018</firstpublished>
    <start type="script"><![CDATA[
      msg ("<hr>Image from <a href='http://backtothefuture.wikia.com/wiki/File:BTTF-game-SS-09.jpg'>http://backtothefuture.wikia.com/wiki/File:BTTF-game-SS-09.jpg</a>.<hr>")
    ]]></start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="Flux Capacitor">
      <inherit name="editor_object" />
      <take />
      <ontake type="script">
        firsttime {
          lastroom = game.pov.parent
          MoveObject (game.pov, cutscene1)
          wait {
            MoveObject (game.pov, lastroom)
          }
        }
      </ontake>
      <look><![CDATA[<img width='100%' src='https://vignette.wikia.nocookie.net/bttf/images/b/b6/BTTF-game-SS-09.jpg/revision/latest/scale-to-width-down/300?cb=20101214205519'/>]]></look>
      <listalias><![CDATA[<hr/><img width='100%'  src='https://vignette.wikia.nocookie.net/bttf/images/b/b6/BTTF-game-SS-09.jpg/revision/latest/scale-to-width-down/300?cb=20101214205519'/>Flux Capacitor<hr/>]]></listalias>
    </object>
    <object name="large table">
      <inherit name="editor_object" />
      <inherit name="surface" />
      <takemsg>It's too big and heavy.</takemsg>
      <feature_container />
      <listchildren />
    </object>
  </object>
  <object name="cutscene1">
    <inherit name="editor_room" />
    <alias>Your House - November 5, 1955</alias>
    <description><![CDATA[You are in your bathroom.<br/><br/>You slip and fall, hitting your head on the sink and knocking yourself out.<br/><br/>When you awaken, you have a vision!  The Flux Capacitor!<br/><br/>You don't know what it can do, but you now know how to create it!]]></description>
    <beforeenter type="script">
      game.autodescription_youarein_useprefix = false
      JS.uiHide ("#gamePanes")
    </beforeenter>
    <onexit type="script">
      game.autodescription_youarein_useprefix = false
      JS.uiShow ("#gamePanes")
    </onexit>
    <usedefaultprefix type="boolean">false</usedefaultprefix>
  </object>
</asl>

Nice information by the way!

Thank ya', thank ya'.


I figured it out eventually, but only after trying Proudly Humble's solution, and then reading your posts a second time.

Look at you go!

You may end up being The Pixie's successor one day!


Well, of course you have to be careful when you change any setting like this, or else things may go wrong. But I'll have to admit, I was surprised to find out that setting game.autodescription to "false" prevented the "look" command from working properly. I'll make a mental note of that.

I've only used the method I suggested for myself to temporarily move the player from room A to room B, then back to room A, so as to prevent certain secondary scripts from triggering an unwanted domino effect (it's a lot easier than a bunch of "if" codes). For example:

  1. script is triggered
  2. autodescription is set to "false"
  3. player is moved to (empty) room B
  4. scripts run without accidentally triggering other scripts
  5. player is returned to room A
  6. autodescription set to "true"
  7. game resumes as normal

This method could be used for a cutscene if you wanted make it appear that the player never changes rooms. Whether or not this would be a good idea totally depends on what your intent is. As others have pointed out, there are probably other ways to accomplish what you want. But since my suggestion worked for you, I'm glad. Just be sure that autodescription is set back to "true" before the game resumes.


K.V.

As a safeguard, you could do this:

When the script is triggered:

game.autodescription = false
if (not HasAttribute(drop, "scriptbackup")) {
  drop.scriptbackup = drop.script
}
drop.script => {
  msg ("You can't drop anything right now.")
}

Before resuming play:

game.autodescription = true
drop.script = drop.scriptbackup

It wasn't my intention to down your suggestion, by the way, PH.

I was just warning everyone about the danger of turning off the automatically generated objects list to save someone the troubles I ran into.

I know you probably know that already, but I want to be sure no one thinks I'm being unpleasant or anything.

(I only posted the big, red warning because I was posting the code, and I don't want anyone having problems because of something I've posted (without warning them about it first, ha-ha!).)


The look commands work for me.

The thing is, I mostly just want to disable the "exits are west" messages. When I am locking the exits, I don't want the player to try to be running off.

But everything is working fine.


It's fine, K.V. I certainly agree that the setting should be left alone unless it is reset to true before the player enters the next command, or if the potential consequences to the player dropping things are intentional.

I thought surely the look command would take care of the issue where players might "lose" items, so I opened up a file, changed the default setting of game.autodescription to false to see what might happen for myself if the setting remained false. As I expected, there were no room status messages per turn, but when I tried looking, I got a null result (no error messages, just no response). This proved your point of how things can go wrong when you play with this setting.


Personally, I am open to suggestions on what I can do differently.

Disabling the descriptions are simply an aesthetic change. I would like it if I can do all that without having to move the player to a different room, and then sending them back. I also want to keep the drop command. But I don't see a work around.


jmnevil54

I may have missed the point of what you want to do, but I think you want to keep the player in the room? The best way is to either lock all the exits or set them all to invisible. There is a brief instruction towards the end of this page, in the section "Room scripts".
http://docs.textadventures.co.uk/quest/exits.html


This method could be used for a cutscene if you wanted make it appear that the player never changes rooms.

If doing that, beware of triggering a room's enter or exit scripts anyway. In that circumstance, I find it easier to us:

temp_variable = player.changedparent
player.changedparent = null
player.parent = Where you want to move them
player.changedparent = temp_variable

Allows you to move a player without triggering any scripts, or the description.

The thing is, I mostly just want to disable the "exits are west" messages. When I am locking the exits, I don't want the player to try to be running off.

There's a variable for that. I think it's game.autodescriptionyoucango or something like that. Set to zero to disable just part of the room description.
Or make all the exits invisible.


game.autodescriptionyoucango
Is this correct?


K.V.

game.autodescription_youcango

http://textadventures.co.uk/forum/quest/topic/0unl3g_pp0yok1_ppqq4sw/turn-room-descriptions-on-and-off#1e8f1906-0610-4507-9624-1466cb985faf


K.V.

...but The Pixie is right:

http://textadventures.co.uk/forum/quest/topic/0unl3g_pp0yok1_ppqq4sw/turn-room-descriptions-on-and-off#4bfcb02c-1daa-414d-87ce-5e144a23187b

http://docs.textadventures.co.uk/quest/functions/corelibrary/scopeunlockedexitsforroom.html


Here's an example in which the available unlocked exits are made invisible (meaning they don't exist in the game) for 5 seconds:


<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Kill the Exits">
    <gameid>b9c1fd33-392e-47ee-b345-19685f50f7f3</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
    <start type="script">
    </start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <beforefirstenter type="script">
    </beforefirstenter>
    <enter type="script">
      msg ("This is the cutscene!")
      SetMakeCurrentExitsInvisibleTimeout (5)
    </enter>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="north" to="northern room">
      <inherit name="northdirection" />
    </exit>
    <exit alias="west" to="wetern room">
      <inherit name="westdirection" />
    </exit>
    <exit alias="east" to="eastern room">
      <inherit name="eastdirection" />
    </exit>
    <exit alias="south" to="southern room">
      <inherit name="southdirection" />
    </exit>
    <command name="test">
      <pattern>test</pattern>
      <script>
      </script>
    </command>
  </object>
  <object name="northern room">
    <inherit name="editor_room" />
    <exit alias="south" to="room">
      <inherit name="southdirection" />
    </exit>
  </object>
  <object name="southern room">
    <inherit name="editor_room" />
    <exit alias="north" to="room">
      <inherit name="northdirection" />
    </exit>
  </object>
  <object name="eastern room">
    <inherit name="editor_room" />
    <exit alias="west" to="room">
      <inherit name="westdirection" />
    </exit>
  </object>
  <object name="wetern room">
    <inherit name="editor_room" />
    <exit alias="east" to="room">
      <inherit name="eastdirection" />
    </exit>
  </object>
  <function name="MakeCurrentExitsVisible"><![CDATA[
    if (not HasAttribute(game, "current_exits")) {
      // Do nothing.
    }
    else if (not ListCount(game.current_exits)<1) {
      foreach (exit, game.current_exits) {
        exit.visible = true
      }
      game.current_exits = NewObjectList()
      msg ("Play has resumed.")
    }
  ]]></function>
  <function name="MakeCurrentExitsInvisible">
    if (not HasAttribute(game, "current_exits")) {
      game.current_exits = NewObjectList()
    }
    game.current_exits = ScopeUnlockedExitsForRoom(game.pov.parent)
    foreach (exit, game.current_exits) {
      exit.visible = false
    }
  </function>
  <function name="SetMakeCurrentExitsInvisibleTimeout" parameters="time">
    MakeCurrentExitsInvisible
    SetTimeout (time) {
      MakeCurrentExitsVisible
    }
  </function>
</asl>

K.V.

Bonus function:

To use:

SetHideCommandBarAndPanesTimeout(interval)

Example: SetHideCommandBarAndPanesTimeout(10)

  <function name="SetHideCommandBarAndPanesTimeout" parameters="time">
    JS.uiHide ("#txtCommand")
    JS.uiHide ("#gamePanes")
    SetTimeout (time) {
      JS.uiShow ("#txtCommand")
      JS.uiShow ("#gamePanes")
    }
  </function>

K.V.

That's a nice script, by the way, MrAngel.

(I'm saving it in my archive: Cool Quest Scripts.)


I've already closed the panes. Making the exits invisble doesn't do what I want, so I'll just go with the off descriptions option.


K.V.

Making the exits invisble doesn't do what I want

Okie dokie.

I'm unclear as to what you want the end result to be.

If the solution isn't in this thread, I don't know what it could be.

(Sorry, jm!)


It's okay.

Maybe someone can play this. http://textadventures.co.uk/games/view/yxlhx2owy0_5gcwaxle0ag/pokemon-play-as-young-harley-version

I've been messing with the typewriter. I haven't got it to look right yet.

Just go west, southwest, south, south.

Wondering if this is the best option, and wondering if I should use the typewriter.


K.V.

It doesn't print any output when playing online in Firefox:

Screenshot:

image


I forgot to publish it. Sorry.

Try it now.


K.V.

If you're just wanting to be certain the player reads that text before continuing, I think you should use a wait script instead of the typewriter effect.

To see how the typewriter effect messing things up, play past that typewriter effect in your game. Go about 10 turns past it. Then, save and load that save. (It may have just been my game, but it kind of messed up everything when loading a save (without clearing the screen after the typewriter effect).


Will check out the wait.

Play past that typewriter effect. Go about 10 turns past it. Then, save and load that save. (It may have just been my game, but it kind of messed up everything when loading a save (without clearing the screen after the typewriter effect).

What.


K.V.

Play your game.

Go w, sw, s, s.

Then, take about 10 more turns and save.

Exit the game.

Load the save.

Kick back and watch.


The first time I tried it, the website signed me out.

The second time I tried it, my game stopped working and I had to reload the game.

The third time I tried it, my panes showed up for some reason. All the text was gone. But I moved, and the text came back.


...hey...


K.V.

My two cents.


Actually, I was thinking about using a time script (already made one). I'm just searching possibilities.

I thought you'd say something about my experience...


K.V.

I thought you'd say something about my experience...

Nah... I was expecting random things to go haywire. (That's what happened to me.)


I was thinking about using a time script

Time scripts do strange things sometimes when loading saves sometimes, too (depending on the scripts in which they are nested as well as what sort of mood Quest is in at the time).


I think the best way to fly is:

// Clear the screen to get rid of any hyperlinks:
ClearScreen
// Hide the panes, so the player can't be clickin' nuthin':
JS.uiHide ("#gamePanes")
msg ("This cutscene prints, then you must click \"Continue...\"")
wait {
  // Back to normal play!
  // Show the panes again:
  JS.uiShow ("#gamePanes")
  // Show the room description, since the screen was cleared:
  ShowRoomDescription
}

I think the best way to fly is:

Nice way to do it.
I'd probably go for hiding #gameBorder instead, and move the current output div outside it temporarily. So you have a cut scene and nothing else onscreen :p (but then, I like to be able to scroll back when playing a game, so I can remind myself what I've already done)


K.V.

I'd probably go for hiding #gameBorder instead, and move the current output div outside it temporarily. So you have a cut scene and nothing else onscreen

This may be the new best way I know of.


I don't know what #gameBorder is.

This is what I've decided on.

LockExit (ac)
LockExit (ab)
msg ("Harley's classmates show up.<br/><br/>One of the popular girls says \"Well, well... If it isn't little Harley? Are you playing with your Canes.<br/><br/>Harley tries not to let her get to him, but his anger shows in his speech. \"I'm a Pokémon trainer!\"<br/><br/>The girl says \"Tch, you couldn't even beat one gym!\"<br/><br/>Your anger increases. \"I will defeat the Pokémon League and become Pokémon Champion! You'll see!\"<br/><br/>(Press a key.)")
wait {
  msg ("Cleared.<br/>You can go north or east.")
  turn on descriptions
  UnlockExit (ab)
  UnlockExit (ac)
}

K.V.

When you hide #gameBorder, you hide all game output.

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Cut Scene">
    <gameid>127b5bbf-514f-480c-8b9d-3057be439fe9</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>
    <exit alias="north" to="Hallway">
      <inherit name="northdirection" />
    </exit>
  </object>
  <object name="Hallway">
    <inherit name="editor_room" />
    <beforefirstenter type="script"><![CDATA[
      msg ("<div id='cut-scene1' onclick='backToGame()' style='margin-left:auto;margin-right:auto;width:"+game.customwidth+"px;font-size:"+game.defaultfontsize+";font-family:"+game.defaultfont+";display:none'><br/><br/>Just before you leave the room, lots and lots of text prints out!<br/><br/>It's insanity!<br/><br/>(Like you're actually going to read it!  Psshht!!!)<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<br/><br/>All work and no play makes Jack a dull boy.<b><center>[ PRESS ANY KEY TO CONTINUE  ]</center></b></div>")
      JS.eval ("backToGame = function(){waitEnded();endWait();uiHide('#cut-scene1');uiShow ('#gameBorder');};$('#cut-scene1').insertAfter($('#gameBorder'));uiHide('#gameBorder');uiShow('#cut-scene1');")
      wait {
        JS.uiHide ("#cut-scene1")
        JS.uiShow ("#gameBorder")
        msg ("<br/><b><center>[  LEVEL 1 COMPLETE!  ]</center></b><br/>")
      }
    ]]></beforefirstenter>
    <exit alias="south" to="room">
      <inherit name="southdirection" />
    </exit>
  </object>
</asl>

I think I'd be likely doing something more like…

function startCutscene() {
  normal_newDiv = createNewDiv;
  createNewDiv = function(alignment) {
    normal_newDiv(alignment);
    getCurrentDiv().insertBefore("#gameBorder");
  };
  StartOutputSection("cutsceneDiv");
  uiHide("#gameBorder");
}

function endCutscene() {
  createNewDiv = normal_newDiv;
  uiShow("#gameBorder");
  $("#gameBorder ~ div.cutsceneDiv").appendTo("#divOutput");
  EndOutputSection("cutsceneDiv");
}

Or even use jQuery's animate/toggle functionality to fade gameBorder out before hiding it.

(off the top of my head, so sorry for any typos)


K.V.

That's good stuff, mrangel! (In fact, I just archived the code!)


Also, I've been playing with something else and came up with these JS functions to hide and show the "You can go" line's element.

JS Functions

hideRoomExitsList = function(){
  $(".exitlink").parent().hide();
};

showRoomExitsList = function(){
  $(".exitlink").parent().show();
};


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

Support

Forums