I hope this is the right place to post this, my first time asking a question on here.
so I'm trying to make the player hp = their con score * 5.
When i change the con i can track the change, but when i change the con it doesn't change the player hp.
here is the problem as far as I can simplify---------------
# Declare characters used by this game. The color argument colorizes the
define NAR = Character("Narrator")
define UN = Character("Angle Pie")
# The game starts here.
label start:
$ player_str = 5
$ player_dex = 5
$ player_con = 5
$ player_int = 5
$ player_wis = 5
$ player_cha = 5
$ player_hp = player_con * 5
$ player_mp = player_int * 5
UN "your hp is... %(player_hp)d"
$ player_con += 1
UN "adding 5 your new hp is... %(player_hp)d"
NAR "if it is not 30 then a table gets filpped again."
return # This ends the game.
making hp con based
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Re: making hp con based
There are number of ways to make it, try
https://www.renpy.org/doc/html/label.ht ... -statement
viewtopic.php?f=8&t=37507&p=406500&hili ... ck#p406500
Code: Select all
default player_con_1 = 5
default player_hp_1 = player_con_1*5
default player_con_2 = 5
default player_hp_2 = player_con_2*5
default player_con_3 = 5
default player_hp_3 = player_con_3*5
init python:
def hp_func(x=0):
global player_con_3, player_hp_3
player_con_3 += x
player_hp_3 = player_con_3*5
player_con_4 = 5
player_hp_4 = player_con_4*5
def hp_func_2():
global player_con_4, player_hp_4
player_hp_4 = player_con_4*5
config.python_callbacks.append(hp_func_2)
# The game starts here.
label start:
"...1...calculate it everytime manualy"
"hp_1 - [player_hp_1]"
"+5 hp"
$ player_con_1 += 1
$ player_hp_1 = player_con_1*5
"hp_1 - [player_hp_1]"
"?"
"...2...make a label where all calculations will be done"
"hp_2 - [player_hp_2]"
"+5 hp"
call hp_calc(1)
"hp_2 - [player_hp_2]"
"?"
"...3...create a function"
"hp_3 - [player_hp_3]"
"+5 hp"
$ hp_func(1)
"hp_3 - [player_hp_3]"
"?"
"...4...add a function to the list of python callbacks, so it will be executed everytime you use python"
$ player_con_4 = 5
"hp_4 - [player_hp_4]"
"+5 hp"
$ player_con_4 += 1
"hp_4 - [player_hp_4]"
"?"
"+5 hp"
$ player_con_4 += 1
"hp_4 - [player_hp_4]"
"?"
"+5 hp"
$ player_con_4 += 1
"hp_4 - [player_hp_4]"
"?"
return # to not let game go farther to label hp_calc
label hp_calc(x=0):
$ player_con_2 += x
$ player_hp_2 = player_con_2*5
return
viewtopic.php?f=8&t=37507&p=406500&hili ... ck#p406500
Re: making hp con based
it took a lot of reading and testing to get it to work, and the posts on viewtopic.php?f=8&t=37507 were just the right thing i needed to get it. So i just want to say thanks!!!!!
new code looks like this now--------
# Declare characters used by this game. The color argument colorizes the
define NAR = Character("Narrator")
define UN = Character("Angle Pie")
init python:
player_con = 5
player_hp = player_con*5
def hp_function():
global player_con, player_hp
player_hp = player_con * 5
config.python_callbacks.append(hp_function)
# The game starts here.
label start:
UN "your hp is... %(player_hp)d"
$ player_con += 1
UN "adding 5 your new hp is... %(player_hp)d"
NAR "if it is not 30 then a table gets filpped again."
return # This ends the game.
new code looks like this now--------
# Declare characters used by this game. The color argument colorizes the
define NAR = Character("Narrator")
define UN = Character("Angle Pie")
init python:
player_con = 5
player_hp = player_con*5
def hp_function():
global player_con, player_hp
player_hp = player_con * 5
config.python_callbacks.append(hp_function)
# The game starts here.
label start:
UN "your hp is... %(player_hp)d"
$ player_con += 1
UN "adding 5 your new hp is... %(player_hp)d"
NAR "if it is not 30 then a table gets filpped again."
return # This ends the game.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]