Ultimate Noob Coding

Anyone know if there is a code character I can insert which will produce a single empty space but still show up as a code symbol when I am writing, like *line_break but for spaces.

You can use unicode empty characters. Discourse forums automatically convert them into common whitespace so I can’t post it here. But take a look at this page. There are different lengths to choose from.

1 Like

For what purpose, if I may ask? Trying to set up a typographical setup?

Its for two things

firstly like this:

You go□
    *if direction = "east"
        east
    *else
        west

with the □ being a blank space so that the sentence runs properly. I know I can just leave a blank space but its good to have a visible indicvato that I remembered the space

The second thing is so I can offset things slightly, as I see there is no way to right align text. It’s a bit of a bodge but like this:

"War, war never changes"
□□□□□□□□□□- Fallout

I think cup_half_empty’s method works (thanks!) since I can do this with it with the little red dots being the empty character indicators:

3 Likes

Another noob question - is it possible to have stat bars of custom maximum value. i.e. not as a percent (out of 100) but say a stat bar which goes from 1 to 20?

Edit: I will add in a second noob question: is it possible to customize the achievements screen, for example to split achievements up by chapter?

1 Like

No, but kind of. You can’t change the range of the stat bar. But you can convert what you have into a percentile value.

*stat_chart
      percent (round((stat_current_value / stat_max_value) * 100)) Stat Name

So 1/20 would become 5%

Sem tĂ­tulo

Alternatively, you can just print it.

Stat Value: stat_current_value / stat_max_value

Stat Value: 1 / 20


No. Unless you tweak CS source code. I’m not sure, but I think the achievements page is generated by ui.js.

2 Likes

The percentage calculations are an interesting way to do it. thanks for the advice.

My work around for the achievements is just to call them things like:

Chapter 1: Stonebreaker
Chapter 2: Stonemender

so the chapter they can be achieved in is visible. I might see about fiddling with ui.js at a later point.

2 Likes

You might want to create a file to visualize the achievements and access it through an option in the stats page. Then you can customise it to your liking. Just an idea.

1 Like

But a good one. Is there a way to use whether an achievement has been achieved or not in an *if conditional? or would I need to set another “achievement variable” to true if the conditions are met for the achievement?

1 Like

You can use *check_achievements. This will generate temporary variables that you can call to—well—check if achievements have been achieved. Then you can display or switch information using if statements. That’s a cool idea.

1 Like

Oh wow, I had not see that there was this command. Thanks a bunch that will make things much easier for my custom screen. Thanks!

1 Like

when you open choicescript, do you have to keep all the comment stuff like *comment Permissions and Limitations under license

No for testing purposes, but when you plan to publish, it’s implied that you have to keep the license in your work. And hiding it behind a *comment seems the proper way.

Okay, hooray for noob coding thread, I have a question:

I recently read in another thread somewhere that using multiple *if’s is not recommended, instead it’s ideal that you use *if in tandem with *else and *elseif. Could someone explain why?

For some reason I’ve stupidly been using *if (var) and *if not (var) instead of just *if and *else, so I guess I’ll have to change that, but what about areas where the text depends on multiple variables? For example, I have a bit of flavor text that has three different variations; one if you were in the elevator, one if you took the stairs, and one where you took the stairs but took your gloves off. Is it appropriate to use multiple *if’s there? Have I unknowingly been making things difficult for myself by using multiple *if’s…?

e.g.
*if (elevator)
  beep beep
*if (lab_off)
  boop boop
*if not (lab_off)
  blah blah

the rest of the text....

Very aware this is somewhat unnecessary, but a good(?) example for the purpose of understanding code. Will edit later :'D

1 Like

From what I’ve learned (and hopefully I’m understanding at least a little bit of this, is that) it’s used to ensure that there will be less pesky bugs. It’s used as a debugging aid and ensures that it doesn’t come up with an error. Error: none of the conditions in Label XYZ applied, is one of them. It is also used so that the code is easier to read.

*else should never be given a specific condition of its own as it essentially means "If none of the above conditions apply, then do this " .

This is taken from the Choicescript Wiki for Else.

1 Like

