Dynamic way to add videos need HELP

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
Mord87
Regular
Posts: 26
Joined: Fri May 31, 2019 7:17 pm
Contact:

Dynamic way to add videos need HELP

#1 Post by Mord87 » Mon Nov 11, 2019 6:43 pm

Hello everybody!

I have a big problem with my game. I made a random npc generator wich is working fine. I try to add videos depends on the characters but I can not make it to work. The characters randomly generated with hair color, body type and skin color. I using dynamic images for these generated characters. I tried the same way with the videos but no luck. I hope somebody can help me.
Thank You!
This is how the generator is working:

Code: Select all

init python:
    class RandomNPCf():
        def __init__(self, namelistf):
            self.name = renpy.random.choice(namelistf)
            self.hairtext = "black"
            self.bodytype = "skinny"
            self.bodycolor = "white"
            self.sextype = renpy.random.choice(sextypelistf)
            self.trait = renpy.random.choice(traitlist)

    portrait1f="black.jpg"
    portrait2f="black.jpg"
    portrait3f="black.jpg"
    
    center1f="black.jpg"
    center2f="black.jpg"
    center3f="black.jpg"
   
define randnamelistf = ["Eva", "Emma", "Violet", "Tina", "Juliet", "Olivia", "Mia", "Zoey", "Eleanor", "Rylee",  "Mary", "Harmony", "Leila", "Ember"]
define hairlist = ["red", "black", "blonde", "brunette"]
define bodytypelist = ["skinny", "average", "chubby"]
define bodycolorlist = ["white", "tanned", "black"]

define randchar1f = RandomNPCf(randnamelistf)
define randchar2f = RandomNPCf(randnamelistf)
define randchar3f = RandomNPCf(randnamelistf)

define rc1f = Character("[randchar1f.name]", image="randchar1f")
define rc2f = Character("[randchar2f.name]", image="randchar2f")
define rc3f = Character("[randchar3f.name]", image="randchar3f")

image randchar1f center = "[center1f]"
image randchar2f center = "[center2f]"
image randchar3f center = "[center3f]"


label start:
    $ i=0

    while i<3:
        if len(hairlist)==0:
            $ hairlist = ["red", "black", "blonde", "brunette"]
        $ hair = renpy.random.randint(0, len(hairlist)-1)
        $ hairtext = hairlist.pop(hair)
        if len(bodytypelist)==0:
            $ bodytypelist = ["skinny", "average", "chubby"]
        $ btype = renpy.random.randint(0, len(bodytypelist)-1)
        $ bodytype = bodytypelist.pop(btype)
        if len(bodycolorlist)==0:
            $ bodycolorlist = ["white", "tanned", "black"]
        $ bcolor = renpy.random.randint(0, len(bodycolorlist)-1)
        $ bodycolor = bodycolorlist.pop(bcolor)
        
        if i==0:
            $ randchar1f.hairtext=hairtext
            $ randchar1f.bodytype=bodytype
            $ randchar1f.bodycolor=bodycolor
            $ randompics = renpy.random.randint(1, 3)
            if randompics == 1:
                $ portrait1f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "1p.png"
                $ center1f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "1.png"
            elif randompics == 2:
                $ portrait1f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "2p.png"
                $ center1f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "2.png"
            elif randompics == 3:
                $ portrait1f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "3p.png"
                $ center1f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "3.png"
                
        elif i==1:
            $ randchar2f.hairtext=hairtext
            $ randchar2f.bodytype=bodytype
            $ randchar2f.bodycolor=bodycolor
            $ randompics = renpy.random.randint(1, 3)
            if randompics == 1:
                $ portrait2f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "1p.png"
                $ center2f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "1.png"
            elif randompics == 2:
                $ portrait2f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "2p.png"
                $ center2f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "2.png"
            elif randompics == 3:
                $ portrait2f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "3p.png"
                $ center2f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "3.png"
                
        elif i==2:
            $ randchar3f.hairtext=hairtext
            $ randchar3f.bodytype=bodytype
            $ randchar3f.bodycolor=bodycolor
            $ randompics = renpy.random.randint(1, 3)
            if randompics == 1:
                $ portrait3f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "1p.png"
                $ center3f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "1.png"
            elif randompics == 2:
                $ portrait3f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "2p.png"
                $ center3f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "2.png"
            elif randompics == 3:
                $ portrait3f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "3p.png"
                $ center3f= "images/npc/female/" + hairtext + "/" + bodytype + "/" + bodycolor + "3.png"
                
         $ i +=1      
         
 # My game start from here. This code above is working perfectly. It is choosing the images fine from the folders depends on the stats.         
Here is the code when I tried to add a video. I have videos for each variation so i want to play the right video wich is fit for the generated character.
I tried diffferent ways but all of them was faulty. It is keep saying the video not found.

Code: Select all

# THIS IS THE FIRST VERSION WICH I TRIED:
image randchar1_dance = Movie(play="[rc1dance]", xalign=0.5, yalign=0.2)

label club:
	$ rc1dance = "images/npc/female/" + randchar1f.hairtext + "/" + randchar1f.bodytype + "/" + randchar1f.bodycolor + "/dance.webm"
	call screen rc1dance:
		add "randchar1_dance"
		text "[randchar1f.name] - You are a great dancer."
		vbox xpos 1600 ypos 100:
            		textbutton "Leave" action Jump("map")
            		
# THIS IS THE SECOND VERSION WICH I TRIED:  
image randchar1_dance = Movie(play="[rc1dance]", xalign=0.5, yalign=0.2)

label club:
	$ rc1dance = "images/npc/female/" + "[randchar1f.hairtext]" + "/" + "[randchar1f.bodytype]" + "/" + "[randchar1f.bodycolor]" + "/dance.webm"
	call screen rc1dance:
		add "randchar1_dance"
		text "[randchar1f.name] - You are a great dancer."
		vbox xpos 1600 ypos 100:
            		textbutton "Leave" action Jump("map")    
            		
# THIS IS THE THIRD VERSION WICH I TRIED:  
image randchar1_dance = Movie(play="[rc1dance]", xalign=0.5, yalign=0.2)

label club:
	$ rc1dance = "images/npc/female/[randchar1f.hairtext]/[randchar1f.bodytype]/[randchar1f.bodycolor]/dance.webm"
	call screen rc1dance:
		add "randchar1_dance"
		text "[randchar1f.name] - You are a great dancer."
		vbox xpos 1600 ypos 100:
            		textbutton "Leave" action Jump("map")                		      		
I hope it is clear. I just want to know the way I can add the videos like the dynamic images.
Thanks Again!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 556
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Dynamic way to add videos need HELP

#2 Post by Per K Grok » Tue Nov 12, 2019 1:36 am

Mord87 wrote:
Mon Nov 11, 2019 6:43 pm
I just want to know the way I can add the videos like the dynamic images.
Thanks Again!
In your code you first define an image as a movie with the name of the movie as a variable.

You then later defines what that variable stands for.

That will not work. You need to do it the other way around.

try

Code: Select all

 
 
$ rc1dance = "images/npc/female/[randchar1f.hairtext]/[randchar1f.bodytype]/[randchar1f.bodycolor]/dance.webm"
$  randchar1_dance = Movie(play="[rc1dance]", xalign=0.5, yalign=0.2)
 
 
Not tested
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

Mord87
Regular
Posts: 26
Joined: Fri May 31, 2019 7:17 pm
Contact:

Re: Dynamic way to add videos need HELP

#3 Post by Mord87 » Tue Nov 12, 2019 7:31 pm

Thanks for your help but it is not working. I tried to put your code in different places but still nothing.
The fault is always the same: Can't register channel outside of init phase.
The game not starting just this fault comes up.
I hope you or somebody have an another idea.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 556
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Dynamic way to add videos need HELP

#4 Post by Per K Grok » Wed Nov 13, 2019 3:58 pm

Mord87 wrote:
Tue Nov 12, 2019 7:31 pm
Thanks for your help but it is not working. I tried to put your code in different places but still nothing.
The fault is always the same: Can't register channel outside of init phase.
The game not starting just this fault comes up.
I hope you or somebody have an another idea.

Well it seems like movie as an image must be defined in the init phase.

Since you, as I understand it, has made a movie for each possible combination you could define an image for each of this possibilities. Have a variable (pick) based on the choices made by the player that determines which of these will be added to the screen

Code: Select all

image dance1 = Movie(play="dance1.webm")
image dance2 = Movie(play="dance2.webm")
----


screen dance():
    add "dance" + str(pick)
Also this idea is not tested.
Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

Mord87
Regular
Posts: 26
Joined: Fri May 31, 2019 7:17 pm
Contact:

Re: Dynamic way to add videos need HELP

#5 Post by Mord87 » Wed Nov 13, 2019 10:01 pm

This is not good for me. The problem is I don`t want to add each clip one by one cos I have over 1000 clips. That is the reason I looking for the solution for the dynamic type system. I got all the videos in the folder system so renpy can open the right one for the right npc. It is working perfectly with the images. I just can not figure out how to do with the movie.
Thank You anyway!

Post Reply

Who is online

Users browsing this forum: darxori, Google [Bot]