Need help creating a clothing system

Hi everyone, so I’m busy creating a layered clothing system in my game, for instance you can have three different types of tops on at the same time plus a jacket, tights under your pants and socks over your tights etc. That kind of thing. I want to create a way so the game describes what you are currently wearing, so I need a little input.

Also, the undershirt1 variable is the first layer of torso clothing, shirt1 is the second layer and outershirt1 is the third layer.

Two things I have tried is.

*label clothes
*if hat1 = true
    *goto wearinghat
You are currently not wearing a hat
*goto top1
*label wearinghat
Your ${hat} sits comfortably on your head
*goto top1
*label top1
*if undershirt1 = true
    *goto wearingundershirt1
*if (((undershirt1 = false) and (shirt1= false)) and (outershirt1 = false))
    *goto notwearingundershirt
*label notwearingundershirt
and you are currently nude from the waist up
*goto jacket1
*label wearingundershirt1
and you are wearing your ${undershirt}
*if shirt1 = true
    *goto wearingshirt1withundershirt1
*label wearingshirt1withundershirt1
under your ${shirt}
*label jacket1
etc

Which works I think, but it’s pretty hard to keep up with all the labels and what not, and gets confusing the more things you add, and I’m not sure how to incorporate something like shirt length, like say an oversized hoodie that reaches down to your thigh and how to describe that through this type of coding. I also tried the following.

