Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#1
Post
by hapciupalit » Sat Dec 05, 2020 7:05 am
Hi there.
I order for me to have an easier life when updating the game I need my default variables to get the latest version of a define variable.
So in the code down below you see a class that receives a list. The way it is now if I save the game and modify the updated_list when I load my test1 it's still the same.
So what I want to achieve is when I load the game I will have another list If I change it. So I'm thinking if I could instead of passing the updated_list to only pass a referance or something.
Code: Select all
class Test:
def __init__(self,name, list):
self.name = name
self.list = list
define updated_list = ["something","goes","here"]
default test1 = Test("Test", updated_list)
Last edited by
hapciupalit on Sat Dec 05, 2020 7:25 am, edited 1 time in total.
-
hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
-
Contact:
#2
Post
by hell_oh_world » Sat Dec 05, 2020 7:16 am
you forgot the instance parameter itself (self) in your constructor.
and don't define something that you're planning to change/modify once declared. default them.
and avoid using any reserved names, list is a reserved name:
https://www.renpy.org/doc/html/reserved ... rved-names.
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#3
Post
by hapciupalit » Sat Dec 05, 2020 7:24 am
It was an example I wrote in the textbox. I forgot about the self and I will avoid using list.
The problem with using default is the fact that in the gameplay I only plan to change test1 variable. So it's okay to use default there, but I need define because that one stays the same as I defined.
And when the player plays another version if he checks the updated_list he has the latest version which is fine. The problem is that test1.list is still the old version, while in my case I want test1.list to be the new list.
So I guess I need to referance it somehow instead of just passing it there
-
hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
-
Contact:
#4
Post
by hell_oh_world » Sat Dec 05, 2020 7:35 am
object properties are saved, so you actually have to start a new game in order for the test1 object to be redefined and use the new update_list.
I suggest taking a look at special labels, especially after_load:
https://www.renpy.org/doc/html/label.ht ... ial-labels.
you can use the label in order to setup/change variables, just like what the doc says.
something like this, i guess...
Code: Select all
# new version
define l1 = [1, 2, 3]
# old version
# define l1 = [3, 2, 3]
default test1 = Test("Test", l1)
label after_load:
$ test1.l1 = l1
return
not sure since i haven't really tried using it.
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#5
Post
by hapciupalit » Sat Dec 05, 2020 8:01 am
hell_oh_world wrote: ↑Sat Dec 05, 2020 7:35 am
object properties are saved, so you actually have to start a new game in order for the test1 object to be redefined and use the new update_list.
I suggest taking a look at special labels, especially after_load:
https://www.renpy.org/doc/html/label.ht ... ial-labels.
you can use the label in order to setup/change variables, just like what the doc says.
something like this, i guess...
Code: Select all
# new version
define l1 = [1, 2, 3]
# old version
# define l1 = [3, 2, 3]
default test1 = Test("Test", l1)
label after_load:
$ test1.l1 = l1
return
not sure since i haven't really tried using it.
This would work, but when I have like 50 or so variables it would be very easy to forget one of them when updating, so I need a more solid solution.
What I have right now is instead of passing the variable I just pass the name, but I feel like it should be a better solution than this.
Code: Select all
class Test:
def __init__(self,name, _l):
self.name = name
self._l = _l
@property
def l(self):
return globals()[self._l]
-
gas
- Miko-Class Veteran
- Posts: 838
- Joined: Mon Jan 26, 2009 7:21 pm
-
Contact:
#6
Post
by gas » Sat Dec 05, 2020 8:39 pm
Sorry, but what exactly force you to use DEFINE?
If the game is not released yet there's no reason to keep define in place of default, that directly solve all of your issues.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#7
Post
by hapciupalit » Mon Dec 07, 2020 2:39 am
gas wrote: ↑Sat Dec 05, 2020 8:39 pm
Sorry, but what exactly force you to use DEFINE?
If the game is not released yet there's no reason to keep define in place of default, that directly solve all of your issues.
The fact that it's a sandbox that is going to be updated every month or so. And I'm working right now on the quest system. I'm having this problem when I create a quest that is not completly done. I'm writing half of the content for a quest, but then I update the version and I need to update someparts of the quest.
Users browsing this forum: Google [Bot]