Dark Room

Hi, this is probably going to be an easy fix, with a classic 'Homeresque' DOH! , or I am doing it the right way.
I have a room that is initially 'Dark' when you enter it, with the rooms alias being 'Dark Room'.
I have a lamp that switches on/off.
When the lamp is switched on, I want the rooms alias to change to 'Hall'.
At the moment, I have it as part of the lamp switch on script, as follows:

this.lightsource = true
Room2.alias = "Hall"

If there are a lot of these 'Dark Rooms', this script is going to get very long.
I have tried putting a change script on the alias of 'Room2', but I can't seem to get it to work.
Any help would be appreciated.


K.V.

I battled with this, as well...

If you want the status bar to print the new alias and the room description to print, you can use this:

Click to view example code

UPDATE:

http://textadventures.co.uk/forum/quest/topic/50zn3-sb-usamdth9loohg/dark-room#78e9d899-fcff-4ac9-9fb0-e236eface691


I would suppose you would have some sort of script where if the light source was switch on or off, the alias would be changed.
...Yes, I know I just repeated what you said.

Do you also want something else to happen, or is that it?


That's pretty much it at this stage jmnevil54. It's just the fact that there could be more than one room involved, maybe an underground section, where the light being switched on, or a torch requiring a battery could be important.
Just wondered if there was another way of doing it, rather than attaching a whole load of 'room.alias' variables to the light switch script, that was all.


K.V.

You could give each of the rooms two extra aliases each: aliasDark and aliasLit, then add this turnscript:

Turn Script

if (CheckDarkness()) {
  game.pov.parent.alias = game.pov.parent.aliasDark
  request (UpdateLocation, "" + room.alias + "")
}
else {
  game.pov.alias = game.pov.parent.aliasLit
  request (UpdateLocation, "" + room.alias + "")
}

(filler for getting this edited post, updated/posted)


This is the same method as KV, but I used Object Types and the special 'changed' Script Attribute for it, instead of a Turnscript as KV used for his example


the 'changedNAME_OF_ATTRIBUTE' Script Attribute would NOT be on the 'alias' as that's the desired result, not the cause of it (the Attribute with changing value that is used to determine what the 'alias' will be set/changed as/to, which is what you DO want!)


most of the built-in Attributes for Objects:

http://docs.textadventures.co.uk/quest/elements/object.html


you'd have it either on your:

  1. 'this.switchedon' Boolean Attribute // the special 'this' (is able to) key-word/key-command references/gets whatever the Object that is the light source (such as your 'lamp' in a room, using your post):

http://docs.textadventures.co.uk/quest/attributes/switchedon.html
http://docs.textadventures.co.uk/quest/attributes/switchedondesc.html
http://docs.textadventures.co.uk/quest/attributes/switchedoffdesc.html
http://docs.textadventures.co.uk/quest/attributes/switchonmsg.html
http://docs.textadventures.co.uk/quest/attributes/switchoffmsg.html

<object name="room">
  <attr name="alias" type="script">dark room</attr>
  <attr name="dark_alias" type="script">dark room</attr>
  <attr name="light_alias" type="script">Hall</attr>
  <object name="lamp">
    <inherit name="light_source_type" />
  </object>
</object>

<object name="room2">
  <attr name="alias" type="script">shadow room</attr>
  <attr name="dark_alias" type="script">shadow room</attr>
  <attr name="light_alias" type="script">Prison</attr>
  <object name="lamp">
    <inherit name="light_source_type" />
  </object>
</object>

<type name="light_source_type">
  <attr name="switchedon" type="boolean">false</attr>
  <attr name="changedswitchedon" type="script">
    if (this.switchedon) { // if (on) // if (TRUE)
      this.parent.alias = this.parent.light_alias
    } else { if (off) // if (FALSE)
      this.parent.alias = this.parent.dark_alias
    }
  </attr>
</type>
  1. and maybe also one of the 'dark/light' feature's Attributes:

http://docs.textadventures.co.uk/quest/attributes/dark.html
http://docs.textadventures.co.uk/quest/attributes/darklevel.html
http://docs.textadventures.co.uk/quest/attributes/lightstrength.html
// helper Functions:
http://docs.textadventures.co.uk/quest/functions/corelibrary/checkdarkness.html
http://docs.textadventures.co.uk/quest/functions/corelibrary/setobjectlightstrength.html
http://docs.textadventures.co.uk/quest/functions/corelibrary/setexitlightstrength.html
http://docs.textadventures.co.uk/quest/functions/corelibrary/setlight.html
http://docs.textadventures.co.uk/quest/functions/corelibrary/setdark.html

