Weird Values in the Stats Screen


#1

Hello, I am trying to configure my stats screen. It is working fine for words and displaying simple numbers and percentages. However I am having trouble with some “Weird Values” as the instructional page on the site calls them. There are five weird variables. The expected preset words do not appear for the heart, style and wounds variables but they DO for the rebellion and vengeance variables. This must mean I have done something wrong for only the 3 wrong weird values.

This is my choicescript_stats.txt file:

*if rebellion_text = 0
*set rebellion_text “Icon of the Rebellion”
*goto chart
*elseif rebellion_text = 1
*set rebellion_text “Quellar of the Rebellion”
*goto chart
*elseif rebellion_text = 2
*set rebellion_text “Unable to Take a Side”
*goto chart
*else
*set rebellion_text “Uninvolved”

*if vengeance_text = 0
*set vengeance_text “Unavenged”
*goto chart
*else
*set vengeance_text “Avenged”

*if heart_text = 0
*set heart_text “”
*goto chart
*elseif heart_text = 1
*set heart_text “In Love”
*goto chart
*else
*set heart_text “Heartbroken”

*if style_text = 0
*set style_text “Wizard Staff”
*goto chart
*elseif style_text = 1
*set style_text “Bow and Arrow”
*goto chart
*elseif style_text = 2
*set style_text “Two Handed Blade”
*goto chart
*elseif style_text = 3
*set style_text “Sword and Shield”
*goto chart
*elseif style_text = 4
*set style_text “Dual Blades”
*goto chart
*elseif style_text = 5
*set style_text “Net and Trident”
*goto chart
*elseif style_text = 6
*set style_text “Spear”
*goto chart
*else
*set style_text “Hand to Hand”

*if wounds_text = 0
*set wounds_text “Uninjured”
*goto chart
*elseif wounds_text = 1
*set wounds_text “Scarred”
*goto chart
*elseif wounds_text = 2
*set wounds_text “Injured”
*goto chart
*elseif wounds_text = 3
*set wounds_text “Seriously Injured”
*goto chart
*else
*set wounds_text “Dying”
*label chart

*stat_chart
text Name
text Gender
text Age
percent Leadership
percent Intelligence
percent Attractiveness
percent Strength
percent Dexterity
percent Magic
percent Cunning
percent Constitution
percent Luck
percent Likability
percent Spontaneity
percent Valour
opposed_pair Pride
Humility
opposed_pair Disdain
Empathy
text wounds_text Wounds
text Rank
text style_text Fighting Style
text ally_name Ally Name
percent ally_loyalty Ally loyalty
text heart_text Heart
text rebellion_text Rebellion
text vengeance_text Vengeance

The incorrect weird values display as:

Fighting Style 7
Heart 0
Wounds 0

This is how I specified them in the mygame.js file.

Please note that NO error messages appear, it is just displayed incorrectly.

Can you spot something wrong because I can’t?

EDIT: Once again there are spaces on some lines which don’t seem to appear here, like text name that should be viewed as " text name".


#2

The trouble is “*goto chart”. Whenever the program hits that line, it skips all the rest of your setup and goes down to the stat chart.

It works the way you expect for these two blocks:

*if rebellion_text = 0
*set rebellion_text “Icon of the Rebellion”
*goto chart
*elseif rebellion_text = 1
*set rebellion_text “Quellar of the Rebellion”
*goto chart
*elseif rebellion_text = 2
*set rebellion_text “Unable to Take a Side”
*goto chart
*else
*set rebellion_text “Uninvolved”

*if vengeance_text = 0
*set vengeance_text “Unavenged”
*goto chart
*else
*set vengeance_text “Avenged”

I’m guessing the default values are Uninvolved and Unavenged; if rebellion_text were 0, 1, or 2, you would have the same problem with vengeance_text because it would go to the chart.

Here’s what you want (with proper indentation of course):

