Page 1 of 1

Dynamic way to add videos need HELP

Posted: Mon Nov 11, 2019 6:43 pm
by Mord87
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!

Re: Dynamic way to add videos need HELP

Posted: Tue Nov 12, 2019 1:36 am
by Per K Grok
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

Re: Dynamic way to add videos need HELP

Posted: Tue Nov 12, 2019 7:31 pm
by Mord87
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.

Re: Dynamic way to add videos need HELP

Posted: Wed Nov 13, 2019 3:58 pm
by Per K Grok
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.

Re: Dynamic way to add videos need HELP

Posted: Wed Nov 13, 2019 10:01 pm
by Mord87
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!