Python:
init python:
def str_check():
return (strength + (str_bonus * mood_happy))
default strength = 0
default str_bonus = 10
default mood_happy = False
label start:
scene black with fade
"Start:.... "
label do_str_check_again:
if str_check() == 0:
"Strength is zero."
$ mood_happy = True
jump do_str_check_again
elif str_check() == 10:
"Strength is 10."
$ strength += 1
jump do_str_check_again
else:
"Strength is something else."
"*** THE END ***"
return
This works because while
mood_happy
is a boolean, python also treats True=1 and False=0.
As a result, 10 * 1 = 10 and 10 * 0 = 0.
If your bonuses were always going to be 10, you wouldn't need the
str_bonus
variable at all.
I've coded it this way however, just in case you want to alter the bonuses occasionally too.
First time though, mood is False - so value is 0.
Second time though, mood is True - so value is 10.
Third time through, mood is True and returned value is 11.
This way, you can alter the strength value however you like, completely independently of the mood, you just need to substitute the function instead of the variable anytime you want to inspect it's value (like doing an
if:
statement).
Edit: If you want to make the function more generic and the bonus is always going to be 10, then you could do this instead:
Python:
init python:
def stat_check(stat_value):
return (stat_value + (10 * mood_happy))
# blah, blah, code
$ strength = 5
$ mood_happy = False
if stat_check(strength) >= 15:
"Something happy"
else:
"Something sad"