I need help setting up a certain part of my stats screen


#1

So im trying to set up my stats screen to show your relationships status and i was thinking something like this

text Relations
 percent Anemos
*if relationship 0-29
 He is completely against having you here
*if relationship 30-64
 He would prefer you over a group of strangers
*if relationship 65-74
 He considers you a friend
*if relationship 75-89
 You are his one and only he would do anything for you
*if relationship 90-100
 He has a crush on you confession is possible

But I don’t think this would work i checked on the Advanced Stat Screen section I got this:

Use Temp Variables for Weird Values

In Choice of the Dragon, we keep track of wounds as a simple number 0-4, but display it as text, like this:

  • Wounds=0: Uninjured
  • Wounds=1: Battle-scarred
  • Wounds=2: Permanently wounded
  • Wounds=3: Permanently weakened
  • Wounds=4: At Death’s door

We do that by creating a temporary variable to hold the text describing your wounds, like this:

`*temp wound_text
*if wounds = 0
  *set wound_text "Uninjured"
  *goto chart
*elseif wounds = 1
  *set wound_text "Battle-scarred"
  *goto chart
*elseif wounds = 2
  *set wound_text "Permanently wounded"
  *goto chart
*elseif wounds = 3
  *set wound_text "Permanently weakened"
  *goto chart
*else
  *set wound_text "At Death's door"
*label chart

*stat_chart
  text wound_text Wounds`

but all this did was confusing me even more so could anyone help


#2

In my WIP I did it this way:

Life: 
*if life > 90
    You are healthy
    *goto next01
*elseif life > 70
    You have some scratches
    *goto next01
*elseif life >50
    You are injured
    *goto next01
*elseif life > 20
    You are badly injured
    *goto next01
*else 
    You are near death
    *goto next01

Works fine, life is a normal variable set in the startup


#3

First, you need to decide how to call the relationship variable and create it in the startup.txt file. For example, if this character is named Anemos, you can name the variable anemos_rel. So it would look something like this:

*create anemos_rel 30

If you want to display a bar with relationship value, you should do this:

Relations
*stat_chart
    percent anemos_rel Anemos

If you want to display different text for different relationship value, you can try this:

*if anemos_rel < 30
    He is completely against having you here.
*if ((anemos_rel >= 39) and (anemos_rel < 64))
    He would prefer you over a group of strangers.

And so on.


#4

Basically what the example is trying to tell you is this:

The stat you display on the stats page doesn’t have to be the same stat you use to keep track of things in-game. Instead, you can use your in-game stat to change the value of a new, different stat. Then you can display that new stat on your stats page.

In that example, there are two variables. The one used in-game is called wounds, and is a simple numeric stat. That is to say, it only records numbers. The other stat (called wound_text) holds the string of letters that will be displayed on the stats page. So it’s a string variable. Because it holds a string of letters. And potentially mixed letters and numbers, though in this example it’s letters only.

Because the stat being displayed is only used on the stats page, because it’s not being used anywhere else, it doesn’t matter whether it’s a normal (a.k.a. “permanent”) variable, or whether it’s a temporary variable. This example is using a temporary variable to keep the code for the game a little cleaner and tidier.

So the example starts by declaring the temporary variable it will use. It does that like this:

*temp wound_text " "

Or maybe the example omitted the quotation marks? I think you should include them, but whatever. Moving on!

After declaring the temp variable, the example code then gives the temp variable a value based on what the main variable is. That’s the whole section of:

*if wounds = 0
    *set wound_test "Uninjured"
    *goto chart

…and so on, and so forth. That section ends with the *else.

Because this example is not using implicit control flow, after each section of the *if/*elseif/*else code, it includes a *goto command. You don’t need those if you’re using implicit control flow, but you will need them if you aren’t using it.

All those *goto commands point to a single label:

*label chart`

This label is right above the stat chart, so the start chart displays next. And what does it display? It displays the temporary variable! That’s this bit here:

*stat_chart
    text wound_text Wounds

Not carefully: This code sample is putting the wound_text variable’s value in the stat chart, and then displaying that… with a different name. It’s displaying with the name Wounds, even though it’s the wound_text variable.

Now, looking at your stat chart, I see some issues:

  • You need do your *if code before the *stat_chart, not in the middle of it
  • Unless you have a variable named Relations something really weird is going to happen in that part of the stat chart
  • Unless Anemos is the only character the player can have a relationship with, you’ll need some way to keep all the characters’ relationships separate

That said, this is how I would handle your code (My example will use implicit control flow; make sure you adjust it if you’re not using it!):

*temp display_relation " "

*if relationship < 30
    *set display_relation "He is completely against having you here"
*if (relationship >= 30) and (relationship < 65)
    *set display_relation "He would prefer you over a group of strangers"
*if (relationship >= 65) and (relationship < 75)
    *set display_relation "He considers you a friend"
*if (relationship >= 75) and (relationship < 90)
    *set display_relation "Your are his one and only he would do anything for you"
*if relationship >= 90
    *set display_relation "He has a crush on you confession is possible"

[b]Relations[/b]

*stat_chart
    percent Anemos
    text display_relation Anemos

#5

Quick question how would you set this up in startup


#6

Neither my example nor the official example require any changes to your startup.txt. They’re ready to go as-is because they use temporary variables.


#7

and for other names would i change this part to

Ex:

text display_relation Dahlia

and so on?


#8

You’ll want to give each character their own set of variables. How are you currently tracking the various characters’ relationships with the MC?


#9

Open the startup.txt file.
Look at the beginning.
Do this:

*title Title of the game
*author Your name

*scene_list
	startup
	scene_2
	scene_3
	
*comment This is for variables you need to have in text form, like names:
*create string_variable "text"
*comment This is for variables you need to have in numbers, like relationship values, money or skill levels:
*create numerical_variable 0
*comment This is for variables which can only be true or false:
*create boolean_variable true

#10

Like this

 percent Anemos
 percent Kasai
 percent Dahlia
 percent Amanzi
 percent Parents

and

increase Parents +7

as example


#11

So you have variables named after the characters? I’m guessing your startup.txt has a section that looks a little like this:

*create Anemos 0
*create Kasai 0
*create Dahlia 0
*create Amanzi 0
*create Parents 0

The numbers may be (and probably are) different, but something like that, yes?

Okay, so, from there. On your stats page you would (could) basically repeat my example five times, with different variables, once for each character. Then, after all that’s done, you can display the stat chart.

For brevity, I won’t do the complete example, but I can show you the first cycle of each character’s variable, and let you combine that with the previous example to fill them out. So, starting with something like this:

*temp anemos_display " "
*temp kasai_display " "
*temp dahlia_display " "
*temp amanzi_display " "
*temp parents_display " "

Note that you don’t need the specific word “display”, you just need a way to tell your variables apart on sight. It’s really easy to see the difference between Anemos and anemos_display, but anything that easy to tell apart works.

So, from there, you could do:

*if Anemos < 30
    *set anemos_display "He is completely against having you here"

*if Kasai < 30
    *set kasai_display "He is completely against having you here"

*if Dahlia < 30
    *set dahlia_display "He is completely against having you here"

*if Amanzi < 30
    *set amanzi_display "He is completely against having you here"

*if Parents < 30
    *set parents_display "He is completely against having you here"

*stat_chart
    percent Anemos
    text anemos_display Anemos
    percent Kasai
    text kasai_display Kasai
    percent Dahlia
    text dahlia_display Dahlia
    percent Amanzi
    text amanzi_display Amanzi
    percent Parents
    text parents_display Parents

First edit: I spelled Anemos’ name wrong (twice). So that should be fixed now.

Second edit: Yes, I shamelessly used the same text for every character’s worst possible relationship level, even though the gender and plurality will only make sense for some of them. I probably should have guessed, but I chose not to.

Finally, I think it should be pretty self-explanatory when combined with the previous example, but please let us know if it isn’t!


#12

I figured out how to do this now thank you so much :grinning::grinning:

but I have like one more problem completely unrelated to this one but I don"t want to create another topic

So my code looks like this

*page_break

You began to run, thinking quickly where could you hide?
You notice a tall and secluded tree on the far right
You also notice obvious, abandoned, hard to see mine
*choice
   #Run (If you run you have to drop something valuable (-5 Skill or items)

    *set agility -5
    *goto escapec3

   #Hide in mine (20 Intelligence)
     *if intelligence > 19
       *if (power = "Water")
         You stay quiet enough to where they don't notice.

         *set Amanzi +10
         *goto escapec2

       *if (power = "Earth")
         You stay quiet enough to where they don't notice. [i] Relationship with Amanzi increases [/i]

         *set Amanzi +10
         *goto escapec2

       *if (power = "Air")
         You stay quiet enough to where they don't notice. [i] Relationship with Amanzi increases [/i]

         *set Amanzi +10
         *goto escapec2

       *if (power = "Fire")
         You stay quiet enough to where they don't notice. [i] Relationship with Amanzi increases [/i]

         *set Amanzi +10
         *goto escapec2
     *else
         They hear you and kill you before you could explain
         *goto realcheckpoint2

   #Climb the tree (20 Agility)
     *if agility > 19
         *set Amanzi +10
         You stay quiet enough to where they don't notice. [i] Relationship with Amanzi increases [/i]
         *goto escapec2.1
     *else
       *if (power = "Earth")
         Anemos wind spirits see you|They kill you before you can explain

       *if (power = "Fire")
         Anemos wind spirits see you|They kill you before you can explain

       *if (power = "Water")
         Anemos wind spirits see you|They kill you before you can explain

       *if (power = "Air")
         Kasai fire spirits see you|They kill you before you can explain

*goto realcheckpoint2

and the error is

Startup line 911 its illegal to fall into an *else statment you must *goto or *finish before the end of an indented block

My goto is escapec2 and line 911 is the else statment following the mine option


#13

ChoiceScript has no way of knowing how many possible values there are for your variable name power. So it’s thinking this:

What happens if a player has more than 19 intelligence… but doesn’t have one of those power values listed?

Just shove an extra *goto escapec2 in between the last *if (power and the *else. It should be on the same level of indentation as the *if (power, like this:

*if intelligence > 19
    *if (power = "something")
        *goto escapec2
    *goto escapec2
*else

Certainly not the only way to let ChoiceScript know you’ve taken care of every possible variable combination, but it’s an easy way to handle it.


#14

I tried it this way and it said the same thing


#15

So, this “Hide in mine” option tests intelligence?
How about replacing this bit

*else
         They hear you and kill you before you could explain
         *goto realcheckpoint2

With this:

*if intelligence < 20
         They hear you and kill you before you could explain
         *goto realcheckpoint2

#16

Okay i tried it similar to how I did the climb the tree selection but now the climb the tree option has disappeared


#17

Let’s try something a little more complex, then. How about this:

*choice
    #Run
        *goto escapec3
    #Hide in mine
        *if intelligence > 19
            *if power = "Water"
                *goto escapec2
            *elseif power = "Earch"
                *goto escapec2
            *elseif power = "Air"
                *goto escapec2
            *else
                *goto escapec2
        *else
            *goto realcheckpoint2

#18

What about the text that goes with it ?


#19

I didn’t see any problems with it, so I’m confident you can add it back in (add your +stat statements too!) without any problems. If you’re not as confident as I am, I can go back through and add it for you. Would you prefer that?

I just wanted to get the structure of the code (which was causing the problems) nailed down and clean first. The text still goes in the same places it was before.


#20

that would help alot thank you