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.
-
span4ev
- Regular
- Posts: 77
- Joined: Fri Jul 08, 2022 9:29 pm
- itch: rpymc
-
Contact:
#1
Post
by span4ev » Sun Oct 16, 2022 5:40 pm
I want to pass variables inside a function, but they won't change because they need to be made global.
Before this, I used a simple way:
Code: Select all
1. setVariable()
2. def my_func():
global money, ...(other variables)
But it's more convenient to do it like this:
Code: Select all
def my_func(x):
global x
x += 1
my_func(money)
But I can't make them global inside the function. Is it possible?
-
laure44
- Regular
- Posts: 60
- Joined: Mon Mar 08, 2021 10:55 pm
- Projects: Arkan'sTower, Gemshine Lorelei!
- Location: France
-
Contact:
#2
Post
by laure44 » Sun Oct 16, 2022 8:01 pm
I'm not even sure that's possible, but it would probably be safer to just use return.
Code: Select all
def my_func(x):
return x + 1
money = my_func(money)
Users browsing this forum: Google [Bot], Majestic-12 [Bot]