Cutting the code into different modules for ease of access?
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.
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.
-
Argeus_the_Paladin
- Veteran
- Posts: 264
- Joined: Sat Feb 26, 2011 9:36 am
- Projects: Rzeczpospolita Polska 1647
- Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
- Contact:
Cutting the code into different modules for ease of access?
As at present, my code is approaching the 7000 mark, and it is becoming harder and harder to properly navigate it. For practical reason, I am considering dividing it into different modules and import them into the main module when the game is run. However, I didn't understand the relevant instruction in the documentation.
Could anyone give me a brief run-through of what I need to keep in mind if I want to do this?
Could anyone give me a brief run-through of what I need to keep in mind if I want to do this?
One Province Minor - 120 class variables and still counting!
Because there is no such thing as too many variables.
Because there is no such thing as too many variables.
Re: Cutting the code into different modules for ease of acce
Why not just use different script files? It's got to be easier than trying to make and import modules...
Ren'Py will run any script files it finds in the game folder, so you can just save different parts of your code to different ones and give them names to help you keep things in order.
Ren'Py will run any script files it finds in the game folder, so you can just save different parts of your code to different ones and give them names to help you keep things in order.
-
Argeus_the_Paladin
- Veteran
- Posts: 264
- Joined: Sat Feb 26, 2011 9:36 am
- Projects: Rzeczpospolita Polska 1647
- Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
- Contact:
Re: Cutting the code into different modules for ease of acce
That's exactly what I am looking for, right there.
Is there any pointer on how the program loads codes in different script files? Or any tutorial I could read about this?
Is there any pointer on how the program loads codes in different script files? Or any tutorial I could read about this?
One Province Minor - 120 class variables and still counting!
Because there is no such thing as too many variables.
Because there is no such thing as too many variables.
Re: Cutting the code into different modules for ease of acce
I'm not sure of the specifics, but I believe anything in an init block (regardless of file) will run first. You shpuld only have one start label (or you'll get an error) amongst all the files, and the game will start there. And you can jump to or call any label, regardless of which file it's in.Argeus_the_Paladin wrote:That's exactly what I am looking for, right there.
Is there any pointer on how the program loads codes in different script files? Or any tutorial I could read about this?
-
Argeus_the_Paladin
- Veteran
- Posts: 264
- Joined: Sat Feb 26, 2011 9:36 am
- Projects: Rzeczpospolita Polska 1647
- Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
- Contact:
Re: Cutting the code into different modules for ease of acce
So in file 1 we can have:
and in file 2, 3, 4, 5,... n we have:
The question is, should all of these files end with return? From dissecting the tutorial it seems to be the case, but there is also the thing that each tutorial modules actually concludes with jumping back to the main tutorial game menu.
So what should it be?
Code: Select all
init python:
# part 1 definitions go hereCode: Select all
init python:
# part 3, 3, 4, 5, ...n definitions go hereSo what should it be?
One Province Minor - 120 class variables and still counting!
Because there is no such thing as too many variables.
Because there is no such thing as too many variables.
- ScottySeng
- Regular
- Posts: 162
- Joined: Tue Oct 04, 2011 9:57 am
- Completed: May-Chan
- Projects: Fairy Tale, What do you see
- Skype: scottyseng
- Location: Carrollton, TX
- Contact:
Re: Cutting the code into different modules for ease of acce
http://lemmasoft.renai.us/forums/viewto ... =8&t=14222
I think the middle of this thread may help. It's about splitting Renpy files.
I think the middle of this thread may help. It's about splitting Renpy files.
Re: Cutting the code into different modules for ease of acce
No. The structure of tutorial game code is - the menu in start label from which different chapters are called, so at the end of this chapters should be a return command (to put player back to menu).The question is, should all of these files end with return? From dissecting the tutorial it seems to be the case, but there is also the thing that each tutorial modules actually concludes with jumping back to the main tutorial game menu.
In your case, no returns are needed. Just split you code to several rpy-files with its own init blocks screens and ATL definitions and so on. When you'll run your game, Ren'py will treat all this rpy-files as one big file and will execute all init blocks first and start label then.
http://www.renpy.org/wiki/renpy/FAQ#How ... e_files.3F
-
Argeus_the_Paladin
- Veteran
- Posts: 264
- Joined: Sat Feb 26, 2011 9:36 am
- Projects: Rzeczpospolita Polska 1647
- Location: Κωνσταντινούπολη, Βασιλεύα των Ρωμαύων
- Contact:
Re: Cutting the code into different modules for ease of acce
So if I understand correctly, splitting the script into different files have virtually no effect on how it is run, but only how it is organized?
That's perfect. Thanks for the pointer, everyone.
That's perfect. Thanks for the pointer, everyone.
One Province Minor - 120 class variables and still counting!
Because there is no such thing as too many variables.
Because there is no such thing as too many variables.
Who is online
Users browsing this forum: Bing [Bot]