Stuck on some coding

Need a little help with this one.
I have stat str and maxstr
I am giving the option to the player to add a number to the stat

Your curent AP Score is: ${ap}


*choice
-#Strenght
--input_stat1
--page_break
--*gosub stat1_check
--*comment this check that the player input is a numbe 8 to 18 if not it will send then an error message and reset to the label so they can try again
--*set stat1 str
--*set stat1 maxstr
--*comment I want to subtract stat1 from the total of ap so would it be
--*set ap -stat1
--*comment then it will goto the label so they can choose another stat.

The other thing is I want is a reset button so if they change their mind it will clear the data. Not real sure how to approach this one.

Thanks for any help.

*edit there is a lot more code to this but felt it best to keep it simple around the area I need help

If I’m not mistaken, you need to use {} around a variable if you want to use it to set another variable. So you would have:

*set stat1 {str}

If you want stat1 to be str’s value, or

*set str {stat1}

If you want stat1 to be the new value for strength (which is what I think you’re going for).

I’m not completely sure about that, as I’ve never had to use that before.

See what you think of this.

For this example I’m using four stats: Strength, Health, Smarts, and Leadership, assumed to be defined in mygame.js along with their “max” counterparts. I’m also assuming they are each to end up between 8 and 18, inclusive, and that the average will be 13 (halfway between 8 and 18). So I took the tactic of setting each of them initially to the minimum of 8 and then giving 20 AP to spend to increase any of them by as much as 10 additional points. You’ll have to tweak the values according to your own needs, of course.


*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?
*choice
  *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

Thanks all, great. Between what I am thinking and what you have offered I think I can make it work the way I want. As always you all are great. Thanks again.

@Lordirish Hey, just as an FYI, if you use `

` instead of ```, it will keep the indentation and not break the forums. (So you won't even have to worry about switching dashes and spaces.