How to make a health system like the one from "The War for Magincia"?

Hello, I’m new here, so sorry if I make mistakes.
My question is stated in the title, but here’s a better explanation of it, I want a fraction Health system(for lack of a better name)like the one in the game “The War for Magincia” that changes based on certain situations.

Here’s an example of what I want: 0/100.
How do I achieve this?

I know this was kind of horribly explained so if I need to explain more please tell me.

Assuming I understood it right (never played that particular game)
you first need to create a variable in your startup file

*create health 100

or any other value you want to display
Now you can add it to the stats like this (or however you prefer)

Health: ${health}/100

It should show 100/100
I would recommend writing a *gosub at the bottom of each scene file so the value doesn’t go over 100 or below 0, something like this:

*label health_score
*if health > 100
    *set health 100
*if health < 0
    *set health 0
*return

So a choice could look like this:

*choice
    #OPTION1
        *set health -20
        *gosub health_score
        OUCH
        *goto ouch
    #OPTION2
        *set health +20
        *gosub health_score
        BLAH BLAH
        *goto blah

Remember to always use *gosub after the health value was changed so it won’t display something like 120/100 unless that’s something you want ^^

1 Like

My understanding of gosubs are that you use the *return command to exit a gosub and return to wherever it was called from

1 Like

That is right as far as I know? I am sorry but I don’t seem to understand your question (if there is one in the first place x))

@tiranka is right. War for Magincia uses a variable for maximum health (that can increase throughout the game iirc) and another one for current health.

In the stats page, it just prints as simple text. It does not use the *stat_chart statement.

Health: ${health} / ${health_max}
3 Likes

Sure. sorry. In your example, you have *gotos under what would seem to be the *label. I’m confused why they’re in that order, since I would expect the *label to gennerally be under the *goto, unless you’re just using placeholder text.

Ah I see! That’s purely placeholder text ^^ next time I’ll just use *finish instead of *goto :slight_smile:

Thanks, I’m currently trying to figure this out.

Hello tiranka, thanks for the comment I tried using this code:

[b]Skills and Health[/b]
*stat_chart
    text health/10 Health

But it doesn’t display 10/10, it just displays 1. My health variable is set to 10, so that’s why it is showing 1, but how do I change it to 10/10?

Also thank you for your help.

@cup_half_empty actually already answered that

So you only have to write this in your stat page:

[b]Skills and Health[/b]

${health}/10 Health

Hope that helps :smiley:

1 Like

Actually forget about my previous question, I managed to get it working, but now it displays it like this 10/10: 10. How do I fix it so that it just shows the 10/10 part?

Here’s my new code: text Health ${health}/10

Umm, I get this error: Invalid exspression, couldn't extract another token: ${health}/10

And here’s the code I used: `This is a stats screen!

Personal Information
*stat_chart
text name Name
text gender Gender
text age Age
text background Background

Skills and Health
*stat_chart
text ${health}/10 Health
`
What does this error mean and how do I fix it? Do you know?

[b]Skills and Health[/b]
Health: ${health}/10
2 Likes

When I use it like that I get this error: this line should start with "percent", "text" or opposed pair and when I use it with “text”(like this:text Health: ${health}/10) I get this error: couldn't extract another token: :

I assume you wrote this?

[b]Skills and Health[/b]
*stat_chart
    Health: ${health}/10

If that is the case (which I assume, because otherwise the error you mentioned wouldn’t occure)

You don’t use the *stat_chart here. You only have to delete that part and it should work. You really only have to write it exactly like @Szaal wrote it

1 Like

It worked! Thank you both so much for your help, I really appreciate it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.