Help to make simple function

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
Andredron
Miko-Class Veteran
Posts: 718
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Help to make simple function

#1 Post by Andredron »

Hello everyone, my code looks like this

Code: Select all

######################script.rpy
    voice "voice/03.ogg"
    sh "放置のほうがムナシイだろ?"
    
    scene c5
    show c5_morg3
    show c5_1_4
    with dissolve
    
    au "どうしてオマエはそんなに醒めてんの?!"
    
    scene c5
    show c5_1_3
    show c5_morg2
    with dissolve

###################resurse.rpy
init:
    image c5_morg2:
        "c5_1_3"   
        choice:
            4.5
        choice:
            3.5
        choice:
            1.5
        "c5_1_1"
        .25
        repeat
    image c5_morg3:
        "c5_1"   
        choice:
            4.5
        choice:
            3.5
        choice:
            1.5
        "c5_1_1"
        .25
        repeat
the code works, but the trouble is that the code becomes huge. I wanted to make a function of this type

Code: Select all

init python:
    def morg(image1,image2):
        image1   
        choice:
            4.5
        choice:
            3.5
        choice:
            1.5
        image2
        .25
        repeat

#############script.rpy

    voice "voice/03.ogg"
    sh "放置のほうがムナシイだろ?"
    
    scene c5
    $ morg("c5_1_3","c5_1_1")
    with dissolve
    
    au "どうしてオマエはそんなに醒めてんの?!"
    
    scene c5
    show c5_1_3
    $ morg("c5_1","c5_1_1")
    with dissolve
But I don't remember renpy written images argument...Help PL

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Help to make simple function

#2 Post by Remix »

transform rather than image and then show expression...

Code: Select all

transform morg( img1, img2 ):
    img1
    choice:
        1.5
    choice:
        0.5
    img2
    0.1
    repeat

label start:
    
    "Start"
    show expression morg("images/bg 0.png","images/bg 1.png")
    "End"
Frameworks & Scriptlets:

User avatar
Andredron
Miko-Class Veteran
Posts: 718
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Help to make simple function

#3 Post by Andredron »

Remix wrote: Tue Oct 23, 2018 5:12 am transform rather than image and then show expression...

Code: Select all

transform morg( img1, img2 ):
    img1
    choice:
        1.5
    choice:
        0.5
    img2
    0.1
    repeat

label start:
    
    "Start"
    show expression morg("images/bg 0.png","images/bg 1.png")
    "End"
Oh, I forgot that they can be! Thank

Post Reply

Who is online

Users browsing this forum: barsunduk, bloodzy, dragondatingsim