Linking multiple files/scripts and compression

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
User avatar
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

#1 Post by rabcor » Fri Nov 22, 2013 5:45 am

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?

User avatar
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

#2 Post by SundownKid » Fri Nov 22, 2013 6:05 am

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..."

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')
(I think you only need to compress the .rpyc files though, .rpy can be removed.)

User avatar
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

#3 Post by rabcor » Fri Nov 22, 2013 6:45 am

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?)

User avatar
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

#4 Post by sendo » Fri Nov 22, 2013 8:48 am

rabcor wrote:Thanks a lot! that explains most of it! it's almost too easy.
That's the beauty of Ren'py ^^ sometimes I think it's magic :D
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?)
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. :)
Finished VNs:
Image Image

User avatar
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

#5 Post by rabcor » Fri Nov 22, 2013 9:08 am

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 :D

ForklessAnon
Regular
Posts: 49
Joined: Fri Sep 06, 2013 1:13 am
Contact:

Re: Linking multiple files/scripts and compression

#6 Post by ForklessAnon » Fri Nov 22, 2013 10:53 am

Example of init declaration (the code shown is arbitrary):

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
Hope this helps.

User avatar
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

#7 Post by rabcor » Fri Nov 22, 2013 12:00 pm

yup it does, thanks :)

Post Reply

Who is online

Users browsing this forum: No registered users