looks like you'd use the 'dark' Boolean Attribute:

<object name="room">
  <inherit name="darkness_type" />
  <attr name="alias" type="script">dark room</attr>
  <attr name="dark_alias" type="script">dark room</attr>
  <attr name="light_alias" type="script">Hall</attr>
  <object name="lamp">
    <inherit name="light_source_type" />
  </object>
</object>

<object name="room2">
  <inherit name="darkness_type" />
  <attr name="alias" type="script">shadow room</attr>
  <attr name="dark_alias" type="script">shadow room</attr>
  <attr name="light_alias" type="script">Prison</attr>
  <object name="candle">
    <inherit name="light_source_type" />
  </object>
</object>

<type name="light_source_type">
  <attr name="lightstrength" type="string">weak</attr>
  <attr name="switchedon" type="boolean">false</attr>
  <attr name="changedswitchedon" type="script">
    if (HasBoolean (this.parent, "dark")) {
      if (this.switchedon) { // if (on) // if (TRUE)
        this.parent.dark = true
      } else { if (off) // if (FALSE)
        this.parent.dark = false
      }
    }
  </attr>
</type>

<type name="darkness_type">
  <attr name="dark" type="boolean">true</attr>
  <attr name="dark_alias" type="script">unknown</attr>
  <attr name="light_alias" type="script">unknown</attr>
  <attr name="changedswitchedon" type="script">
    if (this.dark) { // if (on) // if (TRUE)
      this.alias = this.dark_alias
    } else { if (off) // if (FALSE)
      this.alias = this.light_alias
    }
  </attr>
</type>

Thanks. You've all given me something to think about and try


I'm still struggling to get this to display correctly.
I want to enter a 'Dark Room', the room on enter should say 'You are in a Dark Room.', 'It is too dark too make anything out.', then when you turn on a light, 'You are in a Hall'.
I've tried attaching a script to the 'lightswitchedon' script, but the problem arises when you go back to a light room, then back to the 'Dark Room', 'You are in a Hall', 'It is too dark too make anything out'.
ARGHHH!
I've tried both K.V.'s and HK's ideas, but with no success.
I've also tried looking at the function for 'ShowRoomDescription' and 'GetRoomDescription', but I can't find where in those functions the room alias gets altered.
I feel like I'm going round in circles.
I must be missing something.


K.V.

Check this out:

