Simple attribute room question

XanMag

I know, I know... I should know... but:

There are several rooms I have that are adjacent to a lake (or other water source). I want to be able to "get water" from these locations and x water, x lake, etc.

Do I add an Inherited Type attribute to these rooms (I'll call it "water") and use a universal command for "get water", "x water", etc to see if that inherited attribute is present?

EDIT: Ugh. I've messed with it and can't figure out. Prepared to feel dumb in 3...2...1... =P

Thanks in advance!


onimike

I would try to give water a location variable, then each other room a location var then set all rooms location next to water 1 and set water room to 0. Then in command say

if player.parent.location <= 1 then
    "get water"
else 
    "you are not next to water source."
end

Thats not actual code but hope you get the gist of it. But with this set up you should be able to to do different things with different locations based on a simple number.


XanMag

This seems simple enough and I've been fiddling with that suggestion, onimike, and cannot make it work. It should be easy I think, but I can't get it.

  1. Give the room an attribute.
  2. In the get water; take water command script, check if that attribute is present (this is where I am troubled, I think)
  3. Run proper scripts.

onimike

Ok so I made a little demo game and what I did was make a central room and put the rooms i want around inside the central room, I also made an items room, pond and water. Then made a command called "get water" and gave it a tag "gw" for short. In script i put this

if (player.parent.parent = centralroom) {
  if (Got(water)) {
    IncreaseObjectCounter (water, "volume")
    msg ("You now have " +water.volume+ " drinks of water.")
  }
  else {
    CloneObjectAndMove (water, pond)
    AddToInventory (water)
    IncreaseObjectCounter (water, "volume")
    msg ("You now have " +water.volume+ " drinks of water.")
  }
}
else if (player.parent = centralroom) {
  if (Got(water)) {
    IncreaseObjectCounter (water, "volume")
    msg ("You now have " +water.volume+ " drinks of water.")
  }
  else {
    CloneObjectAndMove (water, pond)
    AddToInventory (water)
    IncreaseObjectCounter (water, "volume")
    msg ("You now have " +water.volume+ " drinks of water.")
  }
}
else {
  msg ("You need to be by a water source.")
}

And thats about it run game and try it.

Here is a link where you can download demo if you have offline version
https://www.dropbox.com/s/jxz93jqoq9z469g/Water.aslx?dl=0

And here's full code for demo if you don't trust the link

<!--Saved by Quest 5.6.6108.15891-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Water">
    <gameid>3b92ad36-7f28-4c55-b960-a032ec85394c</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="centralroom">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="eastroom">
      <inherit name="editor_room" />
      <exit alias="west" to="centralroom">
        <inherit name="westdirection" />
      </exit>
    </object>
    <object name="pond">
      <inherit name="editor_object" />
      <object name="water">
        <inherit name="editor_object" />
        <take />
      </object>
    </object>
    <exit alias="east" to="eastroom">
      <inherit name="eastdirection" />
    </exit>
    <object name="northroom">
      <inherit name="editor_room" />
      <exit alias="south" to="centralroom">
        <inherit name="southdirection" />
      </exit>
    </object>
    <object name="westroom">
      <inherit name="editor_room" />
      <exit alias="east" to="centralroom">
        <inherit name="eastdirection" />
      </exit>
    </object>
    <object name="southroom">
      <inherit name="editor_room" />
      <exit alias="north" to="centralroom">
        <inherit name="northdirection" />
      </exit>
      <exit alias="south" to="outerroom">
        <inherit name="southdirection" />
      </exit>
    </object>
    <exit alias="north" to="northroom">
      <inherit name="northdirection" />
    </exit>
    <exit alias="west" to="westroom">
      <inherit name="westdirection" />
    </exit>
    <exit alias="south" to="southroom">
      <inherit name="southdirection" />
    </exit>
  </object>
  <object name="items">
    <inherit name="editor_room" />
  </object>
  <object name="outerroom">
    <inherit name="editor_room" />
    <exit alias="north" to="southroom">
      <inherit name="northdirection" />
    </exit>
  </object>
  <command name="getwater">
    <pattern>gather water;water;get water; gw;</pattern>
    <script>
      if (player.parent.parent = centralroom) {
        if (Got(water)) {
          IncreaseObjectCounter (water, "volume")
          msg ("You now have " +water.volume+ " drinks of water.")
        }
        else {
          CloneObjectAndMove (water, pond)
          AddToInventory (water)
          IncreaseObjectCounter (water, "volume")
          msg ("You now have " +water.volume+ " drinks of water.")
        }
      }
      else if (player.parent = centralroom) {
        if (Got(water)) {
          IncreaseObjectCounter (water, "volume")
          msg ("You now have " +water.volume+ " drinks of water.")
        }
        else {
          CloneObjectAndMove (water, pond)
          AddToInventory (water)
          IncreaseObjectCounter (water, "volume")
          msg ("You now have " +water.volume+ " drinks of water.")
        }
      }
      else {
        msg ("You need to be by a water source.")
      }
    </script>
  </command>
</asl>

Hope you can get it working.


XanMag

Thanks a ton. I'll give it a go soon and let you know!


Silver

Can't you just put a scenery object in each location with aliases lake/water (in order to examine) and then verbs to trigger scripts for get/fetch etc?

Otherwise commands that checks the player's location. Either way should work.


Log in to post a reply.

Support

Forums