Ultimate Noob Coding

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


This might seem too obvious to be correct:

You say ${namer2} (with an R) where I’d think it should be ${names2} (with an s), because earlier you say ${names1}. Is this intentional or a spelling error?

1 Like

{namer2} is your police partner/romance option {names1} is the NPC/suspect your are questioning. they are gender flip so I coded the names as variable to avoid too many repeats

Also just to clarify, the codes work, there are no errors when I run tests.

It is just the freezing stats screen and never-ending loading bar lol

Apologies if I’m nitpicking, but it seems that you’re missing some #'s before some choices, or the indentation is wrong.

Additional questions:
Is this on Dashindon?; the ChoiceScript IDE; Notepad++; Notepad?
I’ve taken a look, and I can’t figure out for the hell of me why this is happening. Is it possible for you to share the source scene files so we can run a personal test?

1 Like

Maybe it’s the images causing it to load for so long?

The only other thing I can think of is that perhaps there’s a loop that doesn’t exit?

Mind sharing your fuld stats screen code? This looks like more on the stats screen than the actual code. I think you have infini-loop, here.

1 Like

I think there is a loop too, but I can’t find it, well I added it to Dashington, and just tried to play through it and it was kind of slow but did not get stuck…so like you said it might be the pictures but I don’t know.

*label Main

[b]Identification[/b]
*line_break
Name: $!{Name} $!{Surname}
*line_break
Identify as: $!{Identifyas}
*line_break
Eyes Color: $!{Eyes}
*line_break
Hair: ${type} $!{Haircolor}
*line_break
Hairstyle: $!{hairstyl}
*line_break
${face0} $!{facial1}
*line_break
Accessories: $!{access1}
*line_break
Skin Tone: $!{Skintone}
*line_break
Dominant hand: $!{hand2}
*line_break
Body Frame: $!{bod1}
*line_break
Height: ${hei1}
*line_break
Profession: ${travay}
*line_break
Hobby: $!{hob1}
*line_break
Guilty pleasure: $!{plaisir1}
*line_break
Outfit: ${mctop}, paired with ${mcbottom}. [n/] A pair of ${mcfoot} topped with ${mclay}

[b]Family history[/b]
*line_break
${soc1} ${soc2}
*line_break
${com1} ${com2} ${com3}
*line_break
${par1} ${par2} ${par3}
*line_break
${sib1} ${sib2}
*line_break
$!{sibname} $!{Surname}
*line_break
${pib1} ${pib2}
*line_break
${pibname} $!{Surname}
*line_break
${pib00} $!{pib01} $!{Name}
*line_break


[b]Reasons for being in Kastry[/b]
*line_break
${reason1} ${reason2}


*line_break
[b]Possesions[/b]
*line_break
Car: ${carcolor} ${car1}
*line_break
Cell phone: Motorola razr v3
*line_break
Used for work: ${workdev}
*line_break
Apartment decor: ${apttype1}
*line_break
Apartment type: ${aptstyle1}
*line_break



[b]Mental Health[/b]
*stat_chart
 percent Sanity
*choice
 #Your relationships
  *goto Rel
 #Your Skills
  *goto Skills1
 #The friends
  *goto note1
 #Your notes
  *goto note2
 #Leads
  *goto leads0
 #Clues
  *goto clue0


*label Skills1

*line_break 
${intero1} ${intero2}
*line_break 
Accusatory questions asked: ${hard1}
*line_break 
Investigation related questions asked: ${eff1}
*line_break 
Irrelevant questions asked: ${poor1}
*line_break
Amount of cups of coffee you had: ${caffe1}
*line_break
Amount of Alchool beverages you had: ${alco1}
*line_break


[b]Skills[/b]
*stat_chart
 percent Self_confidence

 percent Critical_thinking_skills

 percent Problem_solving_skills

 percent Details_oriented

 percent Attention_seeker

 percent Ethical_behaviour

 opposed_pair comp1
  Competitiveness
  Teamwork

 opposed_pair Joy1
  Introvertion
  Extravertion

 opposed_pair Sacca
  Joyful
  Sarcastic
*choice
 #Your relationships
  *goto Rel
 #Your personal info
  *goto Main
 #The friends
  *goto note1
 #Your notes
  *goto note2
 #Leads
  *goto leads0
 #Clues
  *goto clue0


*label note1

[b]List of ${sis1}[/b]
*line_break
*line_break
[b]${names1} ${surnames1}[/b]
*line_break
$!{menaj1} of Abigail Greene
*line_break
Originally from Maine
*line_break
Twenty-one years old
*line_break
${s1occu}
*line_break
5'11 Black hair brown eyes
*stat_chart
 opposed_pair bels1
  Truthful
  Untruthful
*if (met_s1=true)
 *stat_chart
  opposed_pair sanitys1
   Sane
   Delusional
*line_break
[b]${names2} ${surnames2}[/b]
*line_break
Best friend of Abigail Greene
*line_break
Originally from Maine
*line_break
Twenty years old
*line_break
${s2occu}
*line_break
5'9 Blond hair blue eyes
*stat_chart
 opposed_pair bels2
  Truthful
  Untruthful
*if (met_s2=true)
 *stat_chart
  opposed_pair sanitys2
   Sane
   Delusional
*line_break
[b]${names3} ${surnames3}[/b]
*line_break
Friend of Abigail Greene
*line_break
Originally from Maine
*line_break
Twenty-one years old
*line_break
${s3occu}
*line_break
5'8 Red hair green eyes
*stat_chart
 opposed_pair bels3
  Truthful
  Untruthful
*if (met_s3=true)
 *stat_chart
  opposed_pair sanitys3
   Sane
   Delusional
*line_break
*choice
 #Your Skills
  *goto Skills1
 #Your personal info
  *goto Main
 #Your relationships
  *goto Rel
 #Your notes
  *goto note2
 #Leads
  *goto leads0
 #Clues
  *goto clue0


*label Rel

[b]Relationships[/b]
*line_break
[b]${namer1} ${surnamer1}[/b]
*line_break
$!{r1race} $!{r1}
*line_break
${menajyou1} ${r1lov}
*line_break
Originally from Maine
*line_break
${r1occu}
*line_break
Eyes color: Hazel
*line_break
Hair color: $!{r1haircolor}
*line_break
Body frame: $!{r1bodyframe}
*line_break
Height: ${r1hei}
*line_break
*stat_chart
 opposed_pair romr1
  Lovers
  Friends
*if (met_r1=true)
 *stat_chart
  opposed_pair sanityr1
   Sane
   Delusional
*line_break
[b]${namer2} ${surnamer2}[/b]
*line_break
$!{r2race} $!{r2}
*line_break
${menajyou2} ${r2lov}
*line_break
Originally from New York
*line_break
${r2occu}
*line_break
Eyes color: Light green
*line_break
Hair color: $!{r2haircolor}
*line_break
Body frame: $!{r2bodyframe}
*line_break
Height: ${r2hei}
*line_break
*stat_chart
 opposed_pair romr2
  Lovers
  Friends
*if (met_r2=true)
 *stat_chart
  opposed_pair sanityr2
   Sane
   Delusional
*line_break
[b]$!{namer3} ${surnamer3}[/b]
*line_break
$!{r3race} $!{r3}
*line_break
${menajyou3} ${r3lov}
*line_break
Originally from New York
*line_break
${r3occu} 
*line_break
Eyes color: Light blue
*line_break
Hair color: $!{r3haircolor}
*line_break
Body frame: $!{r3bodyframe}
*line_break
Height: ${r3hei}
*line_break
*stat_chart
 opposed_pair romr3
  Lovers
  Friends
*if (met_r3=true)
 *stat_chart
  opposed_pair sanityr3
   Sane
   Delusional
*line_break
*choice
 #Your personal info
  *goto Main
 #Your Skills
  *goto Skills1
 #The friends
  *goto note1
 #Your notes
  *goto note2
 #Leads
  *goto leads0
 #Clues
  *goto clue0


*label note2

[b]About the victim[/b]
*line_break
Name: Abigail Greene
*line_break
Originally from Maine
*line_break
Age: 20 years old
*line_break
Description: 5'9, blond hair, blue eyes
*line_break
Occupation: Junior College student at Kastry University
*line_break
Last seen: Saturday October 8, 2005 at Kastry public beach
*line_break
Last seen with: Three friends, ${menaj1}, best friend and a friend
*line_break
Status: [b]${abistat}[/b]
*line_break


[b]Your thoughts about the ${menaj1}[/b]
*line_break
1: $!{s1he_she} was found covered in blood.
*line_break
2: ${s1note2}
*line_break
3: ${s1note3}
*line_break
4: ${s1note4}
*line_break
5: ${s1note5}
*line_break
*image not5.png right
*image not5.png right
[b]Your thoughts about the best friend[/b]
*line_break
1: $!{s2he_she} does not remember anything of the night.
*line_break
2: ${s2note2}
*line_break
3: ${s2note3}
*line_break
4: ${s2note4}
*line_break
5: ${s2note5}
*line_break
*image not3.png none
*image not4.png right
[b]Your thoughts about the friend[/b]
*line_break
1: $!{s3he_she} blacked out right around 11:00 pm.
*line_break
2: ${s3note2}
*line_break
3: ${s3note3}
*line_break
4: ${s3note4}
*line_break
5: ${s3note5}
*line_break
*image not6.png right
*line_break
[b]Your thoughts about the parents[/b]
*line_break
1: ${parnote1}
*line_break
2: ${parnote2}
*line_break
3: ${parnote3}
*line_break

[b]Your progressing thoughts on this case[/b]
*line_break
1: ${prognote1}
*line_break
2: ${prognote2}
*line_break
3: ${prognote3}
*line_break

*if (end1=true)
 *goto end0


*choice
 #Your personal info
  *goto Main
 #Your Skills
  *goto Skills1
 #The friends
  *goto note1
 #Your relationships
  *goto Rel
 #Leads
  *goto leads0
 #Clues
  *goto clue0






*label end0
[b]Your conclusion on this case[/b]
*line_break
1: ${endnote1}
*line_break
2: ${endnote2}
*line_break
3: ${endnote3}
*choice
 #Your personal info
  *goto Main
 #Your Skills
  *goto Skills1
 #The friends
  *goto note1
 #Your relationships
  *goto Rel
 #Leads
  *goto leads0
 #Clues
  *goto clue0


*label clue0

[b]${clue01}[/b]
*line_break
1: The letter
*line_break
2: The picture
*line_break
3: The medical report
*line_break
4: The note
*line_break
5: 
*line_break
6
*line_break
*choice
 #Your relationships
  *goto Rel
 #Your Skills
  *goto Skills1
 #The friends
  *goto note1
 #Your notes
  *goto note2
 #Leads
  *goto leads0
 #Your personal info
  *goto Main


*label leads0

[b]${leads01}[/b]
*line_break
1: The fisherman
*line_break
2: Bitsy
*line_break
3: The supplier
*line_break
4: The hidden ingredient
*line_break
5: 
*line_break
6
*line_break
*choice
 #Your relationships
  *goto Rel
 #Your Skills
  *goto Skills1
 #The friends
  *goto note1
 #Your notes
  *goto note2
 #Clues
  *goto clue0
 #Your personal info
  *goto Main


Okay so I am having a bit of a problem with using the if command in relation to true and false.

#Only the Saxons
*if (Saxon >= 40)
*set Saxon true
*set Army + 20
*goto_scene Final
*elseif (Saxon < 40)
*set Saxon = false
*goto_scene Reject

So it works if Saxon is greater then or equal to 40 but if it’s lets say 30 then I always get the error expected at least one line in if true block

Heyo, you might want to check the code:

I’m not sure what sort of Variable ‘Saxon’ should be. You seem to use it a number, and as boolean, which is fine if it’s intentional. Also, you don’t need a ‘=’ sign when you set something to True or False.

Perhaps also just make sure that the indentation is correct. I think that is most likely the cause of the error.

#Only the Saxons
    *if (Saxon >= 40)
        *set Saxon true
        *set Army + 20
        *goto_scene Final
    *elseif (Saxon < 40)
         *set Saxon false
         *goto_scene Reject

I’d also recommend swapping out the *elseif for just *else, since it’ll always ensure that a condition is run if the first isn’t met.

2 Likes

Please, use the pre-formatted option when posting code. This could be a matter of bad grammar. I tested this block of code with proper indentation and it worked fine, except for this line:

Which should not have = between Saxon and false.

2 Likes

I popped your code to my editor and I don’t think I see any cause of infini-loop here. As a kind of last resort, try refreshing your browser. I think you originally had an infini-looping code and you fixed it, but the game did not refresh on the browser; still using the old code.

3 Likes

I changed it else and got rid of the = but it still gives me the same error

Can you post the exact code here?

#Only the Saxons
*if (Saxon >= 40)
*set Saxon true
*set Army + 20
*goto_scene Final
*else (Saxon < 40)
*set Saxon false
*goto_scene Reject

You can format to maintain the coding indents by using this ‘preformatted text’ option, which will help us figure out the problem a bit;

You can also try to include a little bit of code before and after the little bit that is giving the problem.

image