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.
-
Jezzy
- Regular
- Posts: 30
- Joined: Wed Jun 21, 2017 2:18 pm
-
Contact:
#1
Post
by Jezzy » Thu Jan 23, 2020 10:05 am
Hi,
I have a Renpy project working perfectly fine on Windows and MacOS but raising an exception when running under Linux.
I get a NameError not defined on a [None] * len(i). Linux pretend that i isnt defined and I can't figure why.
Here a simplified sniplet of my script code :
Code: Select all
init:
$ renpy.music.register_channel("music","sfx",False)
$ Calendar()
$ Clock()
$ i = 0
define tracking_var = [None] * len(i)
This code will crash and raise this exception :
NameError: name 'i' is not defined
Anyone have an idea?
Last edited by
Jezzy on Thu Jan 30, 2020 2:48 pm, edited 1 time in total.
-
Angelo Seraphim
- Regular
- Posts: 32
- Joined: Tue May 21, 2019 8:00 am
- Completed: Enamored Risks (NaNoReNo 2020)
- Projects: 616 Charagma
- Organization: GLSUoA
- Deviantart: glsuoa
- itch: glsuoa
- Location: London, UK
- Discord: Just A Concept#9599
-
Contact:
#2
Post
by Angelo Seraphim » Fri Jan 24, 2020 6:15 pm
Consider using "
default" when declaring variables and not "
$" .
Code: Select all
init python:
renpy.music.register_channel("music","sfx",False)
## I'm assuming these were supposed to go here (?)
Calendar()
Clock()
default i = 0
This should solve your problem.
Also, if the variable is dynamic consider using "
default" . If it's a constant use "
define" .
Code: Select all
default tracking_var = [None] * len(i)
Also,
also, "
... = [None] * len(i)" doesn't really make much sense since "
i" is defaulted as an "
int" type variable. No real need for "
len()" .
-
Jezzy
- Regular
- Posts: 30
- Joined: Wed Jun 21, 2017 2:18 pm
-
Contact:
#3
Post
by Jezzy » Thu Jan 30, 2020 2:47 pm
Thank you Angelo Seraphim for your answer. Your post made me realized that my mindset wasnt Pythonic enough. I was trying to store object in a Python list like an array in other languages. That is why I tried to pre-create a list with its elements set to a null value * by the len but it wasnt making sense at all as you wrote.
So in order to fix my issue, I had to rethink my script in a more pythonic way. So instead I am using .append to add stuff to my tracking variable and I'm using -1 to get the lastest iteration of my list when I need it later in my code.
Thank you for your time! It was really appreciated.
PS. I still can't understand why It was working just fine un Windows and MacOS but not in Linux though but it doesnt matter much anymore
Users browsing this forum: Bing [Bot]