There a couple reasons why you’d prefere to use if/elseif/else combo in place of consecutive if.

  1. First of all and probably the less interesting one is the performance issue. Granted, it is negligible. Still, when the game engine resolves as true any of the statements in a combo, it skips the rest of it. Whereas if you have consecutive isolated if statements, the engine will resolve all of them one by one. Which leads to the next problem.

  2. Maybe there’ll be more than one statement than resolves as true, but you want to print only the first one. Let’s say you want to print some flavour text depending on the players personality trait stats. You include in the game a series of consecutive ifs, where the text is substancial the same but is worded slightly different for shyness, dauntless, charming and whatnot. If the character reaches more than one of the set thresholds the game would print the more than one of the sentences. In fact, in your example, both the first and the last statements could be printed at once. The result would be:

beep beep blah blah

In order to fix that, you’d have to use intricate conditionals with growing complexity the more statements you have. If/elseif/else just make your life easier.

  1. Finally, as I said above, it just makes your life easier and the code more readable. Sure, you can make do with consecutive ifs, but it’s just a really good practice to use the available tools. Not to mention what @whitebear said, it can also help you set some debugging warnings.
2 Likes

Ah okay, I definitely didn’t consider the situation where multiple variables would read true without me intending, so that makes sense! Thanks very much!

I have a head-scratcher, at least for me uhhhh!

So, I’m working on this WIP and I have a page in the stats screen that says “notes”

I have the player questioning an NPC where the player can ask 5 questions out of 25, and only one question per round (so 5 rounds)

I did not want to use hide_reuse because I wanted it to be more immersive

Also, each question has a unique answer so hide_reuse would have caused the player to go through all the questions and I didn’t want that.

Each answer to a question is tracked with a variable per rounds and the answers are “strings variable”

The questioning rounds goes like this:

Questions

1: Why the sky is blue?
*set round1 “answer1 well I don’t know”
2: Why you did this
*set round1 “answer2 I wanted to”
3: what happen yesterday
*set round1 “answer3 nothing”
4: is this yellow
*set round1 “answer4 no it blue”
5: how old are you
*set round1 “answer5 and so one”

conversations in between and another round of 5 new questions

6: Why the sky is orange?
*set round2 “answer6”
7: Why you said that
*set round2 “answer7”
8: what happen Friday
*set round2 “answer8”
9: is this blue
*set round2 “answer9”
10: how old is he
*set round2 “answer10”

conversations in between and another round of 5 new questions

11: Why the sky is red?
*set round3 “answer11”
12: Why you did that
*set round3 “answer12”
13: what happens today
*set round3 “answer13”
14: is this blue
*set round3 “answer14”
15: how old is he
*set round3 “answer15”

conversations in between and another round of 5 new questions

16: Why the sky is green?
*set round4 “answer16”
17: Why you did this
*set round4 “answer17”
18: what happens Monday
*set round4 “answer18”
19: is this yellow
*set round4 “answer19”
20: and so on
*set round4 “answer20”

conversations in between and another round of 5 new questions

21: Why the sky is red?
*set round5 “answer21”
22: Why you did that
*set round5 “answer22”
23: what happens today
*set round5 “answer23”
24: is this blue
*set round5 “answer24”
25: how old is he
*set round5 “answer25”

At the end of the interview, I displayed the answers to the 5 questions that the player had selected during the 5 rounds.

And asked the player to choose one, and add it to their notes.

Choice
#{round1} *set note1 "{round1}"
#{round2} *set note1 "{round2}"
#{round3} *set note1 "{round3}"
#{round4} *set note1 "{round4}"
#{round5} *set note1 "{round5}"

Hence, the variable note1 will be displayed in the notes of the stats screen.

I did this and it worked, but… it created a never-ending loading bar, when I test the game, whenever I open the stats screen and can’t return to the game.

I passed quicktest and random test…even turn off animation between pages but still get the never-ending loading bar

So, I think the issue might be the fact that I am trying to transcribe one string variable into a second string variable lol.

So I guess the question is, is there another way I can code this? or should I bear with the never-ending loading bar lol

Thanks in advance beautiful people.

Hi! It seems like a really interesting interrogation!

Can I ask that you share the code in the format?

You can put them in a code indent for us to see the actual formatting to help try figure out the issue with three grave ` (key to the left of 1 on keyboard) before and after the code.

1 Like

here you go

  1. List of codes