How to add scenery to several rooms at once (no coding required!)

The Pixie
Let us suppose we have several locations in a forest. You just know that some smart-ass player will type X TREE, and expect a reply. You could implement a tree object in every room, but there is an alternative - and it does not require any coding.

The trick is to set these locations to be transparent, and then put them inside another location that contains the tree.

Set up a location, say called e_forest. In that location, place an item, tree (with an alterative name "trees", as the player may well type LOOK AT TREE and LOOK AT TREES and we want to handle both; find other names on the Object tab). You might also want to put in other objects like sky, path, bush, etc.

Then for each forest location: Drag it into the e_forest location (i.e., rooms within the room). Then on the Attributes tab, click Add, type "transparent", set it to be a Boolean, and tick the box.

Quest will note that your forest rooms are transparent, and so the player will be able to see (but not reach) anything in the containing room.

Here is an example to see it in action.
<!--Saved by Quest 5.6.5510.29036-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="forest">
<gameid>14bb0e0b-4b6c-4c27-96fa-c6c7e975d392</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
</game>
<object name="hut">
<inherit name="editor_room" />
<description>You are in a wooden hut</description>
<alias>Hut</alias>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="out" to="forest_path">
<inherit name="outdirection" />
</exit>
</object>
<object name="e_forest">
<inherit name="editor_room" />
<object name="forest_path">
<inherit name="editor_room" />
<description>There is a hut you can go in, or a path going east.</description>
<alias>Forest Path</alias>
<transparent />
<exit alias="east" to="forest_clearing">
<inherit name="eastdirection" />
</exit>
<exit alias="in" to="hut">
<inherit name="indirection" />
</exit>
</object>
<object name="forest_clearing">
<inherit name="editor_room" />
<alias>Forest Clearing</alias>
<description>A clearing.</description>
<transparent />
<exit alias="west" to="forest_path">
<inherit name="westdirection" />
</exit>
</object>
<object name="tree">
<inherit name="editor_object" />
<scenery />
<look>It is a tall thing with leaves on.</look>
<alt type="stringlist">
<value>trees</value>
</alt>
</object>
<object name="sky">
<inherit name="editor_object" />
<look>The sk is blue; it is a great day.</look>
</object>
</object>
</asl>

The Pixie
Actually this next bit does require code.

Let us add some flavour to the forest; random things seen in the background. As the player wanders through the forest, he might see a rabbit watching him, or butterflies flitting about. We already have a system that groups all the forest locations, so we can start with that (it is less work to have the same random options for any forest location rather than setting them up for each location individually). All we need to do, then, is have a script run when the player enters a room that displays the randomly text.

Except the player is sure to type X RABBIT. We also need to implement every one of those random items. Or do we? How about just implementing one, and disguising it as a rabbit or two butterflies as we need it?

First create an object called "flavour_object", and tick the scenery box. No need to do anything else with it.

In each of your container rooms (like e_forest in the previous post) you need to set up three string list attributes, called "flavour", "flavournames" and "flavourdescs". You then need to add some values.

In the first, "flavour", type in the texts the player will see when entering that location, for example:
A rabbit watches you.
A gust of wind rustles the leaves.
Butterflies chase each other over the flowers.

In the second, "flavournames", type in the names of the objects. This is what the player might type to look at the thing mentioned in the text.
rabbit

butterfly|butterflies

Note that I left the second blank, because there was no object. The system will handle that fine, but you must leave a blank one to keep the rest in the right place. You can put in multiple names separated by a vertical bar, as with the last.

In the third, "flavourdescs", type in the description the player will see if she looks at the object. Again, the blank one is important.
It is a large brown bunny with big floppy ears.

The butterflies are bright blue.

Then the coding. On the game object you will see on the Script tab a section called "Script when entering a room". Paste the code below in there:

