How to Run Script "If Player is wearing object"?

Hi, everyone! I'm super, super new at Quest (like, I've been doing this a week), so I apologize if this question is incredibly simple. I'm using the browser version of Quest, and have barely ventured into the code view—I'm mostly sticking with the drop-down menu stuff for now.

My question is about making objects wearable. I've already checked the "Wearable" box in the Features tab of my objects (dark gray uniform and light gray uniform), and I've put them in the same wear slot so that only one can be worn at one time—all of that's working great. The problem comes when I want to, for instance:

  1. Allow the player to pass through a door only if they're wearing the dark gray uniform, or
  2. Change the command "look at self" text depending on what the player is wearing.

As far as I can tell, there isn't a drop-down option in the "If" script that allows me to select "If player is wearing object." I also considered using object flags to get around this (when player puts on a uniform, set flag "dark gray worn" or something like that), but there also doesn't seem to be a place on the Wearable menu to run any scripts—it's all done automatically by Quest.

Anyone have any idea if I can do this using just the browser version? Please let me know! And thank you.


I think the graphical interface has a condition to check an object's flag. The flag you want to check is called "worn".

You may also want to check that the player contains the garment; though this shouldn't be necessary, as I think the core wearables system will take care of making sure the player takes an item off before dropping it.


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


  1. GUI/Editor's scripting (within your 'door' Object and/or its associated Exit's Scripting/Verbs of some kind):

(replace my all upper case stuff with what you named it in your game or do what it says, lol)

run as script -> add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [EXPRESSION] NAME_OF_OBJECT.worn

-> then, -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable player.parent = [EXPRESSION] NAME_OF_DESTINATION_OBJECT

else,

-> add new script -> 'output' section/category -> 'print a message' Script -> (see below)

print [EXPRESSION] "Sorry, but you can't go through the door, as you're not wearing " + NAME_OF_OBJECT.name

  1. 'player' Player Object -> 'Player' Tab -> 'Look at' object description: [RUN SCRIPT] -> ( see below)

(this is the 'pov_look' String/Script Attribute for when you're controlling this character, the normal: 'player' Player Object -> 'Setup' Tab -> Description: Look at [TEXT/RUN SCRIPT], aka: the 'look' String/Script Attribute, is for when you're NOT controlling it)

add new script -> 'scripts' section/category -> 'if' Script -> (see below)

if [EXPRESSION] NAME_OF_OBJECT.worn

-> then, -> add new script -> WHATEVER_SCRIPTING/SCRIPT(S)_YOU_WANT_TO_DO_FOR_WHEN_YOU'RE_WEARING_IT

else,

-> add new script -> WHATEVER_SCRIPTING/SCRIPT(S)_YOU_WANT_TO_DO_FOR_WHEN_YOU'RE_NOT_WEARING_IT


Thank you so, so much for your replies! That worked like a charm, and my uniforms are now working perfectly. Thanks again!


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

Support

Forums