Variables advice

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.
Post Reply
Message
Author
radu32167
Newbie
Posts: 24
Joined: Wed Nov 23, 2016 10:25 am
Contact:

Variables advice

#1 Post by radu32167 »

Hi

I'm making a game using ren'py and I wonder if anyone has some advice.I'm a noob I know, and maybe this was answered, but I just can't find it.

I hope I'm expressing myself correctly, and that I'm making myself understood.

Instead if having a linear structure to the code, I'm trying to make something circular" MC wakes up, does something in the morning, something in the afternoon, evening, goes back to sleep and wakes up again".

The problem I'm having is with the introduction of new variables and save games. For example if I want to make a 1 time event, and I declare a variable that controls it , it may be checked before it's defined, in the case of a saved game. When I do an update.

For example:
I define a variable in a separate file

default updatevar1 = False

and I want that variable to control an event

label afternoon:
if updatevar1 == False:
jump event1
else:
jump event2

label event1:
code...
code....
$ updatevar1 = True
jump sleep

In the case of saved games, It always gives me the "var1 not defined" error. The code works great with new games, but it always gives me problems with save games from previous builds.
I hope I'm making myself understood, english is not my first language.

Has anyone had problems like this, is there a place where I can better define my variables so that save games acknowledge them?
Last edited by radu32167 on Thu Feb 23, 2017 9:37 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Variables advice

#2 Post by Imperf3kt »

Before any labels, add

Code: Select all

default updatevar1 = False
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

radu32167
Newbie
Posts: 24
Joined: Wed Nov 23, 2016 10:25 am
Contact:

Re: Variables advice

#3 Post by radu32167 »

Default is what I meant

sorry

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]