flavour_object.parent = game
if (HasAttribute(game.pov.parent, "parent")) {
if (HasAttribute(game.pov.parent.parent, "flavour")) {
n = GetRandomInt(0, 20)
if (n < ListCount(player.parent.parent.flavour)) {
msg (StringListItem(player.parent.parent.flavour, n))
if (HasAttribute(player.parent.parent, "flavournames") and HasAttribute(player.parent.parent, "flavourdescs")) {
if (n < ListCount(player.parent.parent.flavournames) and n < ListCount(player.parent.parent.flavournames)) {
if (not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent.flavournames, n) = "") {
flavour_object.parent = player.parent
flavour_object.alt = Split(StringListItem(player.parent.parent.flavournames, n), "|")
flavour_object.look = StringListItem(player.parent.parent.flavourdescs, n)
}
}
}
}
}
}


The code will run each time the player enters a room. First it moves the flavour_object object away to reset itself, then it checks a load of things before proceeding (that this room has a containing room, that the containing room has the needed string lists).

It then generates a random number, from 0 to 20 (you may want to adjust that; I use 5 in the example game below). If the random number is less than the number of texts, then it prints the text.

Next it checks if there are enties in the flavournames and flavourdescs lists. If there are, then it moves the flavour_object object, and then disguises it as the object mentioned, by setting its "alt" and "look" attributes (the "alt" attribute is an array of alternative names, so is more convenient than setting the "alias" attribute - and you cannot chane the "name" attribute during the game).


Example game:

<!--Saved by Quest 5.6.5510.29036-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="forest">
<gameid>14bb0e0b-4b6c-4c27-96fa-c6c7e975d392</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<roomenter type="script"><![CDATA[
flavour_object.parent = game
if (HasAttribute(game.pov.parent, "parent")) {
if (HasAttribute(game.pov.parent.parent, "flavour")) {
n = GetRandomInt(0, 5)
if (n < ListCount(player.parent.parent.flavour)) {
msg (StringListItem(player.parent.parent.flavour, n))
if (HasAttribute(player.parent.parent, "flavournames") and HasAttribute(player.parent.parent, "flavourdescs")) {
if (n < ListCount(player.parent.parent.flavournames) and n < ListCount(player.parent.parent.flavournames)) {
if (not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent.flavournames, n) = "") {
flavour_object.parent = player.parent
flavour_object.alt = Split(StringListItem(player.parent.parent.flavournames, n), "|")
flavour_object.look = StringListItem(player.parent.parent.flavourdescs, n)
}
}
}
}
}
}
]]></roomenter>
<object name="flavour_object">
<inherit name="editor_object" />
</object>
</game>
<object name="hut">
<inherit name="editor_room" />
<description>You are in a wooden hut</description>
<alias>Hut</alias>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="out" to="forest_path">
<inherit name="outdirection" />
</exit>
</object>
<object name="e_forest">
<inherit name="editor_room" />
<flavour type="stringlist">
<value>A rabbit watches you.</value>
<value>A gust of wind rustles the leaves.</value>
<value>Butterflies chase each other over the flowers.</value>
</flavour>
<flavournames type="stringlist">
<value>rabbit</value>
<value></value>
<value>butterfly|butterflies</value>
</flavournames>
<flavourdescs type="stringlist">
<value>It is a large brown bunny with big floppy ears.</value>
<value></value>
<value>The butterflies are bright blue.</value>
</flavourdescs>
<object name="forest_path">
<inherit name="editor_room" />
<description>There is a hut you can go in, or a path going east.</description>
<alias>Forest Path</alias>
<transparent />
<exit alias="east" to="forest_clearing">
<inherit name="eastdirection" />
</exit>
<exit alias="in" to="hut">
<inherit name="indirection" />
</exit>
</object>
<object name="forest_clearing">
<inherit name="editor_room" />
<alias>Forest Clearing</alias>
<description>A clearing.</description>
<transparent />
<exit alias="west" to="forest_path">
<inherit name="westdirection" />
</exit>
</object>
<object name="tree">
<inherit name="editor_object" />
<scenery />
<look>It is a tall thing with leaves on.</look>
<alt type="stringlist">
<value>trees</value>
</alt>
</object>
<object name="sky">
<inherit name="editor_object" />
<look>The sk is blue; it is a great day.</look>
</object>
</object>
</asl>

