Points storage
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.
-
- Regular
- Posts: 65
- Joined: Tue May 23, 2017 1:08 pm
- Projects: VN 789
- Deviantart: bokuman
- Contact:
Points storage
I have a system points on my project, but im not sure why those points are not saved, what problems i could need to check for this issue?
Re: Points storage
You probably defined the variable in init block. Let's say you have variable points. You can do something like this:
Code: Select all
default points = 0
label start:
$ points = 4
"Current points are - [points]"
"Try save and load"
"Current points are - [points]"
-
- Regular
- Posts: 65
- Joined: Tue May 23, 2017 1:08 pm
- Projects: VN 789
- Deviantart: bokuman
- Contact:
Re: Points storage
I think the problem is more complex lol
i use this to define somethings and points. on my screens
and i define later the variables on this way w_girl1.points etc, because there are more girls, make sense?
i use this to define somethings and points. on my screens
Code: Select all
init python:
def no_rep_rand(lst, curr):
r = curr
while r == curr:
r = renpy.random.choice(lst)
return r
class waifu:
def __init__(self, name, dir, act, off):
self.name = name
self.dir = dir
self.act = act
self.off = off
self.avt = "normal"
self.points = 0
def pts(self, x):
if self.points + x > -2001 and self.points + x < 2001:
self.points += x
def change(self, x):
self.avt = x
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3808
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Points storage
Did you remember to default the variables for the points though?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Points storage
As Imperf3kt said, do you 'define' class instance like this?
Code: Select all
default w_girl1 = waifu( 'name', ...)
-
- Regular
- Posts: 65
- Joined: Tue May 23, 2017 1:08 pm
- Projects: VN 789
- Deviantart: bokuman
- Contact:
Re: Points storage
is defined on this way
i have a select menu.
and variables are w_girl1.points, w_girl2.points etc
Code: Select all
init python:
def no_rep_rand(lst, curr):
r = curr
while r == curr:
r = renpy.random.choice(lst)
return r
class waifu:
def __init__(self, name, dir, act, off):
self.name = name
self.dir = dir
self.act = act
self.off = off
self.avt = "normal"
self.points = 0
def pts(self, x):
if self.points + x > -2001 and self.points + x < 2001:
self.points += x
def change(self, x):
self.avt = x
define w_girl1 = waifu("girl1", "char/girl1", Jump('girl1_chapter'), (-1, -1))
define w_girl2 = waifu("girl2", "char/girl2", Jump('girl2_chapter'), (0, -1))
define w_girl3 = waifu("girl3", "char/girl3", Jump('girl3_chapter'), (1, -1))
define w_girl4 = waifu("girl4", "char/girl4", Jump('girl4_chapter'), (-1, 0))
define w_girl5 = waifu("girl5", "char/girl5", Jump('girl5_chapter'), (1, 0))
define w_none5 = waifu(" ", "char/none", Jump('none_chapter'), (-1, 1))
define w_none6 = waifu(" ", "char/none", Jump('none_chapter'), (0, 1))
define w_none7 = waifu(" ", "char/none", Jump('none_chapter'), (1, 1))
#define w_random = waifu("Random", "char/random", Jump('amber_chapter'), (0, 0))
#define w_player = waifu("Player", "char/player", Jump('amber_chapter'), (1, 1))
#define w_amber = waifu("Amber", "char/amber", Jump('amber_chapter'), (1, 1))
define waifus = [
w_girl1,
w_girl2,
w_girl3,
w_girl4,
w_girl5,
w_none5,
w_none6,
w_none7,
]
and variables are w_girl1.points, w_girl2.points etc
Re: Points storage
That is the problem. Look at documentation https://www.renpy.org/doc/html/python.h ... -statement.
Basically define is equivalent to:
You need to use default so the class instance will be saved and will not be rewritten at initialization:
Basically define is equivalent to:
Code: Select all
init python:
w_girl1 = waifu("girl1", "char/girl1", Jump('girl1_chapter'), (-1, -1))
Code: Select all
default w_girl1 = waifu("girl1", "char/girl1", Jump('girl1_chapter'), (-1, -1))
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot]