Question About Stats

Hi ChoiceScripters,

I have a question regarding stats for my work-in-progress, 1542: Rise of the Witchhunter. You can see an example of the game here:

https://dl.dropboxusercontent.com/u/122902630/Choice%20Of%20Witchhunters/web/mygame/index.html

So there’s two things I want to do.

Implement languages in the same way Choice of the Vampire (CoV) did so.

In CoV, in the beginning of the game you could choose a character background. Depending on this background, you would be fluent in different languages. If you chose a Choctaw interpreter, you would be fluent in English and the Native American tongue. If you chose a French aristocrat, you would only speak French. Later on, you could learn new languages. I want to do so something similar.

In my game, you can play as a 16th Century Englishman, which means you are fluent in English, French and Latin. Or you can play as a Swiss, which means you can speak German, French, Italian and Latin. Later on, you will be able to learn other languages, for example “Demonese” (the tongue of demons). I am wondering how I can implement this feature in the stats screen.

i.e. How do I allow languages to be added every so often along the course of the game.

Right now I’ve opted for

*set language “English, French, Latin”

But if I want to add Demonese later on, I have no way of doing so.

You’ll probably want to do two things. For displaying which languages you know, you can use concatenation; basically combining two or more text variables. To add a new language, such as Demonese, just do this:

*set language (language & ", ") & "Demonese"

So if you already had language set as “English, French, Latin”, then using the above code would set it to “English, French, Latin, Demonese”

For functionality, you’ll probably have to add true/false variables for each language that will have an effect on the story. So when you come across a part in the story where the person needs to know Demonese, or any other language, in order to talk to someone or read something you can do:

*if (demonese = true)
  I can read this!
*if (demonese = false)
  It's just gibberish.

Do a Boolean stat for each language, eg *create english false, *create demonese false. Then set them true when they’re learned. Have a section in the stat screen headed Languages and lines underneath like

*if english=true
  English
  *line_break

You can also look at the code for CoV to see how Jason did it:
https://www.choiceofgames.com/vampire/scenes/

Wow this is a lot more complicated than I’d hoped it would be. The amount of code in the CoV stats is insane.

I really hope I’ll be able to reverse engineer this, but thanks you two for the replies!

If I understand you correctly, I should begin startup.txt with the following:

*create latin false
*create italian false
*create dutch false
*create danish false
*create magyar false
*create spanish false
*create polish false
*create english false
*create german false
*create irish false
*create french false
*create nahuatl false
*create slavic false
*create demonese false

But how do I make these languages then appear in the stats together? Because I want them to appear like this, for example:

Languages: English, French, Latin, Nahuatl, Demonese

Should I do it like this:

Languages: {Language1}, {Language2}, ${Language3}, et cetera…

I don’t think that would work…

If you’d be alright with displaying them like

Languages:
Latin
Italian
Dutch
Danish
etc.

you could try my very lazy take an an inventory system.
It would basically be like

Languages:
*if (latin)
    Latin
    *line_break
    *goto italian
*else
    *goto italian
*label italian
*if (italian)
    Italian
    *line_break
    *goto dutch
*else
    *goto dutch
*label dutch
*if (dutch)
    Dutch
    *line_break
    *goto danish
*else
    *goto danish
*label danish

etc.
It might not be the most efficient way, but it works and is relatively easy to understand.

Yes, the way I was suggesting was like @Cecilia_Rosewood’s – although you wouldn’t need the goto italian/label italian bit, just a string of *ifs:

[b]Languages[/b]
*line_break
*if latin
  Latin
  *line_break
*if italian 
  Italian
  *line_break

and so on. You’d end up with a vertical list of as many languages as you know.

I can understand why you wouldn’t want that for a character who knows seven languages. So give me a minute, and I’ll edit this post with an explanation of how to do it the way you want to do it (which is also how Jason does it in CoV).

EDIT: OK, you begin startup.txt with all the language Booleans you mention. When someone learns a language in the game, you set that stat to true:

#I spend a year learning Nahuatl!
  *set nahuatl true

and so on. Meanwhile, here’s how I think you’d use concatenation CoV-style in your stats screen:

*temp languages ""
*temp comma false

*if latin 
  *set languages &"Latin"
  *set comma true
*if italian 
  *if comma
    *set languages &", "
  *set languages &"Italian"
  *set comma true
*if dutch 
  *if comma
    *set languages &", "
  *set languages &"Dutch"
  *set comma true
*if danish
  *if comma
    *set languages &", "
  *set languages &"Danish"
  *set comma true
[and so on until you've got through demonese, at which point:]
Language(s): ${languages}.

What’s that all mean? (I’m going to bold-text all variable names below just for purposes of the explanation – they wouldn’t display as bold in the actual code or text).

Basically, you’ve created a variable languages whose sole purpose is to display in the stats screen the list of languages that you know, separated by commas. (If you wanted to display that list anywhere except the stats screen, you’d need to create languages in startup.txt, rather than make it a temp in the stats screen).

It starts as an empty string: “” Then you’ll use concatenation to add new information to the string. Because you want it to be grammatically correct, you’ll use the Boolean variable comma which becomes true as soon as you know more than one language.

So let’s say that your character only knows Dutch and Danish. The program will skim right past Latin and Italian, because the variables latin and italian are still set to false. Comma will also still be set to false, so when it gets to dutch the first thing it reads will be:

*set languages &"Dutch"

This means it will add the letters “Dutch” to the end of the variable languages, turning it from an empty string “” into “Dutch”. It will then set comma to true.

Because comma is now true, when it gets to danish the program will now read:

*set languages &", "

That turns languages from “Dutch” to (you guessed it) "Dutch, ". And when it continues to:

*set languages &"Danish"

you’ll have “Dutch, Danish”

After all that code has turned languages into a string of whatever languages you know, you end that section with the only piece of code that will actually be displayed to the reader of the stats screen:

Language(s): ${languages}.

Which in this case would display as:
Language(s): Dutch, Danish.

Clear as mud? :slight_smile:

4 Likes

This is amazing! Very well explained I think I get it now. Thanks ^^

I finally got round to implementing this and it works like a charm! Thanks again :smile: