Well, the short answer is with quite a bit of work. ;-)
The longer one depends on how complex you want to get.
Simple skill system:
Add a skill points available attribute to to your user object. You'll need to work out some logic about when to give them available skill points.
Add an array of available skills to the character. How you build this up and when you expand it is something you'll need to work out. Might be the same fixed set for everyone, might be class based, might be achievement based.
Then you need a panel where a character can pick a skill they don't have and acquire it. More complex versions give them multiple levels of each skill and might make the training to acquire/raise it only available at certain places in the game.
Then you need action systems in the game that actually use the skills. Lock picking is fine, but if there are no locks to pick, you've just wasted a skill point. Likewise combat skills need to affect your combat system. Performance skills may just affect the availability of story actions (at the festival, poets gets to recite, singers get to sing and muck shovellers get to sit and watch).
Not something I'd want to implement without giving it a bit of forethought. I'd strongly suggest you go for the simplest option that'll work for you as your first attempt.
Indeed. Using SugarCube's built-in random functions and methods are always the best idea if you need random values. Not only are they easier to use, but they always use the appropriate PRNG (Math.random() or, if enabled, SugarCube's seedable PRNG).
thank you for the help.
i used the <<click>> and <span> and <<replace>> macros for the selection but i don't know how to put a limit. because i click too many times and i get 22222222 strength and i only want a limit of 10 strength and 24 points
there is the code.
Hey, here is how I am doing it if you mean a simple attribute/skill system. Also, currently working on editing yours so that there can be a limit to the value. I know there is a way, I have the idea in my head.
Anyways, here is my current system, presupposing the variables $charstrength and $statsavailable and the fact that this is set in a passage called "stats":
When you press the increase button it adds 1 to $charstrength, subtracts 1 from $statsavailable and then reloads the passage. Once you get to either $charstrength = 10 or $statsavaiable = 0, it stops allowing you to increase the value, but still allows you to decrease it on the stats page. I do this for each "skill" or "attribute."
update: I've found a way to limit your system, but now I have another problem. I can't get the decrease function working properly.
my funky version of your code... I've included enough code for 2 stats so you can see how it would be limited (i.e., how if you maxed str at 10, you could only get dex to 8):
Remember, in this example you would have to have the variables $charstrength, $chardexterity and $statsavailable. I'm on the verge of a breakthrough with how to make the decrease button work inside of this code properly, so that it never disappears permanently.
Note: this example presumes the variables $charconst = 0, $chardexterity = 0, $charstrength = 0 and $statsavailable = 18. Oh, also that this is set in a passage called "stats"
Comments
The longer one depends on how complex you want to get.
Simple skill system:
Add a skill points available attribute to to your user object. You'll need to work out some logic about when to give them available skill points.
Add an array of available skills to the character. How you build this up and when you expand it is something you'll need to work out. Might be the same fixed set for everyone, might be class based, might be achievement based.
Then you need a panel where a character can pick a skill they don't have and acquire it. More complex versions give them multiple levels of each skill and might make the training to acquire/raise it only available at certain places in the game.
Then you need action systems in the game that actually use the skills. Lock picking is fine, but if there are no locks to pick, you've just wasted a skill point. Likewise combat skills need to affect your combat system. Performance skills may just affect the availability of story actions (at the festival, poets gets to recite, singers get to sing and muck shovellers get to sit and watch).
Not something I'd want to implement without giving it a bit of forethought. I'd strongly suggest you go for the simplest option that'll work for you as your first attempt.
You can get random numbers with Math.random().
i used the <<click>> and <span> and <<replace>> macros for the selection but i don't know how to put a limit. because i click too many times and i get 22222222 strength and i only want a limit of 10 strength and 24 points
there is the code.
Anyways, here is my current system, presupposing the variables $charstrength and $statsavailable and the fact that this is set in a passage called "stats":
When you press the increase button it adds 1 to $charstrength, subtracts 1 from $statsavailable and then reloads the passage. Once you get to either $charstrength = 10 or $statsavaiable = 0, it stops allowing you to increase the value, but still allows you to decrease it on the stats page. I do this for each "skill" or "attribute."
Is this what you are looking for?
my funky version of your code... I've included enough code for 2 stats so you can see how it would be limited (i.e., how if you maxed str at 10, you could only get dex to 8):
Remember, in this example you would have to have the variables $charstrength, $chardexterity and $statsavailable. I'm on the verge of a breakthrough with how to make the decrease button work inside of this code properly, so that it never disappears permanently.
My system:
Note: this example presumes the variables $charconst = 0, $chardexterity = 0, $charstrength = 0 and $statsavailable = 18. Oh, also that this is set in a passage called "stats"
The Issues Implementing an RPG style Stats Screen (Stat point allocation etc) in Sugarcube 1x thread also includes two examples (one by TheMadExile and the other by me) showing how to implement what you asked for. The solutions should work in both SC 1 and 2.