Change a room according to an object.

So,

I have a machine in my first room that I’m hoping will allow the player to change the weather outside in a garden room.

The change of weather will also change objects completely.

I am assuming I will need to create a different room for each weather condition.

But my question is... how do I make the correct rooms all appear to the east in accordance to the position of a dial on my machine?


Hopefully there aren’t a TON of objects Or weather types in the garden room. Keep the room, just use an if then script on each object in the garden room to alter its description. Set flags for each weather type.

It’s been a while since I’ve been on the pc. If this doesn’t make sense I’ll add a better description. Let us know.


Great that it’s possible! But if you wouldn’t mind explaining a little more please? Complete novice at this! Thank you so much for your help!


Below is the code and the "game" link. It might be easier to download the game or copy and paste that bit of code in a new game rather than me stumbling over an explanation.

EDIT: I probably should have asked before now, but I assume you are using the downloaded version and NOT the online version... (if you are using the online version, download the offline version - so much more control and reliability)

And here is a link to the "game".

http://textadventures.co.uk/games/view/dzcwo7gnu02uyyhxjdgztw/changing-room-descriptions-with-flags

Ask if you have questions!

<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Changing Room Descriptions with Flags">
    <gameid>07d8ca77-42c9-4859-8731-ca522641dae9</gameid>
    <version>1.0</version>
    <firstpublished>2021</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
  </object>
  <object name="Garden Room">
    <inherit name="editor_room" />
    <description type="script"><![CDATA[
      msg ("This is a garden room.  You see a small pond and a flower on a small square patch of ground.<br/>")
      if (GetBoolean(Control Room, "wpushed")) {
        msg ("It is quite cold in here and a light snow seems to be falling.")
      }
      else if (GetBoolean(Control Room, "ypushed")) {
        msg ("It is really hot in here and the sun is blazing overhead.")
      }
      else if (GetBoolean(Control Room, "bpushed")) {
        msg ("It is nice and cool in here but a steady rain is falling.")
      }
      else {
        msg ("There is nothing remarkable about anything in this room!")
      }
    ]]></description>
    <exit alias="south" to="Control Room">
      <inherit name="southdirection" />
    </exit>
    <object name="flower">
      <inherit name="editor_object" />
      <look type="script">
        if (GetBoolean(Control Room, "wpushed")) {
          msg ("The flower appears to be shivering under the light coating of snow.")
        }
        else if (GetBoolean(Control Room, "ypushed")) {
          msg ("The flower is standing fully erect stretching up toward the sun.")
        }
        else if (GetBoolean(Control Room, "bpushed")) {
          msg ("The flower is clinging desparately to a few drops of water falling from the sky.")
        }
        else {
          msg ("Boring little flower standing comfortably still.")
        }
      </look>
    </object>
    <object name="ground">
      <inherit name="editor_object" />
      <look type="script">
        if (GetBoolean(Control Room, "wpushed")) {
          msg ("The ground is covered in a light dusting of snow.")
        }
        else if (GetBoolean(Control Room, "ypushed")) {
          msg ("The ground is dry and cracked desparate for a bit of moisture.")
        }
        else if (GetBoolean(Control Room, "bpushed")) {
          msg ("The ground is slick with the newly falling rain.")
        }
        else {
          msg ("Lame ground.  not much remarkable.")
        }
      </look>
    </object>
    <object name="pond">
      <inherit name="editor_object" />
      <look type="script">
        if (GetBoolean(Control Room, "wpushed")) {
          msg ("The pond is frozen solid under a light dust of snow.")
        }
        else if (GetBoolean(Control Room, "ypushed")) {
          msg ("The pond looks more like a drying puddle of mud.  Sad little pond.")
        }
        else if (GetBoolean(Control Room, "bpushed")) {
          msg ("The banks of the pond are nearly overflowing with water as the rain pushing its limits.")
        }
        else {
          msg ("Normal pond.")
        }
      </look>
      <swinin type="script">
        if (GetBoolean(Control Room, "wpushed")) {
          msg ("You slip around on the ice like Bambi before retreating back to the shore line.")
        }
        else if (GetBoolean(Control Room, "ypushed")) {
          msg ("You'd rather not get in.  Looks like you'd just get all muddy!")
        }
        else if (GetBoolean(Control Room, "bpushed")) {
          msg ("Nah.  You're afraid you'd drown with all that water in there!")
        }
        else {
          msg ("You jump in and swim around for a bit before hopping back out.")
        }
      </swinin>
    </object>
  </object>
  <object name="Control Room">
    <inherit name="editor_room" />
    <description type="script"><![CDATA[
      msg ("This is your basic control room.<br/><br/>On the wall there are three buttons - a yellow one, a white one, and a blue one.  Each can be pushed.<br/>")
      if (GetBoolean(Control Room, "wpushed")) {
        msg ("It appears that the white button is pushed.")
      }
      else if (GetBoolean(Control Room, "ypushed")) {
        msg ("It appears that the yellow button is pushed.")
      }
      else if (GetBoolean(Control Room, "bpushed")) {
        msg ("It appears that the blue button is pushed.")
      }
      else {
        msg ("It appears none of the buttons have been pushed.")
      }
    ]]></description>
    <exit alias="north" to="Garden Room">
      <inherit name="northdirection" />
    </exit>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="yellow button">
      <inherit name="editor_object" />
      <look>It is a yellow button.  Go on... you know you want to push it.</look>
      <push type="script">
        SetObjectFlagOn (Control Room, "ypushed")
        SetObjectFlagOff (Control Room, "bpushed")
        SetObjectFlagOff (Control Room, "wpushed")
        msg ("You hear a faint click when you push the yellow button and a distant mechanical voice claims \"Yellow pushed.\"")
      </push>
    </object>
    <object name="blue button">
      <inherit name="editor_object" />
      <look>It's a blue button.  Dare you to push it.</look>
      <push type="script">
        SetObjectFlagOn (Control Room, "bpushed")
        SetObjectFlagOff (Control Room, "ypushed")
        SetObjectFlagOff (Control Room, "wpushed")
        msg ("You hear a faint click and a mechanical voice says \"Blue pushed.\"")
      </push>
    </object>
    <object name="white button">
      <inherit name="editor_object" />
      <look>It's a white button.  It looks like it wants to be pushed.</look>
      <push type="script">
        SetObjectFlagOn (Control Room, "wpushed")
        SetObjectFlagOff (Control Room, "ypushed")
        SetObjectFlagOff (Control Room, "bpushed")
        msg ("Click.  \"White has been pushed.\"")
      </push>
    </object>
  </object>
  <verb>
    <property>swinin</property>
    <pattern>swim in; get in</pattern>
    <defaultexpression>"You can't swin in; get in " + object.article + "."</defaultexpression>
  </verb>
</asl>

Oh... you may (or likely may not) find this helpful. I basically created a tutorial for myself whenever I learned new things with Quest. I refer to it quite bit still if I stumble. I made it available to everyone kind of as a tutorial for all. Again, this was written almost entirely for me and how I go about solving problems/getting things accomplished. It is very code light. Others here probably have WAY easier, or at least different solutions to the same problems as I, but this is how MY brain works. I won't be offended if this makes little or no sense to anyone. Just thought I'd make it available just in case. Happy gaming.

http://textadventures.co.uk/games/view/azkg8ntdweivkndr5j-ycg/quest-text-adventure-tutorials-and-templates


An alternative approach is to use the "select" text processor directive. If the "state" attribute of your machine is a number, from 0 to 3, say:

You look at the sky. {select:weathermachine.state:It is pouring with rain:It is sunny:It is foggy:It is snowing}.


Depending on how complex it is, you could use attributes to store the current weather.
For example, the weather machine could have a string attribute into which you put lines like "The sun beats down on the ground." or "There is rain splashing down all around you." - and then you can just include those in the room description by using {name-of-object.name-of-attribute} in the room description.

However, if it's more complex (with objects disappearing and appearing, or different complex puzzles in the outdoor space, for example) it may be easier to create separate copies of the room. In this case, you would need to give the exit that leads there a "name" in the editor (for example I would call it outside_door). Then on the script when you push the button, you could do something like:

msg ("You push the 'sun' button, and you see the weather outside get brighter.")
outside_door.to = sunny_garden

Which method is easier will depend on how many things you need to change :)


As someone who has made a similar project before, I agree with everything the others said. All of those are viable methods depending on how many objects need to change, and how many versions are needed. From experience, I can say that IF THEN is simple and clear, but it will get tedious if there are too many objects. While there are many ways to achieve similar effects in writing code, one of the benefits of brevity is that fewer lines of code means less opportunities for mistakes and typos!

I would also advise you to choose whether you are going to
A: make each item complete one at a time, including all weather effects for that item
(this will feel like less work, but you can't really test everything until all the work is done), or
B: make the basic version of all the items, then go back and add one weather change at a time to each item
(this will feel more tedious, but you'll be able to test each version of the room as you go along), or in the case of multiple rooms
C: make each room one at a time, complete with all items

Try to avoid mixing up these methods, because that will make it very easy to lose track of where you are in the process,
and that will make bug checking and fixes a nightmare.
For instance, I would not make three empty rooms, then ask myself,
"Which rooms have a fountain? This one and this one.
Which rooms have a birdbath? This one and that one..."
as I think that would lead to making mistakes and getting lost in the process.

NOTE: from here I basically summarize/compare what the others said, and I am partly writing this to help me think, because I'm considering doing an expanded remake of a similar game I made before.

This sounds similar to what I did for Day Of Honor, and I believe I used the IF THEN method, as XanMag suggested. In my case, what changed was the player's perspective/awareness. Therefore, all of the objects remained in place, and every single object in the game needed two sets of names, descriptions, and in some cases available verbs. It was quite a lot to do that way, but it was designed to be a short game from the start, so that worked for me. I would not have wanted to do that for more than two versions of things, and I wouldn't want to do it for a larger game.

With that said, any of the options suggested above would work. If I had to do Day Of Honor over again, I would probably want to make it bigger, and I would probably use a different method for that reason. It's a little unclear what your final plan will look like, so my advice is this:

If all the objects remain present but look and function differently, AND there's not too many of them:
IF THEN should work fine. It will mean laying everything out in clear detail, so you won't lose track of what's what.

If there are a lot of objects, or more than two weather conditions:
I would use one of the more concise methods, like the "select" text processor The Pixie proposed.

If the entire contents of the room are changed, with new objects appearing and old objects disappearing:
then I would go with separate rooms, just like mrangel said. If some of the objects exist in more than one version of the garden, consider including the relevant weather in the name of the objects, it'll help you keep track of what you're looking at as you work (i.e.: SprBirdbath, SmrBirdbath, FalBirdbath, WntBirdBath), and give them all the same alias (so they all say "birdbath" instead of "SmrBirdbath" etc.).


Thanks so much for all of your help!
This is exactly what I need. I’ve just got to make sense of it all. I’m VERY new to this 😂

Thanks so much!


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

Support

Forums