It's all just one *if after another

If I have a choice, and one, or more of the outcomes of that choice depends on a *if command, can I do that?
So, something like this:

*choice
 #Option 1
*set X
*set X
*set X
 Option 1 text.
  *if X> 60
  Option 1.1 text
 *if Y=70
  Option 1.2 flaver text.
*goto next

Something like that… I have run into a few choices, that I realized needed a *if tag, depending on the personalaty of at least the MC, if not another char. There are 2 characters in this one who have maluable variables. The rest have fixed variables.
Also. When doing something like:

``` Do you put the operator with a space, or directly beside the number/string/ETC?

Yes, you can use as many *if statements as you want to add customized content. Not sure if your code actually looks like what you’ve pasted above, but be sure that you indent correctly. It should look like:

*fake_choice
  #Option 1
    Option 1 Standard Text

    *if (stat1 >= 50)
      Customized text

    *if (stat2 < 20)
      Customized text

  #Option 2
    Etc

Keep in mind that the extra text will ONLY appear under those conditions, and it’s possible that players could see both customized texts if they pass both checks. If you want players to see either one text or the other but not both or if you want players who don’t pass either stat check to see something else, then you need to use *elseif and *else statements.

One more quick note–I opted to use *fake_choice here. I prefer to use fake_choice and/or enable implicit control flow because it allows you to skip the *goto at the end of every #option in a *choice. It makes coding much neater (and more intuitive imo) and eliminates the need for most (but not all) *labels.

To answer your other question, both formats are fine. I prefer to use spaces, but it doesn’t matter. Be sure to use parentheses though.

PS: you should change the topic of this thread to choicescript help rather than writing and content

4 Likes

Yo @ArchivistAlpha096, I changed the tag from #game-development #game-development:writing-and-content to #game-development #game-development:choicescript-help. Hope you don’t mind :slight_smile:

A, NP.
Seems that when I try to do this on my computer, the catagory switcher thingy is a bit messed.
Thanks for change it for me.
Also, is it sad that I had an instinct to indent that last sentence with tabs?

In the same vane. When doing

*If
label text, indent of course.
*elsif, indent of course.
```What's the indent like after? Is there one? Or, does the Elseif act like a label, and reset indent to 0 till you do another *if?

First, you don’t need a *label under your *if statement unless you’re planning to send players to that spot from a different part of the game with a *goto. When you use *if, *elseif, and *else you either need to 1.) enable implicit control flow or 2.) include a *goto after every option

*if (x <= 20)
  Text
  *goto next
*elseif (y >= 50)
  Text
  *goto next
*else
  Text
  *goto next

*label next
Text

This is where the text converges.
_Alternately you can send the player to different *labels depending on which conditions they meet above_
1 Like

Thanks. That makes sence. I will have to go back into the wiki and run through the *if, and *Elceif stuff some more.
Speaking of the wiki, sort of… Stat charts.
I know what the stat_chart command does, but what’s the format to put in stats below? From what I can gather, I got that you would do something like:

  Text name, so, Fred, name.
  % int
  % wis

ETC. Is that correct?

Short answer, no. For one you’re missing the command, and you also aren’t indenting correctly or using the correct terms (% won’t do anything).

I’m just going to post example code from one of my projects. You can find more info about stats directly from COG here.

[b]Profile[/b]
*if ((hair = true) and (headscarf = false))
  *stat_chart
    text Name
    text hair_color Hair Color
    text eye_color Eye Color
    text skin_tone Skin Tone
    text height_d Height
*elseif ((hair = false) or (headscarf = true))
  *stat_chart
    text Name
    text eye_color Eyes
    text skin_tone Skin Tone
*else
  *bug

Note here that the stat screen is customized for the player, but that’s obviously not necessary. “Text” will display number stats as numerals, or you can use “percent” instead.

[b]Personality[/b]
*stat_chart
  opposed_pair awk
    Awkward
    Smooth
  opposed_pair cha
    Charming
    Intimidating
  opposed_pair dir
    Direct
    Subtle
  opposed_pair gen
    Genuine
    Sarcastic
  opposed_pair hum
    Humble
    Confident
  opposed_pair org
    Organized
    Spontaneous
  opposed_pair per
    Perceptive
    Oblivious
  opposed_pair yie
    Yielding
    Stubborn

Opposed pairs, pretty self explanatory

Here is what the first page of this stat screen looks like:


This is at the beginning of the game before any of the profile variables have been assigned a value, so they appear blank.

1 Like

Thanks. It makes a bunch more sence now… I didn’t know about the [B] command till now. I don’t think it shows in the Wiki? Might have missed it though.
Also, when doing _relationship >, is it: _relationship %>, or >%? Or does it matter? I assume it’s like the +%, but not totally sure.

I don’t know what you mean by [B] command. If you mean *bug, you can read more about it here.

As for your question, you shouldn’t use “%” at all, only operators and numerical values.

*if (relationship_x >= 50)
  Text

Edit:
I reccomend that, in addition to the wiki, you give the following resource a good look:

Master List: Links for Beginners

You can also check out the code of other games to help you better understand how choicescript works. Read about how to do that here and here.

1 Like

Fairmath works on this syntax:

*set variable %+ X

where X is the number. It’s %–operator, not operator–%, so gotta keep that in mind.

As for comparison, you never use the %. Simply do “relationship > X,” whichever you want it to be a bigger-than or lesser-than condition.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.