*if rebellion_text = 0
*set rebellion_text “Icon of the Rebellion”
*goto vengeance
*elseif rebellion_text = 1
*set rebellion_text “Quellar of the Rebellion”
*goto vengeance
*elseif rebellion_text = 2
*set rebellion_text “Unable to Take a Side”
*goto vengeance
*else
*set rebellion_text “Uninvolved”

*label vengeance
*if vengeance_text = 0
*set vengeance_text “Unavenged”
*goto heart
*else
*set vengeance_text “Avenged”

*label heart
*if heart_text = 0
*set heart_text “”
*goto style
*elseif heart_text = 1
*set heart_text “In Love”
*goto style
*else
*set heart_text “Heartbroken”

*label style
*if style_text = 0
*set style_text “Wizard Staff”
*goto wounds
*elseif style_text = 1
*set style_text “Bow and Arrow”
*goto wounds
*elseif style_text = 2
*set style_text “Two Handed Blade”
*goto wounds
*elseif style_text = 3
*set style_text “Sword and Shield”
*goto wounds
*elseif style_text = 4
*set style_text “Dual Blades”
*goto wounds
*elseif style_text = 5
*set style_text “Net and Trident”
*goto wounds
*elseif style_text = 6
*set style_text “Spear”
*goto wounds
*else
*set style_text “Hand to Hand”

*label wounds
*if wounds_text = 0
*set wounds_text “Uninjured”
*goto chart
*elseif wounds_text = 1
*set wounds_text “Scarred”
*goto chart
*elseif wounds_text = 2
*set wounds_text “Injured”
*goto chart
*elseif wounds_text = 3
*set wounds_text “Seriously Injured”
*goto chart
*else
*set wounds_text “Dying”
*label chart


#3

FYI regarding indentation: To preserve your indentation of code on the forum, you can put

 before your first line of code and 
after your last line of code. The forum will then highlight your code with a yellow background and preserve the indentation. It will also insert an extra blank line between each of your lines, which is annoying but a small price to pay for being able to show your indentation. Another trick on the forum is to replace leading spaces with dashes, to visually show your indentation that way. Either way works, but I find using the
 tag easier.

#4

Thank you, this has solved the problem. And thanks for the heads up about more easily preserving the indentation.


#5

Just came out of the woodwork an unknown period of time later to say thanks for helping me out. This post actually got me to understand the stat screen. Thanks man.


#6

My brain is getting the best of me… I’m slowly getting my head head around this coding but for some reason the stat screen is doing my head in…
How would I code this?
Psyche =0. Sane
Psyche=1. Unpredictable
Psyche=2. Unstable

What I want to display on the stat screen is

Psyche: Sane

Or whatever number you as the player is…
And is this coded in the start up txt? Or choicescript stat txt? Or a little in both…


#7

So long as ‘psyche’ has been defined in startup.txt as a numeric variable, e.g. -

*create psyche 0

the simplest way to do what you want would be as a series of *if statements exactly where you want the text to appear in choicescript_stats.txt, e.g. -

*if psyche = 0
    Psyche: Sane
*if psyche = 1
    Psyche: Unpredictable
*if psyche = 2
    Psyche: Unstable

#8

Feeling as though I’m one step closer with that thank you, but not quite there.
So in the startup.txt I’ve put

*create psyche 0

Then in the choicescript_stats.txt I got

*stat_chart
text Psyche
*if psyche = 0
Psyche: Sane

Etc. etc.
but the stat screen reads

Psyche: 0
Psyche: Sane

Any way to rid it of the Psyche: 0 line?


#9

*stat_chart is only really needed for displaying percentile bars, which is not what you are aiming for in this case. Try it using only the example code I used above, nothing else at all…


#10

That worked beautifuly, thank you :smiley:


#11

NP. It’s all a learning experience, but it does get easier with perseverance & practice. :slight_smile:

Bear in mind that one handy simple command for the stats screen (in particular) is *line_break, to better display lists of stuff or simply to add extra space for neatness / appearance.


#12

Actually you can clean up the code even more by just having a variable

*create psyche “Sane”

Then just having

Psyche: ${psyche}

In choicescript stats :slight_smile:


#13

@Nocturnal_Stillness Wouldn’t that would make it difficult if you’ve a game that has psyche increases and decreases though? It’s easier to *set psyche +1 during the game and using @Vendetta’s stat screen code, I’d have thought than doing the following every time you need to adjust psyche

*if psyche="sane"
    *set psyche="unpredictable"
*elseif psyche="unpredictable"
    *set psyche="unstable"

#14

Fair point - it’s always worth bearing in mind that there’s usually more than one way of achieving a particular thing. :smile:

In this case though the desired outcome was to display some changeable text based on a numeric variable ranging between perhaps 0-5 (wild guess!) and in as simple and new-author-friendly method as possible…

Anything more ambitious than this might best be handled with a *gosub though, which would make better use of the suggested ${psyche} string variable to keep the code cleaner in choicescript_stats, at least:


#15

No need if psyche only goes up by 1 or down by 1 it’s just as easy to put

*set psyche “Sane”

And have one line code in the stats. The other way works fine but for each number you add is potentially another line of code whereas in my way it’s only ever going to need

Psyche: ${psyche}

It’s just a way of tidying up code but


#16

Sorry to hijack this thread, but I’m having a similar problem (probably the result of a stupid mistake, but I’ve only just started playing around with ChoiceScript), so if anyone has advice I’d really appreciate it! This is my current stats file:

*if court = 0
  Court: Ignorant. You know little of court affairs or proper conduct.
  *goto combatchart
*elseif court = 1
  Court: Informed. No one could guess at your past now, and you’re beginning to learn useful things about theirs.
  *goto combatchart
*elseif court = 2
  Court: Influential. Your informants and finesse tell you everything you need to know about potential allies and enemies.
  *goto combatchart

*label combatchart
*if combat = 0
  Combat: Helpless. Honestly, your dragon is doing most of the work.
  *goto knowledgechart
*elseif combat = 1
  Combat: Capable. Your prowess in both flight and combat is growing.
  *goto knowledgechart
*elseif combat = 2
  Combat: Heroic. Your skill in battle is renowned throughout the kingdom, and indeed beyond.
  *goto knowledgechart

*label knowledgechart
*if knowledge = 0
  Knowledge: Unschooled. Your knowledge of dragons is derived largely from hearsay.
  *finish
*elseif knowledge = 1
  Knowledge: Academic. You know all there is, and are now embarking on research of your own.
  *finish
*elseif knowledge = 2
  Knowledge: Arcane. You are the kingdom’s foremost expert on dragons, and your bond with your own is unbreakable.
  *finish

The Court option displays correctly (as far as I can tell), but I get an error message telling me the first Combat rank is invalid: Invalid expression, couldn’t extract another token: : Helpless. Honestly, your dragon is doing most of the work. Any suggestions would be awesome :smile:


#17

@Laertes If you’re needing help on your own coding it’s generally better if you start your own thread as opposed to posting on someone elses.

From the wiki (http://choicescriptdev.wikia.com/wiki/Error_messages)

Invalid expression, couldn’t extract another token
If this error occurs, it means you’ve used characters that don’t exist in the english language. Note that most programming languages require you to only use alphanumeric characters that exist in the english language (which means if you use the “alpha” character from the greek alphabet, you’ll encounter this error).

I’m not sure what that has to do with your code though. Your code works fine when I plug it into the IDE and substitute in different values for the variables.

How are you creating/setting the variables?


#18

Sorry, my mistake-- I’ll be sure to do so going forward. All the variables were created at the top of startup.txt (*create court 0, etc) and will be set according to the areas in which the player chooses to specialize (I haven’t reached that stage yet, but the code would just be *set court 1, right?)


#19

Can you copy and paste in the exact code you’re using to create and set the variables? I can’t actually see any errors in any of your above code.