Simplifying a character code
Posted: Fri May 31, 2019 1:08 am
Hi!
Im new with RenPy and I just started a game, Im testing with three characters (and it may come some more), so I making them using "LiveComposite" so it has movement with the eyes for blinking and mouth when talking
I have this code in characters.rpy
Basically I'm repeating the code over and over for every character, then in the script.rpy I use it like this:
Everytime I make a character talk, I set it up as "TRUE" when talking and everybody else as "FALSE", also, I set up the expression and what their eyes are doing, and the direction facing...
So my question is... isnt there a way to simplify this? May be create a function like so:
Thanks for the assist! 
Im new with RenPy and I just started a game, Im testing with three characters (and it may come some more), so I making them using "LiveComposite" so it has movement with the eyes for blinking and mouth when talking
I have this code in characters.rpy
Code: Select all
default andy_talking = False
default andy_eyes = "Blinking" #Blinking, Opened, Closed
default andy_expression = "Happy" #Happy, Shy -- Pendientes: Horny, Sad, Surprise, Angry
default andy_side = "Right" #Left or Right
image andy mouth still = "images/personajes/Andy/[andy_expression]/[andy_side]_Mouth_0001.png"
image andy eyes closed = "images/personajes/Andy/[andy_expression]/[andy_side]_Eyes_closed.png"
image andy eyes opened = "images/personajes/Andy/[andy_expression]/[andy_side]_Eyes_opened.png"
image andy mouth talking:
"images/personajes/Andy/[andy_expression]/[andy_side]_Mouth_0001.png"
0.2
"images/personajes/Andy/[andy_expression]/[andy_side]_Mouth_0002.png"
0.2
"images/personajes/Andy/[andy_expression]/[andy_side]_Mouth_0003.png"
0.5
repeat
image andy eyes blinking:
"images/personajes/Andy/[andy_expression]/[andy_side]_Eyes_opened.png"
choice:
2.0
choice:
3.1
choice:
4.2
choice:
3.3
"images/personajes/Andy/[andy_expression]/[andy_side]_Eyes_closed.png"
.25
"images/personajes/Andy/[andy_expression]/[andy_side]_Eyes_opened.png"
.13
repeat
image andy = LiveComposite((644, 720),
(0,0), "images/personajes/Andy/[andy_expression]/Base_[andy_side].png",
(0,0), ConditionSwitch(
"andy_eyes == 'Blinking'", "andy eyes blinking",
"andy_eyes == 'Closed'", "andy eyes closed",
"andy_eyes == 'Opened'", "andy eyes opened"),
(0,0), ConditionSwitch(
"andy_talking", "andy mouth talking",
"True", "andy mouth still")
)
default chloe_talking = False
default chloe_eyes = "Blinking" #Blinking, Opened, Closed
default chloe_expression = "Happy" #Angry, Happy, Surprise -- Pendientes: Horny, Sad, Shy
default chloe_side = "Right" #Left or Right
image chloe mouth still = "images/personajes/Chloe/[chloe_expression]/[chloe_side]_Mouth_0001.png"
image chloe eyes closed = "images/personajes/Chloe/[chloe_expression]/[chloe_side]_Eyes_closed.png"
image chloe eyes opened = "images/personajes/Chloe/[chloe_expression]/[chloe_side]_Eyes_opened.png"
image chloe mouth talking:
"images/personajes/Chloe/[chloe_expression]/[chloe_side]_Mouth_0001.png"
0.2
"images/personajes/Chloe/[chloe_expression]/[chloe_side]_Mouth_0002.png"
0.2
"images/personajes/Chloe/[chloe_expression]/[chloe_side]_Mouth_0003.png"
0.5
repeat
image chloe eyes blinking:
"images/personajes/Chloe/[chloe_expression]/[chloe_side]_Eyes_opened.png"
choice:
2.0
choice:
3.1
choice:
4.2
choice:
3.3
"images/personajes/Chloe/[chloe_expression]/[chloe_side]_Eyes_closed.png"
.25
"images/personajes/Chloe/[chloe_expression]/[chloe_side]_Eyes_opened.png"
.13
repeat
image chloe = LiveComposite((644, 720),
(0,0), "images/personajes/Chloe/[chloe_expression]/Base_[chloe_side].png",
(0,0), ConditionSwitch(
"chloe_eyes == 'Blinking'", "chloe eyes blinking",
"chloe_eyes == 'Closed'", "chloe eyes closed",
"chloe_eyes == 'Opened'", "chloe eyes opened"),
(0,0), ConditionSwitch(
"chloe_talking", "chloe mouth talking",
"True", "chloe mouth still")
)
default sophia_talking = False
default sophia_eyes = "Blinking" #Blinking, Opened, Closed
default sophia_expression = "Happy" #Angry, Happy, Surprise -- Pendientes: Horny, Sad, Shy
default sophia_side = "Right" #Left or Right
image sophia mouth still = "images/personajes/Sophia/[sophia_expression]/[sophia_side]_Mouth_0001.png"
image sophia eyes closed = "images/personajes/Sophia/[sophia_expression]/[sophia_side]_Eyes_closed.png"
image sophia eyes opened = "images/personajes/Sophia/[sophia_expression]/[sophia_side]_Eyes_opened.png"
image sophia mouth talking:
"images/personajes/Sophia/[sophia_expression]/[sophia_side]_Mouth_0001.png"
0.2
"images/personajes/Sophia/[sophia_expression]/[sophia_side]_Mouth_0002.png"
0.2
"images/personajes/Sophia/[sophia_expression]/[sophia_side]_Mouth_0003.png"
0.5
repeat
image sophia eyes blinking:
"images/personajes/Sophia/[sophia_expression]/[sophia_side]_Eyes_opened.png"
choice:
2.0
choice:
3.1
choice:
4.2
choice:
3.3
"images/personajes/Sophia/[sophia_expression]/[sophia_side]_Eyes_closed.png"
.25
"images/personajes/Sophia/[sophia_expression]/[sophia_side]_Eyes_opened.png"
.13
repeat
image sophia = LiveComposite((644, 720),
(0,0), "images/personajes/Sophia/[sophia_expression]/Base_[sophia_side].png",
(0,0), ConditionSwitch(
"sophia_eyes == 'Blinking'", "sophia eyes blinking",
"sophia_eyes == 'Closed'", "sophia eyes closed",
"sophia_eyes == 'Opened'", "sophia eyes opened"),
(0,0), ConditionSwitch(
"sophia_talking", "sophia mouth talking",
"True", "sophia mouth still")
)
Code: Select all
$ chloe_talking = True
$ chloe_expression = "Angry"
$ chloe_eyes = "Blinking"
$ chloe_side = "Left"
$ sophia_talking = False
$ sophia_expression = "Angry"
$ sophia_eyes = "Blinking"
$ andy_talking = False
$ andy_expression = "Shy"
$ andy_eyes = "Closed"
chloe_character "Hello Andy!"
$ chloe_talking = False
$ chloe_expression = "Happy"
$ chloe_eyes = "Blinking"
$ chloe_side = "Right"
$ sophia_talking = False
$ sophia_expression = "Happy"
$ sophia_eyes = "Blinking"
$ andy_talking = True
$ andy_expression = "Happy"
$ andy_eyes = "Blinking"
andy_character "Oh, Hi there! I'm Boo bo... I meen Andy... please to meet you"
$ chloe_talking = False
$ chloe_expression = "Surprise"
$ chloe_eyes = "Opened"
$ sophia_talking = True
$ sophia_expression = "Horny"
$ sophia_eyes = "Opened"
$ andy_talking = False
$ andy_expression = "Happy"
$ andy_eyes = "Blinking"
sophia_character "Hi, I'm Sophia, my friend call me Sophy, but you can call me when ever you want!"
So my question is... isnt there a way to simplify this? May be create a function like so:
Code: Select all
$ setcharacter ('Andy', False, 'Surprise', 'Opened', 'Left')