Ultimate Noob Coding


#161

I had been fairly confident that specific variation worked everywhere except inside of a choice, but after testing it, that definitely works too.

I believe *selectable_if statements go on the same line as the #option. So something like *selectable_if (palmcomm) #Create a distraction instead of the current “next line, with indent” that *if calls for.

Edit: No, I don’t actually know how it combines with *disable_reuse or *hide_reuse. I should test that. Yes, it probably will mess up all your indentation.


#162

I decided I liked the selectable_if more than the disable_reuse; I only had one option that required the redo, and I don’t think it needed selectable if.

But yeah, combining the two didn’t work at all.

Does *else still work with *selectable_if, or only *if?


#163

It appears to work as *disable_reuse *selectable_if (palmcomm) #Create a distraction.

It absolutely does NOT work as *selectable_if (palmcomm) *disable_reuse #Create a distraction.

I believe *else works correctly with both *if and *selectable_if.


#164

Just accidentally deleted a long paragraph. Is there an undo function in CSIDE, or do I just need to retype or restore from an old save?

Edit: nevermind, disregard.


#165

I have a variable set earlier to assign a 1 to mountain, and if that happens it should go to DUck Mountain. Otherwise, Drake Valley. But my playtests seem to always be sending me to Duck Mountain. However, I know it’s not always putting a 1 there, because if I choose the town option I still get the Duck Mountain sign, but the bad joke is the one that would fit for the town (which only shows up if mountain does not equal 1). So I think the issue has to be in this patch of code. Any thoughts?

*if (mountain = 1)
    *goto survivorexperiment
*label survivorexperiment
“Duck Mountain Research Facility.  Trespassers Will Be Shot.  Survivors Will Be Experimented Upon*.”  A/F points at the bottom of the sign.  In small print there is another message. “*-Non-Survivors Will Also Be Experimented Upon.”
*goto settlementchoice
*if (mountain /= 1)
    *goto placetodie
*label placetodie
“Drake Valley: A Great Place to Live!” is what the sign once proclaimed.  But someone has slashed through the word Live with dripping black paint, and written Die over top of it.  Underneath this makeshift proclamation of Drake Valley as a suitable place for expiration, you find a more direct warning: “Not Safe!  Stay Away!”
*goto settlementchoice

#166

Would this be better?

*if (mountain = 1)
    “Duck Mountain Research Facility.  Trespassers Will Be Shot.  Survivors Will Be Experimented Upon*.”  A/F points at the bottom of the sign.  In small print there is another message. “*-Non-Survivors Will Also Be Experimented Upon.”
    *goto settlementchoice
*if (mountain != 1)
    “Drake Valley: A Great Place to Live!” is what the sign once proclaimed.  But someone has slashed through the word Live with dripping black paint, and written Die over top of it.  Underneath this makeshift proclamation of Drake Valley as a suitable place for expiration, you find a more direct warning: “Not Safe!  Stay Away!”
    *goto settlementchoice

#167

@ParrotWatcher is correct. *label is basically like a bookmark. You can jump to it with a *goto command, as you have used it. However, you can also get to it just through the natural progression of the story. As such, in the code you have, you will always get the duck research facility text.

Effectively, the way you have it written is:
If mountain = 1, goto duck mountain text.
Else, duck mountain text.

The *if (mountain != 1) text is never reached.


#168

You put the *label in-between both conditional checks. Of course, this result in something you’re not expecting.

Think of it like a laser-scanner scanning your code from top to bottom. In your code, doesn’t matter if
mountain = 1 or not 1, the *label survivorexperiment will always be encountered.

Try something like this instead.

*if (mountain = 1)
    *goto survivorexperiment
*if (mountain != 1)
    *goto placetodie

*label placetodie
asdfi;jaskl;dvnioea
*goto settlementchoice

*label survivorexperiment
iouhvne;idsk;io
*goto settlementchoice

P.S. It’s *if (mountain != 1) :heavy_check_mark:, not *if (mountain /= 1) :x:


#169

So once these variables are set, how do you go about using them in the text itself? Do I just write *he and it fills in the appropriate gender?


#170

You’d write ${he_she} which prints whatever the variable happens to be ($!{he_she} to capitalize). So, if you’re dealing with an mc and an npc that could be either gender, you’d write your code something like:

$!{ahe_she} finally sees you and introduces you to the others. "This is $!{name}, ${he_she}'s a good friend of mine."
You glare at ${ahim_her}. If you were really ${ahis_her} good friend, ${ahe_she} might have invited you in the first place.

The pronouns will be replaced with whatever you’ve set them as – just don’t get the npc and mc variables mixed up!

(Oh, and you can see in this example why I’m not just naming my variables he, his, him – there are differences between pronouns you don’t see unless you put both next to each other. his_her and his_hers are different, just as him_her and his_her are different!)


#171

I get around the his/her and his/hers by using the characters name for possession every time.

The alternative workaround is to think of all genders as female and use her and hers as the variable names, with his as the male alternative for both.


#172

But you’d also want a “her” that’s the opposite of “him,” no?


