Code: Select all
$ player.mc_hp = max(0, player.mc_hp-45)
"You step on a spike and take 45 damage."
$ player.mc_hp = max(0, player.mc_hp-30)
"You trip and take 30 damage."
Code: Select all
$ player.mc_hp = max(0, player.mc_hp-45)
"You step on a spike and take 45 damage."
$ player.mc_hp = max(0, player.mc_hp-30)
"You trip and take 30 damage."
Code: Select all
init -1 python:
import renpy.store as store
import renpy.exports as renpy # we need this so Ren'Py properly handles rollback with classes
inv_page = 0 # initial page of the inventory screen
item = None
class Player(renpy.store.object):
def __init__(self, name, mc_max_hp=100, mc_max_mp=0, element=None, healthpot=None):
self.name=name
self.mc_max_hp=mc_max_hp
self.mc_hp=mc_max_hp
self.mc_max_mp=mc_max_mp
self.mp=mc_max_mp
self.element=element
self.healthpot=healthpot
player = Player("[mc]", 100, 50)
Code: Select all
screen mc_hp_screen:
$renpy.transition(dissolve)
bar align (0.125, 0.10) value AnimatedValue(player.mc_hp, player.mc_max_hp, delay=1.0) style "hp_slider"
text "[player.mc_hp]%" size 26 align (0.172, 0.123) style "hp_bar_percentage"
Code: Select all
label start:
$ mc = renpy.input("", length=10, with_none=None, pixel_width=None)
if mc == "":
"Invalid name."
jump start
show screen inventory_button()
show screen mc_hp_screen
I tried that. It didn't fix the issue unfortunately.Eliont wrote: ↑Thu Jul 09, 2020 8:23 am Try to use https://www.renpy.org/doc/html/save_loa ... after-load
Code: Select all
#Player saves the game here."
"Walking down the path..."
$ player.mc_hp = max(0, player.mc_hp-45)
"You step on a spike and take 45 damage."
$ player.mc_hp = max(0, player.mc_hp-30)
"You trip and take 30 damage."
#Player loads save here."
Code: Select all
label start:
$player=Player()
Code: Select all
default player=Player()
Code: Select all
label init_game:
$player=Player()
return
label start:
call init_game
#content starts here
Oh, my god! It worked! Thank you so so so much!drKlauz wrote: ↑Thu Jul 09, 2020 9:45 am Create player after start label.Objects (including lists&dicts) created in init block are not saved.Code: Select all
label start: $player=Player()
https://www.renpy.org/doc/html/save_load_rollback.html
P.S.: Or useTho i personally prefer using something likeCode: Select all
default player=Player()
It allow more flexible variable initialization.Code: Select all
label init_game: $player=Player() return label start: call init_game #content starts here
Users browsing this forum: No registered users