Need Help with Live Composite

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
amaturemanga
Regular
Posts: 97
Joined: Sun Mar 08, 2015 6:55 pm
Deviantart: amaturemanga
Skype: amature.manga
Contact:

Need Help with Live Composite

#1 Post by amaturemanga »

Hey everyone i trying to make an option for a customizable character using Live Composite but i'm getting a syntax error here is the error along with my code

error:

Code: Select all

File "game/script.rpy", line 7: invalid syntax
            define base = "base.png"
code:

Code: Select all

# You can place the script of your game in this file.
init python:
    dressup_button_show = False
    hair= 1 # default dressup items
    hair_styles_num= 6 # number of styles (files) for each dressup item
    # define images as:
    define base= "base.png" 
    define hair1= "hair1.png"
    define hair2= "hair2.png"
    define hair3= "hair3.png"
    define hair4= "hair4.png"
    define hair5= "hair5.png"
    define hair6= "hair6.png"
    

    def draw_char(st, at): # combine the dressup items into one displayable
        return LiveComposite(
            (361, 702), # image size
            (0, 0), "base.png",
            (0, 0), "hair%d.png"%hair,
            ),.1

    def draw_char_side(st, at): # same thing as above, just scaled and positioned for the sideimage; there's probably more elegant solution than this...
        return LiveComposite(
            (361, 702),
            (10, 550), im.FactorScale("base.png", .45, .45),
            (10, 550), im.FactorScale("hair%d.png"%hair, .45, .45),
            ),.1

init:
    image char = DynamicDisplayable(draw_char) # using DynamicDisplayable ensures that any changes are visible immedietly
    $ character = Character('player', color="#c8ffc8", window_left_padding=180, show_side_image=DynamicDisplayable(draw_char_side))

# Declare images below this line, using the image statement.
image mainmenu = "hypnotic_student.png"
image ctc_animation = Animation("ctcarrow01.png", 0.2, "ctcarrow02.png", 0.2, xalign=0.9, yalign=0.9)

# Declare characters used by this game.
define story = Character(None, kind = nvl, ctc = None)

define player = Character("[playername]")

# The game starts here.
label splashscreen:
    scene black 
    $ renpy.pause(1)
    
    show text "The following story is a work of fiction and contain fantasy situations and does not reflect hypnosis in real life" with dissolve
    $ renpy.pause(2)
    
    hide text with dissolve
    $renpy.pause(1)
    
    $ renpy.pause(1)
    
    show text "AmatureManga Productions Presents\na story by: AmatureManga   and   Art by: SilverKazeNinja" with dissolve ## fix
    $ renpy.pause(2)
    play music "Metaphysik.mp3"
    hide text with dissolve
    $renpy.pause(2)
    return ## fix
    
label start:
    label dressup:
    show char:
        xpos 250
    python:
        # display the arrows for changing the dress:
        y = 50
        ui.imagebutton("arrowL.png", "arrowL.png", clicked=ui.returns("hairL"), ypos=y, xpos=50)
        ui.imagebutton("arrowR.png", "arrowR.png", clicked=ui.returns("hairR"), ypos=y, xpos=400)
        y += 80
        
    $ picked = ui.interact()
    # based on the selection, we increase or decrease the index of the appropriate dress up item
    if picked == "hairL":
        $ hair -= 1 # previous hair
    if picked == "hairR":
        $ hair += 1 # next hair
    if hair < 1: # making sure we don't get out of index range (index 0 is not allowed)
        $ hair = hair_styles_num
    if hair > hair_styles_num: # making sure we don't get out of index range (index musn't be bigger than hair_styles_num)
        $ hair = 1

    $ story = Character(None, ctc="ctc_animation", ctc_position="fixed", kind=nvl)
    stop music
    with dissolve
    
    window show fade
    $ playername = renpy.input("Please enter your character's name below.")
    $ playername = playername.strip()
    window hide fade  
    
window show fade 
story "I am walking down a dark corridor. It is a corridor i am very familiar with."
story "As this is a dream i have almost every night."
story "I can feel the darkness telling every fiber in my body to turn back,"
story "but i know... i know i have to press forward as i reach the familiar corner..."
nvl clear 
window hide fade

window show fade
story "I turn the corner and find myself in a familiar dark abandoned room"
nvl clear
window hide fade

 
return
    
I want it to be set up so when the player presses start on the main menu the player customization window comes up and then after they've created their character in the next scene the window where they name their character comes up and then moves on to the actual game. Any help would appreciated.

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Need Help with Live Composite

#2 Post by Pippin123 »

that's not how you define image in renpy:

Code: Select all

image eileen happy = "eileen_happy.png"
Also the whole block appears useless, since you are directly calling the .png files by their name in your code.

Code: Select all

    # define images as:
    define base= "base.png" 
    define hair1= "hair1.png"
    define hair2= "hair2.png"
    define hair3= "hair3.png"
    define hair4= "hair4.png"
    define hair5= "hair5.png"
    define hair6= "hair6.png"
Try to remove your whole "define" block, the code should work fine without it

edit: also, look into the cookbook section, there's a few dress up code you can literally cut and paste.

User avatar
amaturemanga
Regular
Posts: 97
Joined: Sun Mar 08, 2015 6:55 pm
Deviantart: amaturemanga
Skype: amature.manga
Contact:

Re: Need Help with Live Composite

#3 Post by amaturemanga »

Pippin123 wrote:that's not how you define image in renpy:

Code: Select all

image eileen happy = "eileen_happy.png"
Also the whole block appears useless, since you are directly calling the .png files by their name in your code.

Code: Select all

    # define images as:
    define base= "base.png" 
    define hair1= "hair1.png"
    define hair2= "hair2.png"
    define hair3= "hair3.png"
    define hair4= "hair4.png"
    define hair5= "hair5.png"
    define hair6= "hair6.png"
Try to remove your whole "define" block, the code should work fine without it

edit: also, look into the cookbook section, there's a few dress up code you can literally cut and paste.
ok now its working but now when i click on the arrow it changes the hair but then it goes to the next scene and the characters stays there on the screen any ideas?

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Need Help with Live Composite

#4 Post by Pippin123 »

It doesn't loop, because you never told Renpy to loop.

you need a "jump dressup" at the end to make it loop and another "ok" button that breaks the loop by jumping to another label.

Also, I don't know if it's copy/paste, but the label start / label dressup indentation you have is wrong. Labels are self contained. Here it works because start is empty so renpy just read label dressup instead, but it could cause problems.

also, do read: http://lemmasoft.renai.us/forums/viewto ... 51&t=14559
Everything is there.
or another version I did (slightly more complex)
http://lemmasoft.renai.us/forums/viewto ... 51&t=30643

User avatar
amaturemanga
Regular
Posts: 97
Joined: Sun Mar 08, 2015 6:55 pm
Deviantart: amaturemanga
Skype: amature.manga
Contact:

Re: Need Help with Live Composite

#5 Post by amaturemanga »

Pippin123 wrote:It doesn't loop, because you never told Renpy to loop.

you need a "jump dressup" at the end to make it loop and another "ok" button that breaks the loop by jumping to another label.

Also, I don't know if it's copy/paste, but the label start / label dressup indentation you have is wrong. Labels are self contained. Here it works because start is empty so renpy just read label dressup instead, but it could cause problems.

also, do read: http://lemmasoft.renai.us/forums/viewto ... 51&t=14559
Everything is there.
or another version I did (slightly more complex)
http://lemmasoft.renai.us/forums/viewto ... 51&t=30643
how do i code the ok image button? Because before you responded i fixed the looping problem but now i need to make the ok button so the loop breaks, the character isnt visible anymore and it goes to the next scene. I know the ok button would go under ui.imagebutton but im not sure how to code it properly.

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Need Help with Live Composite

#6 Post by Pippin123 »

I refer you to the exemple:
http://lemmasoft.renai.us/forums/viewto ... 51&t=14559

his "Ok" button is called "Return" , but it's the same.

Post Reply

Who is online

Users browsing this forum: 3N16M4, Bing [Bot]