Quick Question on Clothes
JenniferKline
02 Jun 2021, 22:51Heya all,
I usually manually give the player a series of attributes, i.e "top" "bottom" "bra" "pants" and use If statements figure out what they're wearing, or warning them if they're not properly dressed. For example
if (player.bottom = "") {
if (player.bra = "") {
if (player.panties = "") {
msg ("You are stark naked.")
}
}
else {
if (player. etc etc etc= ) {
Any item that is put on fills out the relevant attribute with a string. It's simple and reliable.
This time I'm trying to use the built-in Wearable system.
What would be the simplest way to determine if a player is or isn't wearing? I can't seem to find what attributes alter when a player puts on a piece of clothing.
It might be that my usual method of doing things is much simpler, but I thought I'd give an ask and see.
K.V.
02 Jun 2021, 23:00Hello.
The only things I know that change are the player's worn
boolean attribute and its alias
gets " (worn)"
added or removed from the end of it, depending on whether donning or doffing.
I haven't fooled with clothing too much, but I happened to fool around with it a little bit last night. It looks like the number we can set is the layer
, and 1 means nothing else can go underneath, and the other field is slot
, where you would put "bottom" or "top" or whatever you decided to use.
https://docs.textadventures.co.uk/quest/wearables.html
Someone with actual knowledge concerning this will more than likely chime in soon (I hope).
JenniferKline
02 Jun 2021, 23:17I think I've found a way around this.
I found Advanced Options for Wearables in Game Features which offers a bonus to player attributes.
I turned the attribute player.top into an integer rather than a string and set in to 0.
Then I set the shirt to give +1 to player.top.
Thus a player wearing a shirt has a top value of 1 and a player without a shirt has a top value of 0.
Now I can use if player.top = 1 or = 0 to determine if they're wearing a shirt or not. Seems like a simple solution, but there might be more direct ways around this that I'm not yet aware of.
mrangel
03 Jun 2021, 09:01The system you'd normally use is probably "slots"
To find out if a player is wearing a particular garment, you can do (for example):
if (GetBoolean (pink shirt, "worn")) {
To find out if a player is wearing anything on a specific body part, you would have a slot named "top", and do something like:
top = GetOuterFor (game.pov, "top")
if (top = null) {
msg ("You are topless!")
}
else {
msg ("You are wearing " + GetDisplayName (top))
}
the function GetOuterFor
gives you the object which has the highest layer for a given slot; so it will tell you what garments an NPC could see.
AdrianHamilton
04 Jun 2021, 10:37Hi, thanks for your question and also the answer to it JenniferKline))) Just like you I turned the player.top attribute into an integer instead of a string and set the value to 0....this made everything very easy!!! Thank you very much