Marzipan
Holy crap this is a good thread.

HegemonKhan
Most of the Libraries and 'how to' guides are Pixie's, laughs. Can't thank Pixie enough for all the code resources that he~she has provided for us, hehe. Though understanding them... takes some time... as many of them are quite advanced code stuff, laughs.

Marzipan
As an addition to the 'no coding' example, I just want to point out that if your game takes place entirely in a forest, you could just add a game-wide command for examining the trees. Or if your player will spend most of their time in outside locations, having one of these for the sky is handy. Some jerk always wants to test your attention to detail by examining the sky. (I'm that jerk, it's me)

The Pixie
Marzipan wrote:As an addition to the 'no coding' example, I just want to point out that if your game takes place entirely in a forest, you could just add a game-wide command for examining the trees. Or if your player will spend most of their time in outside locations, having one of these for the sky is handy. Some jerk always wants to test your attention to detail by examining the sky. (I'm that jerk, it's me)

Even if your game is not entirely in a forest, you could probably get away with doing this, as no one is likely to ever type LOOK AT SKY whilst inside the house, and so no one will realise.

jaynabonne

Even if your game is not entirely in a forest, you could probably get away with doing this, as no one is likely to ever type LOOK AT SKY whilst inside the house, and so no one will realise.


Given what I've read in the IntFic forums, I wouldn't bet on that. :)

Father thyme
Your game wide command for examining things could be worded.
" The sky is blue, or at least it was this morning, which was the last time I bothered to look at it."
" The last time I examined a tree it was made of wood. I doubt if things have changed since then"
The player has then got the gentle hint that he/she should get on with it and not waste time looking for holes in the writers game.

TM123
Is this info obsolete? I followed the instructions, resulting in something like this in the uh, tree view:
-Woods_Container
-tree
+Woods1
+Woods2

The rooms woods1 and woods2 being transparent, both have the alias "a magical forest"

What I get is the ability to see the rooms, from room Woods1:

You are in a magical forest.
You can see an a magical forest (containing a brook) and an a magical forest.

What I can't see is the tree - maybe because I had to make it not visible otherwise it showed up as "there is a tree here."

TM123
I got it to work - I set the "visible" attribute to False for the rooms woods1 and woods2. The tree, apparently by magic, is also working properly. For some reason it isn't ignoring "Scenery (do not display in room description)" like it has been since I started using this. Wait! Perhaps it started working because under "game/features" I clicked off "In-room descriptions: additional text which each object contributes to a room description" and then clicked it back on again. That's plausibly magical.

eagle7000
First of all, thanks for the helpful tips and tutorials!

I'm stumped on the string attributes - I am using the online game editor on a mac to the extent that makes a difference. I can add the flavour "object", move the rooms into the e_room add the code but cannot figure out how to adjust the string attributes or even what that means / how one accesses same. Help would be much appreciated!

Oh, I also get the following errors after adding my e_room and then moving the individual rooms into same:
Could not set value 'not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent' - The number of opening brackets "(" does not match the number of closing brackets ")".
Could not set value 'not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent' - The number of opening brackets "(" does not match the number of closing brackets ")".


Perhaps relatedly, I don't see any option to make a room transparent. Thanks for any assistance you can offer!

HegemonKhan
your '('~left parenthesis quantity must match your ')'~right parenthesis quantity, and also you got to have them in the right places ~ depending on your scripts used. It's easy to mess this stuff up... best is to space them out, so you can better see them, then once you fixed the issue, respace them back together. Actually, the best is to use an advanced Text Editor, such as: notepad++, or usually any SDK/IDE has one built-into it too.

