ID:2013807
 
(See the best response by Ter13.)
Code:
mob/proc
Healthboxstats()
src << output("[src.Strength]", "Str")
//This is the code for stats showing in the Str label

mob/verb
StrengthAddPoint()
var/removepoints = 1
set hidden = 1
if(statpoints >= 1)
usr.Strength += 1
usr.statpoints -= removepoints
if(statpoints < 1)
return
else
return
//This is trying to click the + button so clicking it increases the strength you added by 1 each click.


Problem description:
So when i try to click the + button the strength stat doesn't appear to be updating. https://gyazo.com/e5a67d877baa89de275a19fbd4c15635
You'll need to call Healthboxstats() when you have increased the Strength variable to update the label, otherwise it'll remain as the value when Healthboxstats() was last called.

If you're using an output rather than a label you'll also need to set "Str" to output null first to reset the field, otherwise it will contain a new line and value each time the process is called.
In response to Reversal Entertainment
Reversal Entertainment wrote:
You'll need to call Healthboxstats() when you have increased the Strength variable to update the label, otherwise it'll remain as the value when Healthboxstats() was last called.

If you're using an output rather than a label you'll also need to set "Str" to output null first to reset the field, otherwise it will contain a new line and value each time the process is called for the healthbox.

So i tested it out on a seperate window and it works however it doesn't seem like putting the proc somewhere when you finish creating a character. doesn't work. Also i'm using a child.
Is the actual strength value a label or an output?

If it's a label you should be using:

winset(src,"window.labelname","text=\"[StrengthVariable]\"")


Here's an example of a similar thing working in one of my projects:

    CreationStrengthPlus()
set hidden=1
if(src.StatPoints<1||src.Strength>=10) return
src.Strength++
src.Strength = src.Strength /*This doesn't do anything as pointed out in Azurift's response.*/
src.StatPoints--
winset(src,"Creation.Strength","text=[src.Strength]")
winset(src,"Creation.StatPoints","text=[src.StatPoints]")
Correct me if I am wrong, but I find that these types of behaviors exhibited by both of these functions don't exactly line up with the definition of a verb, which is an action that the mob takes. These are better suited to procedures rather than verbs.

Code snippet by Reversal Entertainment:
    CreationStrengthPlus()
set hidden=1
if(src.StatPoints<1||src.Strength>=10) return
src.Strength++
src.Strength = src.Strength
src.StatPoints--
winset(src,"Creation.Strength","text=[src.Strength]")
winset(src,"Creation.StatPoints","text=[src.StatPoints]")

The "src.Strength = src.Strength" is redundant and should be removed. You are assigning a value to itself, which accomplishes nothing.
In response to Azurift
It's called through the interface though so as far as I'm aware it needs to be a verb because you can't call a procedure through the interface?

Indeed "src.Strength = src.Strength" is redundant, I originally had attributes that were increased through the use of stat points as a bonus variable rather than the core attribute itself. I decided against it eventually, but this line was left over and has just been removed. :)
Best response
Correct me if I am wrong, but I find that these types of behaviors exhibited by both of these functions don't exactly line up with the definition of a verb, which is an action that the mob takes. These are better suited to procedures rather than verbs.

Interface-based UIs require verbs exposed to the client in order to operate. OP is actually correct in this instance to use a verb.

I'm glad to see OP properly gated the function to ensure that it isn't called inappropriately, though.

A few pointers for some of the code in this thread though:

mob/verb
StrengthAddPoint() //This is oddly specific, better to have fewer verbs for debugging.
var/removepoints = 1 //this is in the wrong place, and is probably unnecessary given the current code.
set hidden = 1
if(statpoints >= 1)
usr.Strength += 1 //usr is incorrect here, limiting the utility of this function.
usr.statpoints -= removepoints
if(statpoints < 1) //this if statement shouldn't be here. Redundant logic
return
else
return


Those if statements are a bit out of whack, and your settings are in the wrong place.

First-pass fix:

mob/verb
StrengthAddPoint()
set hidden = 1 //settings should always be at the top of a verb.
set instant = 1 //I recommend setting instant for all interface related verbs
if(statpoints >= 1)
++Strength
--statpoints
else
return


A much more robust fix would be to reduce the number of verbs you are using to a single verb that encompasses all stats. Generally speaking, multi-purpose verbs will save you quite a lot of headache later on if you want to make a change to how something works. Changing a single function is much easier than updating 7 separate functions that share identical logic.

#define clamp(V,L,H) min(max(V,L),H)
#define floor(x) round(x)
#define ceil(x) (-round(-(x)))

//These are just examples
/* define the stat definitions to the list position in the global variable stat_names.*/

#define STAT_STRENGTH 1
#define STAT_AGILITY 2
#define STAT_VITALITY 3
#define STAT_INTELLIGENCE 4
#define STAT_WISDOM 5
#define STAT_CHARISMA 6
#define STAT_CHUTZPAH 7

var/list/stat_names = list("Strength","Agility","Vitality","Intelligence","Wisdom","Charisma","Chutzpah")

mob/verb
SpendStatpoints(stat as num,n as num)
set hidden = 1
set instant = 1
n = clamp(floor(n),0,statpoints) //ensure that the number we're spending is in range of the number of statpoints we have
if(!n||stat<1||stat>stat_names.len||floor(stat)!=stat) return //if any of the values are mangled
stat = stat_names[stat] //get the string name of the stat by number
vars[stat] += n //modify the variable using the string name through the vars list
statpoints -= n //remove the designated number of statpoints.


And for this little guy:

            winset(src,"Creation.Strength","text=[src.Strength]")
winset(src,"Creation.StatPoints","text=[src.StatPoints]")


Group up your winsets where possible:

winset(src,null,"Creation.Strength.text=\"[src.Strength]\";Creation.StatPoints.text=\"[src.StatPoints]\";)
I'm a big fan of multipurpose verbs like SpendStatPoints() when hooking up verbs to interfaces. The fewer verbs you have to create to tie to your UI, the better. When you have several stats you intend to raise/lower with buttons, a single verb to handle every one of those buttons is the very best way to go. Likewise if you want to set a color or style for different parts of your character, again a single verb for each type (color, style, etc.), but handling all applicable parts, is the better option.
Thanks. I'm kinda new to this stuff but i know a few basics.