Programming Method Question

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
ShaydeZehetbauer
Newbie
Posts: 7
Joined: Sat Apr 04, 2009 1:09 pm
Projects: Lost In Translation VN
Location: Hirikata, Japan
Contact:

Programming Method Question

#1 Post by ShaydeZehetbauer »

Hey, all goes well so far with my project but I've got a quick question about efficiant ways to organise code.

In my tech demo, which I made whilst I was still getting the feel for Ren'Py, I coded the entire demo in the script.rpy file, but here is the question I'm posing.

Can I have different sections of the game (for example, my game is in Acts, so for example actone_op or something) in other script files and have script.rpy call that script, which would ideally run the opening sequence of that act?

After the theory, I thought it would work, and I'd be able to have the main code looking something like this.

Code: Select all

actone_op
actone_arrival
actone_schooldayone
actone_classone
actone_endclass
Some advice and help would be very appreciated!

Thanks in advance guys!

- Shayde

Dusty
Regular
Posts: 126
Joined: Fri Jul 25, 2008 11:51 pm
Contact:

Re: Programming Method Question

#2 Post by Dusty »

If you use label:s, you can put different labels in different script files, and then jump to the next label after each act is finished. What file the label:s are in doesn't really matter. You don't even have to have a script.rpy file, even, as long as you place a label start: somewhere.

So, with your script names you could have, in actone_op.rpy:

Code: Select all

label start:
    #the introduction...
    #....
    #your script goes here....

    #and now the act is over, so we
    jump actone_arrival
and then place this next bit into actone_arrival.rpy:

Code: Select all

label actone_arrival:
    #the next portion of the script goes here...
    #....

    #and now the act is over, so we
    jump actone_schooldayone
and it will be just like the script was all on one file.

ShaydeZehetbauer
Newbie
Posts: 7
Joined: Sat Apr 04, 2009 1:09 pm
Projects: Lost In Translation VN
Location: Hirikata, Japan
Contact:

Re: Programming Method Question

#3 Post by ShaydeZehetbauer »

Awesome, that's a spot of good news then, thanks for that.

I'm guessing I don't have to define images and characters again for each script seeing as it's already done in the main script file?

Dusty
Regular
Posts: 126
Joined: Fri Jul 25, 2008 11:51 pm
Contact:

Re: Programming Method Question

#4 Post by Dusty »

Yes, you only have to define images and characters once.

(And just like label:s can be put anywhere, you can define images and characters anywhere, as long as they get put inside an init: block.)

ShaydeZehetbauer
Newbie
Posts: 7
Joined: Sat Apr 04, 2009 1:09 pm
Projects: Lost In Translation VN
Location: Hirikata, Japan
Contact:

Re: Programming Method Question

#5 Post by ShaydeZehetbauer »

Awesome, thanks alot for your help, Dusty! :)

Now it's time to go work on my Imagemap Titlescreen. :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]