Page 1 of 1

Character Stats Question [SOLVED]

Posted: Sun Aug 14, 2022 5:55 pm
by Pink_Juicy
Is it possible to be able to code something like the attachment below? Sort of like those games where in the beginning you can customize the character's stats :D

Re: Character Stats Question

Posted: Sun Aug 14, 2022 6:27 pm
by laure44
It can be quite simple to do.

You'd need a few variables and a screen.

Code: Select all

default stat_kindness = 0
default stat_strength = 0
default stat_magic = 0
default available_points = 5

screen Stats():
    vbox align(.5,.5):
        # You can repeat the below for each stat
        hbox:
            text "Kindness"
            null width 30
            textbutton "-":
                action SetVariable("stat_kindness", stat_kindness-1), SetVariable("available_points", available_points+1)
                if stat_kindness <= 0:
                    sensitive False # Only if you don't want the stat to be below 0
            text str(stat_kindness)
            textbutton "+":
                action SetVariable("stat_kindness", stat_kindness+1), SetVariable("available_points", available_points-1)
                if available_points <= 0:
                    sensitive False
        text "Available points: [available_points]"
That's just a basic code, I'd also recommend checking the documentation to customize the appearance of your screens.

Re: Character Stats Question

Posted: Sun Aug 14, 2022 6:58 pm
by Pink_Juicy
laure44 wrote: Sun Aug 14, 2022 6:27 pm It can be quite simple to do.

You'd need a few variables and a screen.

Code: Select all

default stat_kindness = 0
default stat_strength = 0
default stat_magic = 0
default available_points = 5

screen Stats():
    vbox align(.5,.5):
        # You can repeat the below for each stat
        hbox:
            text "Kindness"
            null width 30
            textbutton "-":
                action SetVariable("stat_kindness", stat_kindness-1), SetVariable("available_points", available_points+1)
                if stat_kindness <= 0:
                    sensitive False # Only if you don't want the stat to be below 0
            text str(stat_kindness)
            textbutton "+":
                action SetVariable("stat_kindness", stat_kindness+1), SetVariable("available_points", available_points-1)
                if available_points <= 0:
                    sensitive False
        text "Available points: [available_points]"
That's just a basic code, I'd also recommend checking the documentation to customize the appearance of your screens.
nice!!! thank you!! also, how do you set max points for certain stats?

Re: Character Stats Question

Posted: Sun Aug 14, 2022 7:14 pm
by laure44
Pink_Juicy wrote: Sun Aug 14, 2022 6:58 pm nice!!! thank you!! also, how do you set max points for certain stats?
Pretty much the same way you set the minimum amount of points, like so:

Code: Select all

textbutton "+":
    action SetVariable("stat_kindness", stat_kindness+1), SetVariable("available_points", available_points-1)
    if available_points <= 0 or stat_kindness == 10: # change 10 to whatever you want, you could also use a variable to set the maximum if you wanted to
        sensitive False