CLICK HERE TO VIEW EXAMPLE GAME CODE THAT WORKS WELL
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="dark room (DrAgon)">
    <gameid>6cc08af2-1354-41a8-9d10-35ca9dc88ad4</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <feature_lightdark />
    <feature_advancedscripts />
    <scopebackdrop type="script">
      if (not ListContains(items, light switch)) {
        list add (items, light switch)
      }
    </scopebackdrop>
    <start type="script">
      renameAliasDark
    </start>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <aliasDark>Dark Room</aliasDark>
    <aliasLit>Hall</aliasLit>
    <dark />
    <darkroomdescription><![CDATA[It is too dark to make anything out.<br/>]]></darkroomdescription>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="light switch">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <feature_switchable />
      <feature_lightdark />
      <lightstrength>weak</lightstrength>
      <flip type="script">
        if (light switch.switchedon) {
          HandleSingleCommand ("turn off light")
        }
        else {
          HandleSingleCommand ("turn on light")
        }
      </flip>
      <onswitchon type="script">
        SetLight (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchon>
      <onswitchoff type="script">
        SetDark (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchoff>
    </object>
  </object>
  <turnscript name="checkDarknessTurnscript">
    <enabled />
    <script>
      renameAliasDark
    </script>
  </turnscript>
  <verb>
    <property>flip</property>
    <pattern>flip</pattern>
    <defaultexpression>"You can't flip " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>flipon</property>
    <pattern>flip on</pattern>
    <defaultexpression>"You can't flip on " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>flipoff</property>
    <pattern>flip off</pattern>
    <defaultexpression>"You can't flip off " + object.article + "."</defaultexpression>
  </verb>
  <function name="renameAliasDark">
    if (CheckDarkness()) {
      game.pov.parent.alias = game.pov.parent.aliasDark
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
    else {
      game.pov.parent.alias = game.pov.parent.aliasLit
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
  </function>
</asl>

UPDATE: Added 'FLIP' verb to light switch.

NOTE: The light switch could be made a 'weak light source' so it would be included in the room description, then the scope script could be removed, but I got the impression you didn't want the light switch mentioned.


K.V.

Here's one with two rooms, both initially dark, and a start script that fills in each room's alias, when the room has the attribute aliasDark.

You can't see the light switches in the room descriptions, but you can FLIP SWITCH or turn it off or on.

I also added a command: FEEL;FEEL AROUND

It prints, "you found a light switch" if you're in the dark and a light switch is there.

CLICK HERE TO VIEW THE CODE
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="dark room (DrAgon)">
    <gameid>6cc08af2-1354-41a8-9d10-35ca9dc88ad4</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <feature_lightdark />
    <feature_advancedscripts />
    <scopebackdrop type="script">
    </scopebackdrop>
    <start type="script">
      foreach (rm, AllObjects()) {
        if (HasAttribute(rm, "aliasDark")) {
          rm.alias = rm.aliasDark
        }
      }
      renameAliasDark
    </start>
    <roomenter type="script">
      renameAliasDark
    </roomenter>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <aliasDark>Dark Room</aliasDark>
    <aliasLit>Hall</aliasLit>
    <dark />
    <darkroomdescription><![CDATA[It is too dark to make anything out.<br/>]]></darkroomdescription>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="light switch">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <feature_switchable />
      <feature_lightdark />
      <lightstrength>weak</lightstrength>
      <scenery />
      <lightsource />
      <flip type="script">
        if (light switch.switchedon) {
          HandleSingleCommand ("turn off light")
        }
        else {
          HandleSingleCommand ("turn on light")
        }
      </flip>
      <onswitchon type="script">
        SetLight (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchon>
      <onswitchoff type="script">
        SetDark (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchoff>
    </object>
    <exit alias="south" to="room2">
      <inherit name="southdirection" />
    </exit>
  </object>
  <turnscript name="checkDarknessTurnscript">
    <enabled />
    <script>
      renameAliasDark
    </script>
  </turnscript>
  <verb>
    <property>flip</property>
    <pattern>flip</pattern>
    <defaultexpression>"You can't flip " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>flipon</property>
    <pattern>flip on</pattern>
    <defaultexpression>"You can't flip on " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>flipoff</property>
    <pattern>flip off</pattern>
    <defaultexpression>"You can't flip off " + object.article + "."</defaultexpression>
  </verb>
  <object name="room2">
    <inherit name="editor_room" />
    <dark />
    <darkroomdescription>It is too dark to make anything out.</darkroomdescription>
    <aliasDark>Dark Room</aliasDark>
    <aliasLit>Empty Room</aliasLit>
    <exit alias="north" to="room">
      <inherit name="northdirection" />
    </exit>
    <object name="light switch2">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <alias>light switch</alias>
      <feature_switchable />
      <feature_lightdark />
      <lightstrength>weak</lightstrength>
      <scenery />
      <lightsource />
      <flip type="script">
        if (light switch2.switchedon) {
          HandleSingleCommand ("turn off light")
        }
        else {
          HandleSingleCommand ("turn on light")
        }
      </flip>
      <onswitchon type="script">
        SetLight (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchon>
      <onswitchoff type="script">
        SetDark (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchoff>
    </object>
  </object>
  <command name="feel">
    <pattern>feel;feel around</pattern>
    <script>
      if (CheckDarkness()) {
        foreach (o, ScopeReachable()) {
          if (StartsWith(o.name, "light switch")) {
            msg ("You found a light switch.")
          }
        }
      }
      else {
        msg ("You feel nothing unexpected.")
      }
    </script>
  </command>
  <function name="renameAliasDark">
    if (CheckDarkness()) {
      game.pov.parent.alias = game.pov.parent.aliasDark
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
    else {
      game.pov.parent.alias = game.pov.parent.aliasLit
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
  </function>
</asl>

Thanks K.V., that works. But, I didn't really want to have to remember to add two attributes to every room in the game. I mean the rooms got a name and an alias it uses already. My thought was if only the 'Dark Rooms' had a DarkRoomAlias, and then flip between the two, and then check for the alias via a change script 'HasAttribute', that sort of thing.


K.V.

My thought was if only the 'Dark Rooms' had a DarkRoomAlias, and then flip between the two, and then check for the alias via a change script 'HasAttribute', that sort of thing.

Ah...

Be right back.


K.V.
foreach (o, AllObjects()) {
  if (HasAttribute(o, "aliasDark")) {
    o.aliasLit = o.alias
    o.alias = o.aliasDark
  }
}
renameAliasDark

That change to the start script should do it.

I just deleted the aliasLit attribute from both rooms. Then I made 'Hall' the alias for room, and "Empty Room" the alias for room2.

Testing now...


K.V.

Okay.

Now it adds the dark room description for you, too.

All you have to do is give the room the aliasDark attribute with "Dark Room" for the string. You don't even need a room alias. Just name the room whatever you'd like it to say when it's lit.

GAME CODE HERE
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="dark rooms (for DrAgon)">
    <gameid>6cc08af2-1354-41a8-9d10-35ca9dc88ad4</gameid>
    <version>0.3</version>
    <firstpublished>2017</firstpublished>
    <feature_lightdark />
    <feature_advancedscripts />
    <scopebackdrop type="script">
    </scopebackdrop>
    <start type="script">
      foreach (o, AllObjects()) {
        if (HasAttribute(o, "aliasDark")) {
          o.aliasLit = o.alias
          o.alias = o.aliasDark
          o.darkroomdescription = "It is too dark to make anything out."
        }
      }
      renameAliasDark
    </start>
    <roomenter type="script">
      renameAliasDark
    </roomenter>
    <description>example game</description>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <aliasDark>Dark Room</aliasDark>
    <dark />
    <alias>Hall</alias>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="light switch">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <feature_switchable />
      <feature_lightdark />
      <lightstrength>weak</lightstrength>
      <scenery />
      <lightsource />
      <flip type="script">
        if (light switch.switchedon) {
          HandleSingleCommand ("turn off light")
        }
        else {
          HandleSingleCommand ("turn on light")
        }
      </flip>
      <onswitchon type="script">
        SetLight (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchon>
      <onswitchoff type="script">
        SetDark (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchoff>
    </object>
    <exit alias="south" to="room2">
      <inherit name="southdirection" />
    </exit>
  </object>
  <turnscript name="checkDarknessTurnscript">
    <enabled />
    <script>
      renameAliasDark
    </script>
  </turnscript>
  <verb>
    <property>flip</property>
    <pattern>flip</pattern>
    <defaultexpression>"You can't flip " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>flipon</property>
    <pattern>flip on</pattern>
    <defaultexpression>"You can't flip on " + object.article + "."</defaultexpression>
  </verb>
  <verb>
    <property>flipoff</property>
    <pattern>flip off</pattern>
    <defaultexpression>"You can't flip off " + object.article + "."</defaultexpression>
  </verb>
  <object name="room2">
    <inherit name="editor_room" />
    <dark />

    <aliasDark>Dark Room</aliasDark>
    <alias>Empty Room</alias>
    <exit alias="north" to="room">
      <inherit name="northdirection" />
    </exit>
    <object name="light switch2">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <alias>light switch</alias>
      <feature_switchable />
      <feature_lightdark />
      <lightstrength>weak</lightstrength>
      <scenery />
      <lightsource />
      <flip type="script">
        if (light switch2.switchedon) {
          HandleSingleCommand ("turn off light")
        }
        else {
          HandleSingleCommand ("turn on light")
        }
      </flip>
      <onswitchon type="script">
        SetLight (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchon>
      <onswitchoff type="script">
        SetDark (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchoff>
    </object>
  </object>
  <command name="feel">
    <pattern>feel;feel around</pattern>
    <script>
      if (CheckDarkness()) {
        foreach (o, ScopeReachable()) {
          if (StartsWith(o.name, "light switch")) {
            msg ("You found a light switch.")
          }
        }
      }
      else {
        msg ("You feel nothing unexpected.")
      }
    </script>
  </command>
  <function name="renameAliasDark">
    if (CheckDarkness()) {
      game.pov.parent.alias = game.pov.parent.aliasDark
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
    else {
      game.pov.parent.alias = game.pov.parent.aliasLit
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
  </function>
</asl>

Give me 5 minutes, and it will be even LESS to set up.


K.V.

Bwahahahaha!


Okay.

  1. Make a room.
  2. Name it what you'd like it to be called when it's lit.
  3. Make an attribute named aliasDark (no need to fill in the string anymore). (No need to set the room as DARK either.)
  4. That's it! The start script will fix the aliases AND add the light switch.
CLICK TO VIEW THE BEST CODE FROM ME, AS OF THIS POST
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="dark rooms (for DrAgon)">
    <gameid>6cc08af2-1354-41a8-9d10-35ca9dc88ad4</gameid>
    <version>0.4</version>
    <firstpublished>2017</firstpublished>
    <feature_lightdark />
    <feature_advancedscripts />
    <description>example game</description>
    <scopebackdrop type="script">
    </scopebackdrop>
    <start type="script">
      foreach (o, AllObjects()) {
        if (HasAttribute(o, "aliasDark")) {
          o.aliasLit = o.alias
          o.aliasDark = "Dark Room"
          o.alias = o.aliasDark
          o.dark = true
          o.darkroomdescription = "It is too dark to make anything out."
          CloneObjectAndMove (light switch, o)
        }
      }
      renameAliasDark
    </start>
    <roomenter type="script">
      renameAliasDark
    </roomenter>
    <object name="light switch">
      <inherit name="editor_object" />
      <inherit name="switchable" />
      <feature_switchable />
      <feature_lightdark />
      <lightstrength>weak</lightstrength>
      <scenery />
      <lightsource />
      <flip type="script">
        if (this.switchedon) {
          HandleSingleCommand ("turn off light")
        }
        else {
          HandleSingleCommand ("turn on light")
        }
      </flip>
      <onswitchon type="script">
        SetLight (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchon>
      <onswitchoff type="script">
        SetDark (game.pov.parent)
        renameAliasDark
        ShowRoomDescription
      </onswitchoff>
    </object>
  </game>
  <object name="Hall">
    <inherit name="editor_room" />
    <aliasDark type="string"></aliasDark>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="south" to="Empty Room">
      <inherit name="southdirection" />
    </exit>
  </object>
  <turnscript name="checkDarknessTurnscript">
    <enabled />
    <script>
      renameAliasDark
    </script>
  </turnscript>
  <verb>
    <property>flip</property>
    <pattern>flip</pattern>
    <defaultexpression>"You can't flip " + object.article + "."</defaultexpression>
  </verb>
  <object name="Empty Room">
    <inherit name="editor_room" />
    <aliasDark type="string"></aliasDark>
    <exit alias="north" to="Hall">
      <inherit name="northdirection" />
    </exit>
  </object>
  <command name="feel">
    <pattern>feel;feel around</pattern>
    <script>
      if (CheckDarkness()) {
        foreach (o, ScopeReachable()) {
          if (StartsWith(o.name, "light switch")) {
            msg ("You found a light switch.")
          }
        }
      }
      else {
        msg ("You feel nothing unexpected.")
      }
    </script>
  </command>
  <function name="renameAliasDark">
    if (CheckDarkness()) {
      game.pov.parent.alias = game.pov.parent.aliasDark
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
    else {
      game.pov.parent.alias = game.pov.parent.aliasLit
      request (UpdateLocation, "" + game.pov.parent.alias + "")
    }
  </function>
</asl>

Thanks again K.V.


Is this 'Dark Room' issue a bug.
Does anyone know in which function the room gets its alias from, or is it embedded in the core code.


K.V.

It's no problem!

I've been battling Quest, trying to find an easy way to handle this as well.


I found out Quest will pull the object's name if the object doesn't have an alias, as far as my start script in this example is concerned, anyway.


The beginning of ShowRoomDescription :

isDark = CheckDarkness()
if (isDark) {
  descriptionfield = "darkroomdescription"
}
else {
  descriptionfield = "description"
}
if (game.autodescription) {
  desc = ""
  for (i, 1, 4) {
    if (i = game.autodescription_youarein) {
      if (game.autodescription_youarein_useprefix) {
        youarein = game.pov.parent.descprefix
        desc = AddDescriptionLine (desc, youarein + " " + GetDisplayName(game.pov.parent) + ".")
      }
      else {
        desc = AddDescriptionLine (desc, "<b>" + CapFirst(GetDisplayName(game.pov.parent)) + "</b>")
      }

Here's GetRoomDescription (note the note from Pix):

fulldesc = ""
if (CheckDarkness()) {
  if (HasString(game.pov.parent, "darkroomdescription")) {
    if (LengthOf(game.pov.parent.darkroomdescription) > 0) {
      fulldesc = game.pov.parent.darkroomdescription
    }
  }
  // Added by The Pixie to correct what appears to be a bug
  if (fulldesc = "") {
    fulldesc = DynamicTemplate("LookAtDarkness", game.pov.parent)
  }
}
else {
  if (HasString(game.pov.parent, "description")) {
    if (LengthOf(game.pov.parent.description) > 0) {
      fulldesc = game.pov.parent.description
    }
  }
}
if (game.appendobjectdescription) {
  foreach (val, ScopeVisibleNotHeld()) {
    if (HasString(val, "inroomdescription")) {
      if (LengthOf(val.inroomdescription) > 0 and val <> game.pov) {
        fulldesc = fulldesc + " " + val.inroomdescription
      }
    }
  }
}
return (Trim(fulldesc))

OnEnterRoom seems to only be pulling the display name to update the location bar (in the middle of the script:

request (UpdateLocation, CapFirst(GetDisplayName(game.pov.parent)))

Thanks again for the coding help K.V., just trying to understand how 'Quest' works.
Incidentally, I noticed you used 'Request UpdateLocation', I've not seen that on any of the Scripts, Functions, Attributes lists. Is there another listing of functions somewhere I've not seen.


@K.V. or anybody else
Can you check the following for me. It's a modification on the 'ShowRoomDescription' function.
The 'Dark Room' has a new attribute 'aliasDark'

isDark = CheckDarkness()
if (isDark) {
  descriptionfield = "darkroomdescription"
}
else {
  descriptionfield = "description"
}
if (game.autodescription) {
  desc = ""
  for (i, 1, 4) {
    if (i = game.autodescription_youarein) {
      if (game.autodescription_youarein_useprefix) {
        youarein = game.pov.parent.descprefix
        // Modification by Doctor Agon - Check if 'Dark Room'
        if (isDark) {
          desc = AddDescriptionLine (desc, youarein + " " + game.pov.parent.aliasDark + ".")
        }
        else {
          desc = AddDescriptionLine (desc, youarein + " " + GetDisplayName(game.pov.parent) + ".")
        }
      }
      else {
        // Modification by Doctor Agon - Check if 'Dark Room'
        if (isDark) {
          desc = AddDescriptionLine (desc, "<b>" + CapFirst(game.pov.parent.aliasDark) + "</b>")
        }
        else {
          desc = AddDescriptionLine (desc, "<b>" + CapFirst(GetDisplayName(game.pov.parent)) + "</b>")
        }
      }
      if (game.autodescription_youarein_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }
    if (i = game.autodescription_youcansee) {
      objects = FormatObjectList(game.pov.parent.objectslistprefix, GetNonTransparentParent(game.pov.parent), Template("And"), ".")
      desc = AddDescriptionLine(desc, objects)
      if (game.autodescription_youcansee_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }
    if (i = game.autodescription_youcango) {
      exits = FormatExitList(game.pov.parent.exitslistprefix, GetExitsList(), Template("Or"), ".")
      desc = AddDescriptionLine(desc, exits)
      if (game.autodescription_youcango_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }
    if (i = game.autodescription_description) {
      if (HasScript(game.pov.parent, descriptionfield)) {
        if (LengthOf(desc) > 0) {
          msg (desc)
          desc = ""
        }
        do (game.pov.parent, descriptionfield)
        if (game.autodescription_description_newline) {
          msg ("")
        }
      }
      else {
        desc = AddDescriptionLine(desc, GetRoomDescription())
        if (game.autodescription_description_newline) {
          msg (desc + "<br/>")
          desc = ""
        }
      }
    }
  }
  if (LengthOf(desc) > 0) {
    msg (desc)
  }
}
else {
  if (HasScript(game.pov.parent, descriptionfield)) {
    do (game.pov.parent, descriptionfield)
  }
  else {
    fulldesc = GetRoomDescription()
    if (LengthOf(fulldesc) > 0) {
      msg (fulldesc)
    }
  }
}

Hopefully, no need for turn scripts etc. This will do it all in one.


"Incidentally, I noticed you used 'Request UpdateLocation', I've not seen that on any of the Scripts, Functions, Attributes lists. Is there another listing of functions somewhere I've not seen. (Docter Agon)"


here's some of the 'Request' commands:

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

(Pixie might have been adding more with his new version of quest)


K.V.

Request UpdateLocation

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


I find some of those odd things by perusing the scripts of all the stuff in the tree after selecting ShowLibraryElements.

image


And Pixie has a wiki page on GitHub that is quite extensive:

https://github.com/ThePix/quest/wiki

And this is about darkness:
http://docs.textadventures.co.uk/quest/guides/hs_objectsappear.html


Mostly I just search the forum, though.

The thing is: any one thing can be done so many different ways...

Pixie seems to come up with the most direct way of handling things, and his way usually involves a function that keeps you from writing similar scripts repeatedly. He also has a tendency to post 'how-to' guides, which is extremely cool. Maybe not quite Fonzie cool, but really close!


Before your post (this post), I would just make a room called Darkness. "You can't see jack squat."

Then I moved the player to the real room after switching on a light. (If the light was fixed in place, I moved it with the player, of course. We wouldn't want to miss any details like that, would we?)

Anyway, no thanks are necessary (but I do appreciate your appreciation). Problem-solving is my drug of choice.

I learned a good way to handle darkness this time.

We have a text scrambler from another post...

Everybody wins!


K.V.

That code looks good to me, Doctor Agon.

...but I've only been using Quest a few months...

Fret not, though. If there are holes in it, someone here will point them out, then tell us how to patch it all up!


Revised 'ShowRoomDescription' Function.
I've added a 'Default Dark Room' name now just in case you forget to set the attribute 'aliasDark'.

isDark = CheckDarkness()
if (isDark) {
  descriptionfield = "darkroomdescription"
}
else {
  descriptionfield = "description"
}
// Modification by Doctor Agon: Check if 'Dark Room' attribute 'aliasDark' is set, if not assigns default name.
if (not HasAttribute(game.pov.parent, "aliasDark")) {
  game.pov.parent.aliasDark = "Dark Place"
}
if (game.autodescription) {
  desc = ""
  for (i, 1, 4) {
    if (i = game.autodescription_youarein) {
      if (game.autodescription_youarein_useprefix) {
        youarein = game.pov.parent.descprefix
        // Modification by Doctor Agon: Check if 'Dark Room'.
        if (isDark) {
          desc = AddDescriptionLine (desc, youarein + " a " + game.pov.parent.aliasDark + ".")
        }
        else {
          desc = AddDescriptionLine (desc, youarein + " " + GetDisplayName(game.pov.parent) + ".")
        }
      }
      else {
        // Modification by Doctor Agon: Check if 'Dark Room'.
        if (isDark) {
          desc = AddDescriptionLine (desc, "<b> A " + CapFirst(game.pov.parent.aliasDark) + "</b>")
        }
        else {
          desc = AddDescriptionLine (desc, "<b>" + CapFirst(GetDisplayName(game.pov.parent)) + "</b>")
        }
      }
      if (game.autodescription_youarein_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }
    if (i = game.autodescription_youcansee) {
      objects = FormatObjectList(game.pov.parent.objectslistprefix, GetNonTransparentParent(game.pov.parent), Template("And"), ".")
      desc = AddDescriptionLine(desc, objects)
      if (game.autodescription_youcansee_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }
    if (i = game.autodescription_youcango) {
      exits = FormatExitList(game.pov.parent.exitslistprefix, GetExitsList(), Template("Or"), ".")
      desc = AddDescriptionLine(desc, exits)
      if (game.autodescription_youcango_newline) {
        msg (desc + "<br/>")
        desc = ""
      }
    }
    if (i = game.autodescription_description) {
      if (HasScript(game.pov.parent, descriptionfield)) {
        if (LengthOf(desc) > 0) {
          msg (desc)
          desc = ""
        }
        do (game.pov.parent, descriptionfield)
        if (game.autodescription_description_newline) {
          msg ("")
        }
      }
      else {
        desc = AddDescriptionLine(desc, GetRoomDescription())
        if (game.autodescription_description_newline) {
          msg (desc + "<br/>")
          desc = ""
        }
      }
    }
  }
  if (LengthOf(desc) > 0) {
    msg (desc)
  }
}
else {
  if (HasScript(game.pov.parent, descriptionfield)) {
    do (game.pov.parent, descriptionfield)
  }
  else {
    fulldesc = GetRoomDescription()
    if (LengthOf(fulldesc) > 0) {
      msg (fulldesc)
    }
  }
}

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

Support

Forums