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.
I have a list as a persistent variable and I need to assign its value to a regular variable and change the value of the regular variable using Python methods for lists. However, changing the value of a regular variable also changes the value of persistent. Here's a simple example of what's happening:
NoFanru wrote: ↑Sat Nov 25, 2023 4:02 am
So, is it possible to change a regular variable without changing the persistent variable?
I would be grateful for any help
This has nothing to do with persistent or regular variables. It's just a Python thing. If you want to create a copy of a list (or dictionary etc.) you have to do it in a way @Ocelot describes. Otherwise in Python you would just create a reference. It's how Python works, not Renpy.
Ocelot wrote: ↑Sat Nov 25, 2023 4:59 am
Yes, you just need to make sure that regular variable points to a copy and not the same list your persistent variable points to.
Choose your approach: