How to make it where items can only be used in certain rooms?

Hi, I'm new to Quest, and I can't seem to figure out nor find a solution to my problem. I'm using the latest desktop version of Quest.

My question is, how can I make it where a certain object can only be used in specific rooms?

Let's say, I want to be able to have the main character change clothes(So the object being a Shirt, for example), but only in rooms that can be considered "private", so if a room has another character in it, or you're in a public space, you can't use the object/shirt at all.

I have a house mapped out, where the MC's room, his sister's room, the bathroom, living room, and kitchen exist. I only want the MC's room and bathroom to be places where the object can be "used".

Is there a way to do this? Without going into the heavy scripting part of Quest?


I think you will need a flag that will identify if a room is private...
Then when you "use" the object, check that the room it private
then you can use it, and if not private, a message that you would not want to use it here.


I would, as DarkLizerd suggests, set flags on the rooms that are private. I think the easiest way to do this is on the after entering room script. In that section, just add the script 'set flag' on an object (like the player) and name the flag private. Make sure that you add a script to 'unset flag' when you leave that room. Some coders might tell you that setting flags on the player is unwise, so if you want to set a flag on something else, just set it on any other object in the game. Hell, you could create an object called 'private', make it invisible, and just use it to set/unset a private flag.

You have two options, I think, for changing your clothes. you can add a global command and type - change clothes; change shirt; switch clothes - etc (whatever you want as an accepted synonym for changing clothes) and run an 'If' script and select 'if object has flag' object (wherever you placed the flag (player?) named private, 'then' run your proper scripts.

Option 2 - add the verb 'wear' to whatever objects the player has that they could wear. Check to see if your private flag is set, and run the proper scripts. Else print message "This room is not private enough to strip down to your birthday suit. Try another room."

If you need more help, I'd be glad to post code or send you a small sample game.

Good luck.


Thanks a lot, you two, the flags thing worked exactly as I wanted! I was actually trying the flag thing, but I didn't know where to put it in the room's script tab, or that there had to be a remove flag on exit.

Xanmag, your option 2 worked for me just fine, thanks!


unfortunately, making a game requires use of scripting (Attributes and the 'if' Script usage), as this (Attributes and the 'if' Script usage) is the 'bread and butter' of coding/scripting/game-making, but the good news is that just learning this (Attributes and the 'if' Script usage), enables you to do 90% of everything that you want to do-in/put-into your game!

here's a link to a guide on it, though it's a bit code heavy, and will probably be difficult to understand/follow (ask and I'll help you with understanding whatever, when I have the time: busy with school/school-work, lol):

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
or
https://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk


and here's a step by step walkthrough guide demo game for you to learn the basics of Attribute usage:

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help
or
https://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help


the basic concept is this:

  1. you need indicators/flags (Attributes) on your rooms, for being able to determine whether they're private rooms or not (or non-private/other rooms)
  2. so that you can then 'check' (the 'if' Script) them, to determine what you do, for example: if room is 'indicated/flagged' as 'private', then enable the changing of your clohes, else, prompt them that they can't just start taking their clothes off in front of everyone!)

a quick example (using Boolean Attributes, and the bit more advanced usage of 'Object Types / Types', which are quest's user-level 'groups/classes'):

<object name="room_1">
  <inherit name="room_type" />
</object>

<object name="room_2">
  <inherit name="room_type" />
  <attr name="is_private" type="boolean">true</attr> // this over-rides/over-writes the: room_type 's Value of 'false' for the 'is_private' Boolean Attribute, with the value of 'true', thus effectively (see the 'change_clothes' Script Attribute's scripting in the 'room_type' type/Object-Type tag block below) making the room 'private', instead of 'public'
</object>

<type name="room_type">
  <attr name="is_private" type="boolean">false</attr>
  <attr name="change_clothes" type="script">
    if (GetBoolean (this, "is_private")) {
      // your scripting for removing/wearing/changing your clothes
    } else {
      msg ("What are you doing/thinking?! This is not a private room! Are you an exhibitionist?! Do you want to go to jail?!")
    }
  </attr>
</type>

<verb>
  <property>change_clothes</property>
  <pattern>change_clothes</pattern>
  <defaultexpression>You can't change your clothes here!</defaultexpression>
</verb>

// you'd be able to change your clothes in: room_2, and NOT be able to change your clothes in: room_1

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

Support

Forums