Defining stats in scenes and or stats folder

I am trying to enable stats whereby someone can make some choices on increasing their luck, stamina and health at the start of the game
I have defined these in the startup file and as text in the stats file. Through searching I found the following code from an earlier post in the forum that I think I can adapt

My question is, where do I add the following code? Is it to the top of the first scene (which will bugger up all my indenting), do I create a new scene called choose your stats?

*label init
*set ap 20
*set str 8
*set health 8
*set smarts 8
*set leadership 8
*temp top_limit
*set top_limit 10
*label choose_stats
You have ${ap} AP left to spend to increase your stats. Which stat do you want to increase?
  *hide_reuse #Strength
    How many AP will you spend to increase Strength? (1 - ${top_limit})
    *input_number stat1 1 top_limit
    *set str +stat1
    *goto adjust_ap
  *hide_reuse #Health
    How many AP will you spend to increase Health? (1 - ${top_limit})
    *input_number stat1 1 top_limit
    *set health +stat1
    *goto adjust_ap
  *hide_reuse #Smarts
    How many AP will you spend to increase Smarts? (1 - ${top_limit})
    *input_number stat1 1 top_limit
    *set smarts +stat1
    *goto adjust_ap
  *hide_reuse #Leadership
    How many AP will you spend to increase Leadership? (1 - ${top_limit})
    *input_number stat1 1 top_limit
    *set leadership +stat1
    *goto adjust_ap
  #I'm finished spending AP
    *goto done
  #Reset stats and AP
    *goto init
*label adjust_ap
*set ap -stat1
*if ap < 1
  *goto done
*if ap < 10
  *set top_limit ap
*goto choose_stats
*label done
*set maxstr str
*set maxhealth health
*set maxsmarts smarts
*set maxleadership leadership

Add it where you want it to show up. I’d personally put it in my startup.txt or one of my story scenes.

Oh, and looking at your code, the player can proceed without spending AP. Might want to look into that, unless you allow it to happen, ofc.


Also want to point out just in case that if this is your first bit of code with stats, you need the first code to be *create in your startup file

*create health 8

Etc etc, pretty sure you’ll get a bug with *temp top_limit too because you have to assign values to variables as soon as you create them (as with the line I posted above). That value can be 0, but if you’re going to immediately change it to 10, then you might as well just do

*temp top_limit 10

You could make this a gosub if you don’t want to just insert it randomly into already existing code, and that will save your indents. Then you can stick the *gosub_scene filename wherever you want this code to be. The only thing you’ll have to add is a *return at the end of this section.

I would put this in with the rest of character creation, but since I dont know what the rest of you game looks like, it may not fit very well there

1 Like

Thank you both for your help, I have a Lot to learn!

1 Like

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the @moderators.