You can definitely set a variable to be equal to whatever the current value of another variable is, but as far as I know you can’t tie them together. If you did something like this:
*create hair
*create other_guys_hair
*set hair “red”
*set other_guys_hair hair
*set hair “plaid”
After that segment of code runs, hair will contain the value “plaid”, and other_guys_hair will contain the value “red”. By the way, how I “*set other_guys_hair hair” is how you set a variable to hold the value of another.
As for that second part with setting variables to combinations of strings and variable values… that’s harder than you’d think. You can’t just use ${variable} to put the variable’s value into the string - you’ve got to end the string, and then put a “&” between the string and the variable. Example:
*create hair
*create stringadditionisannoying
*set hair “red”
*set stringadditionisannoying "I wish it was easier to say that your hair is " & hair
Don’t forget to leave a space at the end of the string so it doesn’t say “hair isred”. This doesn’t look bad, but it gets much worse when you have more than one “segment” to add to the thing. Choicescript only combines pairs of segments. Its way around that is combining a pair of segments, calling it a new segment, and then pairing that off with another segment. It figures out segments using the “(” and “)” guys. So if you wanted the last code I showed you to end in a period, you’d need to rewrite it as something like:
*create hair
*create stringadditionisannoying
*set hair “red”
*set stringadditionisannoying ("I wish it was easier to say that your hair is " & hair) & “.”
Gets so much worse when you have more than just one variable to include.
Anyway, back to your question. You cannot make a variable’s value depend on another variable’s, but you can make a pseudo-nested variable. Sort of. Just update your variable that has another “nested” in it every single time you call that variable. Alternatively update it whenever you change the value of the variable nested within it - whichever is easier depends on which one involves fewer updates. To make life easier and prove to the world that you are a fancy-pants, you can use the magical *gosub command when doing this. That command lets you make mini-programs within your program that your program can call whenever. So if you don’t want to retype something like below each and every time you update something big…
*set scenery ((((“Wow, look at all the " & wild_animals) & (”! You feel so with nature here, with your " & relationship_level)) & ((" " & lover_name)) & ((", the most popular " & lover_gender)) & ((" at " & school_name) & “!”)) ))
…then you don’t have to. Don’t yell at me if the I messed up the parentheses - I don’t really care. Anyway here’s how you do *gosub:
How is your date going?
*choice
#My date with Jessica is terrible
*set stuff (not important to include that code in demonstration)
*gosub update_scenery
*goto lovers_death
#My romantic outing with my husband Jamal (who goes to school with me) is great
*set stuff
*gosub update_scenery
*goto lovers_death
#I’m having a good time with my friend Jamie
*set stuff
*gosub update_scenery
*goto lovers_death
*label update_scenery
*set scenery ((((“Wow, look at all the " & wild_animals) & (”! You feel so with nature here, with your " & relationship_level)) & ((" " & lover_name)) & ((", the most popular " & lover_gender)) & ((" at " & school_name) & “!”)) ))
*return
You set up the subroutine (mini-program) like it is a label, but add a *return to the end of it so you go back to wherever you called the *gosub. It doesn’t only make it easier to read - it also makes it easier to debug and edit. If there’s a typo or you want to add or remove something, you don’t have to go looking around and find every single instance of *set scenery. You do, however, have to put a copy of the subroutine in every single text document/scene that you use it in. I usually put my subroutines at the end of my programs to make it all neat and stuff.
Random note - that whole pairing with parentheses rule thing I mentioned earlier… you need that for big if statements too, like *if ((hair = “red” and hair2 = “blue”) and hair3 = green)
Hope this helped, wasn’t waaay too long, and didn’t miss anything. Good luck with Choicescript (you’ll get the hang of it, don’t worry), and I look forward to seeing what you make.
Oh yeah, and before I forget, some nice tutorial stuff:
You’ve probably already read this - http://www.choiceofgames.com/make-your-own-games/choicescript-intro/
But have you read this? - http://www.choiceofgames.com/make-your-own-games/choicescript-advanced/