Efficiency of coding variables


#1

Hi, yes so I am starting out in ChoiceScript and yes I am having some initial troubles around gender/name variables (I’ve read all the material I can find on it, which doesn’t address my specific questions around coding efficiency. I want my characters to have a Title, and a Surname, which can be concenated as Title Surname e.g. Sir Percival, Lord Lancelot. However I also want a standard greeting “My Lord”, “My Lady”. All of this seems straight forward then it gets a bit complicated:

-If your title is Sir, people should always address you by your fullname e.g. Sir Percival, which is a variable that already exists.
-If your title is Lord, people should address you by greeting variable “My Lord” but record your fullname as a variable elsewhere within the script.

So is there a way to set the greeting variable to be the fullname variable in the event that the player chooses to be a Sir?

So ideally, later in the script I can just use “greeting” which in that instance will also be “fullname”

Also, can all this be done in my startup file (the setting of variables to be other variables)?


#2

So like this?

Would you like to be called by sir or lord?
*fake_choice
 #Sir
  *set fullname ("Sir"&" ")&surname
 #Lord
  *set fullname "My Lord"
Greetings ${fullname}.

Or…

*if gender = "male"
 *set lord "lord"
*if gender = "female"
 *set lord "lady"
Thank you my ${lord}.

I don’t really understand your question sorry.


#3

The more experienced coders might have mysterious ways but the only way I can think would be a tedious programing of each form of address manually into your text where needed or wanted.

As long as you set each form of address as a name in startup and in the first scene, I do not see why it can’t be done. I just think the amount of coding would outweigh the benefits.


#4

The first part goes

*create name “”
*create fullname “”
*create title “”
*create greeting “”
*create gender “”

#Lady
    *set title "Lady"
    *set greeting "My Lady"
    *set gender "female"
    *goto name

#Sir
*set title “Sir”
*set greeting fullname
*goto name

The problem is *set greeting fullname doesn’t work.


#5

Is the *set greeting fullname before you set your name?


#6

Yes, that might explain the problem.


#7

Those are separate variables that need setting separately in the code - I don’t see anyway but coding each greeting manually within your text.

As I said, I am a novice though; more experienced authors who outrank me might have something mysterious and cool that I don’t have.


#8

Can I concatenate title and name into fullname within my startup text, and does that carry over into the other scenes?


#9

You cannot do it until the player has set their gender and name. They could do this is the startup text though.


#10

Didn’t see this question. Yes it would as long as you *create a variable in the startup scene it will carry over into every single other chapter. And that variable can be changed by using *set


#11

I do not know of any scripted way, setting each individual as a separate entity is the only way I know. One of the AAA coders like @Cecilia_Rosewood will need to come help us I’m afraid.


#12

Your family name is:

*input_text name
*if (title = “Sir”)
*set greeting fullname
*set fullname (title&" ")&name
*goto intro

This doesn’t work either :slight_smile:


#13

You give me more credit than is due, since I quite frankly haven’t got a clue how to do that. There is however a topic about a similar problem


That should probably work for this problem too.


#14

Switch these two around


#15

I believe @Synapse wants it to automatically chose the right greeting depending on the situation (which is quite complicated going the full historical etiquette for medieval societies …

He’ll (She’ll) still need to code the individual occurrences within the text, no matter the complexity, correct?


#16

…I don’t think that’s what they are trying to achieve here. Anyway, @Kelvin seems to know what has to be done, so I’ll just quietly return to the background.

slinks back into the shadows


#17

@Cecilia_Rosewood
"Thank you" bows and steps forward

I think it is not a question about how to set a variable just a question about the order in which to place the set commands.

@Zolataya
I think it may be fixed very easily just by using two variables. Yes if he wanted one variable to always be used and for the variable to figure out which version of itself to use would require a ton of coding but it can be easily done with two variables.


#18

Wouldn’t he need four? Two for each sex?


#19

@Zolataya
You could set them when they choose their sex.

*temp lord "lord"
*if gender = "female"
 *set lord "lady"

My ${lord}.

If you wanted to do that before they set their gender you wouldn’t know which one to use anyway