*if ((undershirt1 = false) and (shirt1 = false) and (outershirt = false) and etc, I tried adding like thirteen of these variables in the chain, because I thought it would be easier to follow, as in I could just copy paste the code and change the false variables to positive, like

*if ((undershirt1 = true) and (shirt1 = false) and (outershirt = false) and (etc...)
         *goto wearingonlyundershirt1
*label wearingonlyundershirt1
You are currently only wearing your ${undershirt}

But I don’t understand how the parentheses works with like thirteen different “and”'s. So I keep getting an error for that. Does anyone have some tips for me? I appreciate the help.

*fixed the messy code

2 Likes

Hmm, your code displayed a bit messy.
Mind to tag them with [code] [/code]?

I´m not sure, if this works in Choice script but it sounds like a list and loop thing for me. So you could put als the clothing in one list, and then search through the list. So you may search for trues and if there is only one true, you could use the You are currently only wearing your (result from list) so you don´t have to make the same 13 length long argument for each type of clothing, also when you build the list you could make it start with the less visible clothing, that may help too.

I hope I made myself understandable, my English is not that good.

If you don’t want to have to mess with how many parentheses to put where, you can just put *if statements kind of underneath each other like this:

*if undershirt1 = false
 *if shirt1 = false
  *if outershirt1 = false
   *goto notwearingundershirt

Spacing is important in ChoiceScript, so this sort of thing will work if the spacing is correct.

For starters, I think you can use

*if (hat1)
    You are wearing a ${hat}.
*if not(hat1)
   You are not wearing a hat.

Instead of

*if hat1 = true
*if hat1 = false

Now, for your clothing system. I would go with what @Carlos.R suggested. Group pieces of clothing that go together in pairs or in trios (eg. shirt, undershirt, overshirt) and check them together.

Here’s an example of the code, that should be working:

*if not(hat1)
  You are currently not wearing a hat.
  
*if (hat1)
  A ${hat} is currently resting on your head.

*if (shirt1)
  *if ((undershirt1) and (overshirt1))
    Your ${shirt} is pretty neat!
    
    Underneath your ${shirt} you are wearing a nice ${undershirt} that goes wonderfully with your ${overshirt}.
  *if ((undershirt1) and not(overshirt1))
    Your ${shirt} is pretty neat!
    
    Underneath your ${shirt} you are wearing a nice ${undershirt}.
  *if (not(undershirt1) and (overshirt1))
    Your ${shirt} is pretty neat!
    
    It is even better when paired with your ${overshirt}.
  *if (not(undershirt1) and not(overshirt1))
    Your ${shirt} is pretty neat!
    
*if not(shirt1)
  *if ((undershirt1) and (overshirt1))
    Your ${undershirt} is lovely, especially when you are wearing your ${overshirt}.
  *if ((undershirt1) and not(overshirt1))
    Your ${undershirt} is lovely.
  *if (not(undershirt1) and (overshirt1))
    There's absolutely nothing better than the feeling of your ${overshirt} on your skin.
  *if (not(undershirt1) and not(overshirt1))
    You are wearing nothing from the waist up. Go you!

This is how ChoiceScript handles three variables in a chain:

*if (((shirt1) and (overshirt1)) and (undershirt1))
   You are wearing a ${shirt}, ${undershirt} and ${overshirt}.

Edit: See @Szaal post below, if you want to try more than three variables in a chain.

2 Likes

I hope this works! Cause this is a REALLY AWESOME idea!!!

:kissing: Pssst.

*selectable_if ((((bodybuild != 0) and (bodyheight != 0)) and ((skin_col != "") and (eye_col != ""))) and ((hair_l != 0) and ((hair_t != 0) and (hair_col != "")))) #@{sr ✓|} All done
		*set idok *7
		*set idone true
		*gosub_scene A.Setup log "list_deed" "Filled the form"
		*gosub desc_comment
		*goto p1_IDform
	*if (idok modulo 7) != 0
		#✗ On a second thought, I'll leave out this part for now.

But yeah, it’s a mess to work with a chain of more than 2 pairs of variable checks. Unless you have assassin’s eagle vision to see through those parens or something, I totally discourage you to do that :eyeglasses:

2 Likes

Here’s how I’d do it! :slight_smile:

*create outerlayer false
*create middlelayer false
*create innerlayer false
*create hatlayer false
*create exposed false

...

What are you wearing?
*fake_choice
  # A straw hat.
    *set hat "a straw hat"
    *set hatlayer true
  # A curly wig.
    *set wig "a curly wig"
    *set hatlayer true
  # Polkadot underwear.
    *set underwear "polkadot underwear"
    *set innerlayer true
  # A sweat stained undershirt.
    *set undershirt "a sweatstained undershirt"
    *set innerlayer true
  # Khaki pants.
    *set pants "khaki pants"
    *set middlelayer true
  # A tailored shirt.
    *set shirt "a tailored shirt"
    *set middlelayer true
  # A leather jacket.
    *set jacket "a leather jacket"
    *set outerlayer true
  # A crocodile belt.
    *set belt "a crocodile belt"
    *set outerlayer true

...

Do you want to take off your hat?
*fake_choice
  # Yes.
    *set hat ""
  # No.

...

*if ((hat = "") and (wig = ""))
  *set hatlayer false
*if ((underwear = "") and (undershirt = ""))
  *set innerlayer false
*if ((pants = "") and (shirt = ""))
  *set middlelayer false
*if ((jacket = "") and (belt = ""))
  *set outerlayer false

*if (hatlayer = true)
  *if (hat != "") You're wearing ${hat}.
  *if (wig != "") You have on ${wig}.
*if (outerlayer = true)
  *if (jacket != "") You're covered by ${jacket}.
  *if (belt != "") Around your waist is ${belt}.
*if (middlelayer = true)
  *if (outerlayer = true)
    *if (shirt != "") Underneath, you have on ${shirt}.
    *if (pants != "") You have ${pants} on under that.
  *if (outerlayer = false)
    *if (shirt != "") You have on ${shirt}.
    *if (pants != "") You have ${pants} on.
*if (((innerlayer = true) and (middlelayer = false)) and (outerlayer = false))
  You only have an under layer on!
  *if (underwear != "") You're sporting ${underwear}.
  *if (undershirt != "") Your chest is covered by ${undershirt}.
  *goto observations
*else
  *if (underwear != "") Underneath, you're sporting ${underwear}.
  *if (undershirt != "") Your inner layer includes ${undershirt}.
  *goto observations

*label observations

*if (((outerlayer = false)) and (middlelayer = false)) and (innerlayer = false))
  *set exposed true
  You're totally naked!
  *if (hatlayer = true)
    At least you're covering your head.
  *finish
*elseif ((pants = "") and (underwear = ""))
  *set exposed true
  Your genitals are free to the wind!
  *finish
*elseif (((jacket = "") and (shirt = "")) and (undershirt = ""))
  You've got no shirt on!
  *if (gender = "female")
    *set exposed true
  *finish
*else
  *finish
1 Like

You can have any number of conditionals. You’ll have to use lots of parentheses, though, and here’s how that works.

A connector like and or or has a left and a right side. If the left or the right side has its own and or or, it needs to be surrounded in parentheses.

Wrong!

*if (var1 > 10) and (var2 > var1) and (var3 < var2)

Right!

*if ((var1 > 10) and (var2 > var1)) and (var3 < var2)

And of course each nested and or or has its own left-hand and right-hand side, so the deeper you go, the more parentheses you need.

Next, some of your text is a good candidate for variable interpolation - it’ll be easier to read and maintain (and shorter.) For example, you have

*label clothes
*if hat1 = true
    *goto wearinghat
You are currently not wearing a hat
*goto top1
*label wearinghat
Your ${hat} sits comfortably on your head
*goto top1

Several revisions ago, Choicescript added a feature that lets you handle certain kinds of variant text without using an *if statement. It would look like this:

@{(hat1) Your ${hat} sits comfortably on your head|You are currently not wearing a hat}

If hat1 is true the first text is displayed; if it’s false, the second is. (You can also leave one or the other blank.)

I agree with will’s suggestionabout using variables for layers. I’d also suggest using subroutines for putting clothing on or taking it off, and have the subroutine automatically check whether you already have something in that layer, set the appropriate layer to true/false, etc.

6 Likes

Oops. I definitely didn’t know this. Thank you for the explanation!

Thanks for everyone’s responses so far; I REALLY appreciate all of you. I’ll try some of your ideas and report back with what I could do ASAP.