for some examples:

if (orc.dead { /* scripts */ }// notice that I've got 1 '(' but 0 ')'; 1 =/= 0; ERROR!
correct: if (orc.dead) { /* scripts */ }

using Lists/Dictionaries can get quite messy/many with the parenthesis, and is easy to mess them up, for example:

invoke (ScriptDictionaryItem (Object_name.Script_Dictionary_Attribute_name, StringListItem (Object_name.String_List_Attribute_name, GetRandomInt (0, ListCount (Object_name.String_List_Attribute_name) - 1))))


I counted left parenthesis (find the segment where it shifts from left parenthesis to right parenthesis): 5
so that means I need 5 right parenthesis
now, it's just a matter of putting them in the right places

you can either,

space it out:

invoke (ScriptDictionaryItem (Object_name.Script_Dictionary_Attribute_name, StringListItem (Object_name.String_List_Attribute_name, GetRandomInt (0, ListCount (Object_name.String_List_Attribute_name) - 1) ) ) )

or space out the segments/scripts (to see/check/fix it, then put them back togehter):

1. invoke (
2. ScriptDictionaryItem (
3. Object_name.Script_Dictionary_Attribute_name, StringListItem (
4. Object_name.String_List_Attribute_name, GetRandomInt (
5. 0, ListCount (

5. Object_name.String_List_Attribute_name)
4. - 1)
3. )
2. )
1. )

The Pixie
eagle7000 wrote:First of all, thanks for the helpful tips and tutorials!

I'm stumped on the string attributes - I am using the online game editor on a mac to the extent that makes a difference. I can add the flavour "object", move the rooms into the e_room add the code but cannot figure out how to adjust the string attributes or even what that means / how one accesses same. Help would be much appreciated!

For reasons I do not get, the on-line version does not have an attributes tab, so that is why you cannot set attributes. There is a work around, but it is not as easy. Got to the Script tab of the game object. At the top you have "Start script"

For each attribute: Click "Add new script", then "Variables" and select "Set an object's attribute", and click Okay.
[]Set object [name][                     ]
Attribute: ["" ]
Value [ ]

Say you want to set the "transparent" attribute of a room called "lounge" to true. Fill it in like this:
[]Set object [name][lounge               ]
Attribute: ["transparent" ]
Value [true ]

A few notes. When it says lounge, you will find that is a dropdown list of objects in your game. Note that the attrribute name has to be in quotes. If the value is a string, then that also needs to be in quotes.

Oh, I also get the following errors after adding my e_room and then moving the individual rooms into same:
Could not set value 'not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent' - The number of opening brackets "(" does not match the number of closing brackets ")".
Could not set value 'not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent' - The number of opening brackets "(" does not match the number of closing brackets ")".


This maybe because of the way the forum has split some long lines in the code. In the middle of the code in the second post, there are these three lines:
      if (HasAttribute(player.parent.parent, "flavournames") and HasAttribute(player.parent.parent, "flavourdescs")) {
if (n < ListCount(player.parent.parent.flavournames) and n < ListCount(player.parent.parent.flavournames)) {
if (not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent.flavournames, n) = "") {

In my browser they are broken up into six lines, and if they are six lines in your code, Quest will get confused, and you will get that error message. Here they are without the code formatting; try pasting them in like this (normal formating removes the spaces at the start of the line, but Quest does not care about that).

if (HasAttribute(player.parent.parent, "flavournames") and HasAttribute(player.parent.parent, "flavourdescs")) {
if (n < ListCount(player.parent.parent.flavournames) and n < ListCount(player.parent.parent.flavournames)) {
if (not StringListItem(player.parent.parent.flavournames, n) = "" and not StringListItem(player.parent.parent.flavournames, n) = "") {

Perhaps relatedly, I don't see any option to make a room transparent. Thanks for any assistance you can offer!


That is the missing attributes tab again.

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

Support

Forums