#173

Why not just use singular “they” instead of either of the traditionally gendered sets of pronouns? Both the traditionally masculine and traditionally feminine pronouns have repeats, but neither singular nor plural “they” pronouns do.

They - She - He
Them - Her - Him
Their - Her - His
Theirs - Hers - His

See? No repeats in “they” pronouns! Only “she” and “he” pronouns repeat. Sure, there are other ways to work around the repetition. I can’t help but think, however, that all the alternatives are more either work or greater risk of confusion than simply naming your variables with the pronoun set that doesn’t have the problem because it doesn’t repeat.

Think about how easy to implement and use it will be.
*fake_choice
    #Non-binary.
        *set gender "non-binary"
        *set they "they"
        *set them "them"
        *set their "their"
        *set theirs "theirs"
    #Female.
        *set gender "female"
        *set they "she"
        *set them "her"
        *set their "her"
        *set theirs "hers"
    #Male.
        *set gender "male"
        *set they "he"
        *set them "him"
        *set their "his"
        *set theirs "his"
Or, alternatively, set your gender variable as numeric instead of string...
*fake_choice
    #Non-binary.
        *set gender 1
    #Female.
        *set gender 2
    #Male.
        *set gender 3
...then use multireplace operators instead of variables for pronouns.
@{gender They go|She goes|He goes} to the farmers' market every Saturday morning at 8 sharp.
...
What are you doing? Give @{gender them|her|him} the damn book already. It's [i]@{gender theirs|hers|his}.[/i]
...
@{gender They're|She's|He's} gonna crash! Run!
Multireplace would even work in gendered phrases that aren't pronouns...
I cannot believe the nerve of that @{gender child|girl|boy}.
...
I need a word with the @{gender youngster|young lady|young man}. In private, if you please.
...
Thank you, @{gender Ser|Miss|Sir} ${name}. That will be all for today.

I’m actually fairly fond of numeric gender variables working with multireplace primarily for that last reason. Think about all the extra garbage variables or *if statements you need to properly keep track of things like she reaches versus they reach, or she swings versus they swing. And of course she is and she was versus they are and they were, too. And the contractions of all those as well!


#174

I’m this :+1:t4:

But I’m not this :frowning_face:


I guess… I walked down the path of “the most complicated system” at here.


#175

Hello again, gang. Got a thought on those beloved if/else things. Will it work to have multiple qualifiers for an *if, such as this example: *if (alexi =1 and arlship < 6)

And follow-up to that, does it matter if you do three or four *ifs before you finally have an *else? Or is the *else itself not necessarily needed?


#176

I believe each condition for the *if statement has to be in its own set of parentheses like so:
*if (alexi =1) and (arlship <6)

does it matter if you do three or four *ifs before you finally have an *else?

Maybe? It depends on what you want ChoiceScript to do. While there shouldn’t be any error messages from stringing several *if statements in a row before using *else, you’ll need to put *goto commands under every *if you don’t want to display simultaneously with the *else.

For example, if you have…

*if gloves = 0
    You're not wearing any gloves.
*if gloves = 1
    You're only wearing one glove.
    *goto next_label
*else
    You're wearing both gloves.
    *goto next_label
*label next_label

ChoiceScript will allow it to run, as only the final *if is associated with the *else. However, the *else will “sweep up” all values for the gloves variable that aren’t gloves = 1. As a result, because 0 isn’t 1, it will trigger the *else, displaying BOTH “You’re not wearing any gloves.” AND “You’re wearing both gloves.”

If you took that example and added another *goto under the first *if, then you’d only get one line to display at a time. Like so:

*if gloves = 0
    You're not wearing any gloves.
    *goto next_label
*if gloves = 1
    You're only wearing one glove.
    *goto next_label
*else
    You're wearing both gloves.
    *goto next_label
*label next_label

I hope that’s clear enough to help. Please say something if it isn’t!

Or is the *else itself not necessarily needed?

The *else is not strictly needed, and leaving it out can make things much easier as the *goto commands become optional, however you’ll need to be much more careful to ensure all possible values for the variables in question have a piece of code ready to handle them, and won’t simply be skipped over.

Going back to my gloves example, if 0, 1, and 2 were the only possible values for gloves, there would be no problem with some code like this:

*if gloves = 0
    You're not wearing any gloves.
*if gloves = 1
    You're only wearing one glove.
*if gloves =2
    You're wearing both gloves.

But that would be pretty bad if there was a chance gloves could be 3! What would happen then? Absolutely nothing, that’s what. Still, so long as you’re prepared, it should be fine.


#177

Yes, you can do multiple qualifiers, but you have to put parentheses around them in a very specific way.
*if ((alexi = 1) and (arlship < 6))
There are a few more examples in this thread, with more variables. In some places, just making an additional variable might make more sense.


#178

Else and elseif are not vital anymore and you can live without hem both. I think it’s good to understand how they work so you can read your own code better so let’s take a look at examples with and without them.

First, with *else and *else_if

*create fruit "apple"
*create fruit colour "red"

You see two fruit trees, one with delicious apples and another with tasty pears.  You pick a fruit.  Which one do you take?
*choice
  #Apple
    Do you pick a red apple or a green one?
    *choice
      #Red
        *goto fruit_story
      #Green
        *set fruit_colour "green"
        *goto fruit_story
  #Pear
    Do you pick a British green pear or a Chinese yellow pear?
    *choice
      #British
        *set fruit_colour "green"
        *goto fruit_story
      #Chinese
        *set fruit_colour "yellow"
        *goto fruit_story

*label fruit_story
You take the
*if fruit_colour = "red"
  red apple and take a bite.  It is delicious.
  *goto last_part
*else_if fruit colour = "yellow"
  yellow pear and take a bite.  It is delicious.
  *goto last_part
*else
  green fruit and take a bite.  It is delicious.
  *goto last_part

*label last_part
Unfortunately it is poisonous, so you die.

Notice that you need to *goto (or *finish) after the condition is met.

Now, only using *if

*create fruit "apple"
*create fruit colour "red"

You see two fruit trees, one with delicious apples and another with tasty pears.  You pick a fruit.  Which one do you take?
*choice
  #Apple
    Do you pick a red apple or a green one?
    *choice
      #Red
        *goto fruit_story
      #Green
        *set fruit_colour "green"
        *goto fruit_story
  #Pear
    Do you pick a British green pear or a Chinese yellow pear?
    *choice
      #British
        *set fruit_colour "green"
        *goto fruit_story
      #Chinese
        *set fruit_colour "yellow"
        *goto fruit_story

*label fruit_story
You take the
*if fruit_colour = "red"
  red apple and take a bite.  It is delicious.
*if fruit colour = "yellow"
  yellow pear and take a bite.  It is delicious.
*if fruit_colour = "green"
  green fruit and take a bite.  It is delicious.

Unfortunately it is poisonous, so you die.

This has exactly the same effect except that all of the *goto statements have been removed. The game will only read the relevant ones.

A word of warning though - if none of the if conditions are possible, then at best, nothing will be displayed and at worst, you could have a bug.

A better practice is to only use *if statements but keep the *goto statements. Also, remove the last *if statement like this:

*create fruit "apple"
*create fruit colour "red"

You see two fruit trees, one with delicious apples and another with tasty pears.  You pick a fruit.  Which one do you take?
*choice
  #Apple
    Do you pick a red apple or a green one?
    *choice
      #Red
        *goto fruit_story
      #Green
        *set fruit_colour "green"
        *goto fruit_story
  #Pear
    Do you pick a British green pear or a Chinese yellow pear?
    *choice
      #British
        *set fruit_colour "green"
        *goto fruit_story
      #Chinese
        *set fruit_colour "yellow"
        *goto fruit_story

*label fruit_story
You take the
*if fruit_colour = "red"
  red apple and take a bite.  It is delicious.
  *goto last_part
*if fruit colour = "yellow"
  yellow pear and take a bite.  It is delicious.
  *goto last_part
green fruit and take a bite.  It is delicious.

*label last_part
Unfortunately it is poisonous, so you die.

This is better because if none of the conditions are met, you have a default outcome. This is essential the same as the *else statement but with less code.

When would errors occur? If instead of giving 2 fruit choices, maybe you add an *input_text command so the player can type a fruit colour. Then, you can personalise the text for the red and yellow fruit, but have a standard reply for other colours. In more practical terms you would be using this with stat numbers where a variable is a number, perhaps a percentage. The more complex the variable, or variables, the more likely you are to get errors. Using the last style for your code is perhaps the best although I tend to use all three.

A final note, the whole example above only uses text rather than numbers so the whole thing could be written much more simply like this:

*create fruit "apple"
*create fruit colour "red"

You see two fruit trees, one with delicious apples and another with tasty pears.  You pick a fruit.  Which one do you take?
*choice
  #Apple
    Do you pick a red apple or a green one?
    *choice
      #Red
        *goto fruit_story
      #Green
        *set fruit_colour "green"
        *goto fruit_story
  #Pear
    Do you pick a British green pear or a Chinese yellow pear?
    *choice
      #British
        *set fruit_colour "green"
        *goto fruit_story
      #Chinese
        *set fruit_colour "yellow"
        *goto fruit_story

*label fruit_story
You take the ${fruit} ${fruit_colour} and take a bite.  It is delicious.

Unfortunately it is poisonous, so you die.

#179

Just a topic for thought.


#180

More fun questions potentially involving *if: I want to have the big bad for this story introduced by listing off what the MC has done up to this point. My ideal would just be to have a big long list of *if statements involving each variable tied to these things (for example, transportcrash if you managed to bring down the troop transport in chapter 3). But each *if has to have a *goto at the end, right? So how can I display all the ones that apply without showing the others, yet having it know when to kick off to the next part of the story?

Also, I want to start running Randomtest and Quicktest since things are getting a trifle long to just keep playtesting everything. I went to run them from the downloaded programs but can’t get them to work. How do you run those tests on your story?