Two coding questions


#1

Hey! There are two coding questions I’ve been unable to find an answer to. Any help is appreciated.

How would you go about using “ifs” to display (or not display) regular text? For example:

*if happiness > 20
You’re a really happy person, aren’t you?
*else
You’re pretty miserable and I pity you.

*page_break

Is it possible to append text to a string? For example:

*choice
#Steal his money.
*set inventory + “, A roll of paper-money”

*page_break

Thanks!


#2

*if happiness>20 You're a really happy person, aren't you? *goto next_part_of_your_story *else You're pretty miserable and I pity you. *label next_part_of_your_story

Alternatively you can use:

*if happiness>20 You're a really happy person, aren't you? *if happiness <21 You're pretty miserable and I pity you.

Both will only display the text depending on your happiness level.

As for appending text to a string, I don’t know if it would work like that but I wouldn’t want to. I would use an individual variable for each part of your sentence. That way the sentence could be changed as you see fit. To have the variable display nothing for default you can set it as “”


#3

First, you’ll want to start here (if you haven’t already):


(Notice the navigation on the right side of the screen to ‘advanced choicescript’ and other links)

About your first question: I’m not quite sure what you’re asking. It seems to me that your example is answering your own question (or I’m completely missing what your asking).

About the second, it’s:
*set inventory &", a roll of paper-money"
or
*set inventory old_inventory&", a roll of paper-money"
Be careful with this, as you can’t ‘redact’ the addition later. It might be better to handle it as a number of different true/false variables and only combine them when you’re going to display them. See how Choice of the Vampire handles languages here for an example: (http://www.choiceofgames.com/vampire/scenes/choicescript_stats.txt)

Third (a minor thing): If you put < code> before the first line of your code and < /code> after it, the forum will keep the indentation in place (it’ll appear as andymwhy’s did). Remember that proper indentation in choicescript is important.


#4

Thanks, to the both of you. I tried both methods out and sure enough, they worked. I’ll also take your advice on the appending; better to be safe than sorry.

I’ll be more careful with how I format my post next time, Reaperoa, thanks for the tip. :slight_smile: