Linking multiple files/scripts and compression
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.
- rabcor
- Regular
- Posts: 81
- Joined: Sun Mar 17, 2013 3:07 pm
- Projects: None (Need a programmer?)
- Organization: Cestarian Games
- Contact:
Linking multiple files/scripts and compression
Lets say i would like to write a big RPG project, i would like to store dialogues about certain topics seperately from each other. Or just store dialogue for main storyline characters seperately.
As any good rpg there would have to be some opponents to fight in it, so i would like to have a database over the monster types that would help the game "build" these monsters when needed (i'd want to procedurally generate most (but not all) monster's stats, and sometimes even images to avoid having a level cap, so i'd need a "leveled monster" database and "hardcoded monster" database)
then there would be several minigames, one being the dungeon crawling part, then perhaps a world map, etc.
Needless to say storing all of this stuff in one Script.rpy file would be an extremely bad idea.
What do you think is the best way to tell a script to load another script file either to enter a minigame or load specific data from it (pull out a monster, or dialogue)?
The other thing i'm wondering about is compression, is there a way so that i can compress the game (scripts, images, sounds, etc) into just a few files instead of having a huge game folder structure on the released game?
As any good rpg there would have to be some opponents to fight in it, so i would like to have a database over the monster types that would help the game "build" these monsters when needed (i'd want to procedurally generate most (but not all) monster's stats, and sometimes even images to avoid having a level cap, so i'd need a "leveled monster" database and "hardcoded monster" database)
then there would be several minigames, one being the dungeon crawling part, then perhaps a world map, etc.
Needless to say storing all of this stuff in one Script.rpy file would be an extremely bad idea.
What do you think is the best way to tell a script to load another script file either to enter a minigame or load specific data from it (pull out a monster, or dialogue)?
The other thing i'm wondering about is compression, is there a way so that i can compress the game (scripts, images, sounds, etc) into just a few files instead of having a huge game folder structure on the released game?
- SundownKid
- Lemma-Class Veteran
- Posts: 2299
- Joined: Mon Feb 06, 2012 9:50 pm
- Completed: Icebound, Selenon Rising Ep. 1-2
- Projects: Selenon Rising Ep. 3-4
- Organization: Fastermind Games
- Deviantart: sundownkid
- Location: NYC
- Contact:
Re: Linking multiple files/scripts and compression
In Ren'py all scripts in the game folder act like one big script. So, it doesn't matter where you put the label as long as it's in the same script file.
To compress the files add something like this to options where it says "to archive files..."
(I think you only need to compress the .rpyc files though, .rpy can be removed.)
To compress the files add something like this to options where it says "to archive files..."
Code: Select all
build.classify('game/**.png', 'archive')
build.classify('game/**.jpg', 'archive')
build.classify('game/**.rpy', 'archive')
build.classify('game/**.rpyc', 'archive')
build.classify('game/**.ogg', 'archive')
build.classify('game/**.ogv', 'archive')- rabcor
- Regular
- Posts: 81
- Joined: Sun Mar 17, 2013 3:07 pm
- Projects: None (Need a programmer?)
- Organization: Cestarian Games
- Contact:
Re: Linking multiple files/scripts and compression
Thanks a lot! that explains most of it! it's almost too easy.
But one thing i do wonder about is what order the compiler/builder will load my scripts in, and if i can perhaps specify a load order?
Or do i not have to worry about that (i might define a class in "Class" file, then call on it in "Code" file, but it could break compilation if the "Code" file would be loaded before "Class" file right?)
But one thing i do wonder about is what order the compiler/builder will load my scripts in, and if i can perhaps specify a load order?
Or do i not have to worry about that (i might define a class in "Class" file, then call on it in "Code" file, but it could break compilation if the "Code" file would be loaded before "Class" file right?)
- sendo
- Veteran
- Posts: 290
- Joined: Sun Sep 01, 2013 2:28 am
- Completed: To Libertad, Diamond Rose, SC2VN, Sickness VN
- Projects: eroges!
- itch: sendo
- Contact:
Re: Linking multiple files/scripts and compression
That's the beauty of Ren'py ^^ sometimes I think it's magicrabcor wrote:Thanks a lot! that explains most of it! it's almost too easy.
I'm not an expert in Ren'py but I think all you have to remember is to define all the classes in an init block so that they are visible throughout the whole script. Also, you can specify script load order by giving the init block a 'priority number'. More info here.rabcor wrote:But one thing i do wonder about is what order the compiler/builder will load my scripts in, and if i can perhaps specify a load order?
Or do i not have to worry about that (i might define a class in "Class" file, then call on it in "Code" file, but it could break compilation if the "Code" file would be loaded before "Class" file right?)
- rabcor
- Regular
- Posts: 81
- Joined: Sun Mar 17, 2013 3:07 pm
- Projects: None (Need a programmer?)
- Organization: Cestarian Games
- Contact:
Re: Linking multiple files/scripts and compression
That answered it quite nicely, thanks a bunch 
Still didn't understand how to specify the priority though (that link is outdated i think) but it may very well be that i won't ever have to anyways. I can just look into it again or work around it if i ever do find a reason to use it though
Still didn't understand how to specify the priority though (that link is outdated i think) but it may very well be that i won't ever have to anyways. I can just look into it again or work around it if i ever do find a reason to use it though
-
ForklessAnon
- Regular
- Posts: 49
- Joined: Fri Sep 06, 2013 1:13 am
- Contact:
Re: Linking multiple files/scripts and compression
Example of init declaration (the code shown is arbitrary):
Hope this helps.
Code: Select all
init: #this init block gets executed second (at the default priority of 0)
def foo(shift):
global mylist
return (shift*5)/len(mylist)
init -2: #This init block gets executed first
temp = ""
mylist = []
init 5: #This block gets executed third
def bar(num, itr):
return foo(num)%itr- rabcor
- Regular
- Posts: 81
- Joined: Sun Mar 17, 2013 3:07 pm
- Projects: None (Need a programmer?)
- Organization: Cestarian Games
- Contact:
Re: Linking multiple files/scripts and compression
yup it does, thanks 
Who is online
Users browsing this forum: No registered users



