How to allow the player to choose their character?
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.
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.
How to allow the player to choose their character?
In my game, the player will always see everything as in "first-person". Their character will never show up in the scene.
But I wanted to let them choose their side imagem. It will be static and won't change according to the story. It's just like a profile picture.
I'll make a menu giving them the options of avatar they have, and those images will show up when they speak (as a side image).
This will not change the character they are, only the picture. Even because I let them choose their names.
I'm new on Renpy, so can you give me some help?
I wanted to know what code I should use to do this.
Thanks in advance.
But I wanted to let them choose their side imagem. It will be static and won't change according to the story. It's just like a profile picture.
I'll make a menu giving them the options of avatar they have, and those images will show up when they speak (as a side image).
This will not change the character they are, only the picture. Even because I let them choose their names.
I'm new on Renpy, so can you give me some help?
I wanted to know what code I should use to do this.
Thanks in advance.
I can't access my other account cause I don't remember the e-mail I used *cries in emoji*.
Re: How to allow the player to choose their character?
I've just learned how to do something similar so maybe it will help you.
I think you should look into DynamicImages. You can assign a variable to your portrait, and after the player chooses an avatar, assign a number to it.
First of all, say you have 3 different avatars to choose from, name them something like this:
Then at the top of your script, where the variables are inititally set, define one for your character's portraits and set up the dynamic image, something like this:
That will set the default character to 1, and prepare the dynamic image for later.
Then you let the player choose which one they want to be, so you need some kind of menu with the 'avatar' variable gets set. It'll look something like this:
Now that the player has chosen their avatar, you just need to reference it wherever you want the portrait image to appear. To show it, you just need to show the dynamic image that we set up:
That should work. Let me know if you get stuck.
I think you should look into DynamicImages. You can assign a variable to your portrait, and after the player chooses an avatar, assign a number to it.
First of all, say you have 3 different avatars to choose from, name them something like this:
Code: Select all
"character1.jpg"
"character2.jpg"
"character3.jpg"
Code: Select all
default avatar = 1
image characterPortrait = DynamicImage("character[avatar].jpg" )
Then you let the player choose which one they want to be, so you need some kind of menu with the 'avatar' variable gets set. It'll look something like this:
Code: Select all
menu:
"Choose Character 1":
$ avatar = 1
"Choose Character 2":
$ avatar = 2
"Choose Character 3":
$ avatar = 3
Code: Select all
show characterPortrait
Re: How to allow the player to choose their character?
Thank you so much! I'm gonna try it
I can't access my other account cause I don't remember the e-mail I used *cries in emoji*.
Re: How to allow the player to choose their character?
Unluckly it said:
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00start.rpy", line 188, in script
python:
File "renpy/common/00start.rpy", line 189, in <module>
renpy.execute_default_statement(True)
File "game/script.rpy", line 27, in set_default
default avatar = 2
Exception: store.avatar is being given a default a second time.
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00start.rpy", line 188, in script
python:
File "renpy/common/00start.rpy", line 189, in <module>
renpy.execute_default_statement(True)
File "game/script.rpy", line 27, in set_default
default avatar = 2
Exception: store.avatar is being given a default a second time.
I can't access my other account cause I don't remember the e-mail I used *cries in emoji*.
- 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: How to allow the player to choose their character?
The hint is in the exception response:
Exception: store.avatar is being given a default a second time.
Are you using 'default avatar = ????' more than once?
After setting default once, just alter the value normally where needed (without using 'default' again)
Exception: store.avatar is being given a default a second time.
Are you using 'default avatar = ????' more than once?
After setting default once, just alter the value normally where needed (without using 'default' again)
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: How to allow the player to choose their character?
Thanks for your help
I can't access my other account cause I don't remember the e-mail I used *cries in emoji*.
Re: How to allow the player to choose their character?
Hello, i'm a complete noob at this, is this up to date? If not can someone who's experienced help me with this?
https://gutrotz.itch.io/
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
Re: How to allow the player to choose their character?
heyo is this up to date?Tekamutt wrote: ↑Tue Dec 05, 2017 4:48 pm I've just learned how to do something similar so maybe it will help you.
I think you should look into DynamicImages. You can assign a variable to your portrait, and after the player chooses an avatar, assign a number to it.
First of all, say you have 3 different avatars to choose from, name them something like this:
Then at the top of your script, where the variables are inititally set, define one for your character's portraits and set up the dynamic image, something like this:Code: Select all
"character1.jpg" "character2.jpg" "character3.jpg"
That will set the default character to 1, and prepare the dynamic image for later.Code: Select all
default avatar = 1 image characterPortrait = DynamicImage("character[avatar].jpg" )
Then you let the player choose which one they want to be, so you need some kind of menu with the 'avatar' variable gets set. It'll look something like this:
Now that the player has chosen their avatar, you just need to reference it wherever you want the portrait image to appear. To show it, you just need to show the dynamic image that we set up:Code: Select all
menu: "Choose Character 1": $ avatar = 1 "Choose Character 2": $ avatar = 2 "Choose Character 3": $ avatar = 3
That should work. Let me know if you get stuck.Code: Select all
show characterPortrait
https://gutrotz.itch.io/
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
- mitoky
- Veteran
- Posts: 316
- Joined: Sat Feb 07, 2015 9:12 pm
- Projects: The Purring Demon's Love, circus eterie
- Contact:
Re: How to allow the player to choose their character?
I think it is, at least i see no reason why it shouldnt be working.chungy wrote: ↑Mon Sep 24, 2018 5:50 pmheyo is this up to date?Tekamutt wrote: ↑Tue Dec 05, 2017 4:48 pm I've just learned how to do something similar so maybe it will help you.
I think you should look into DynamicImages. You can assign a variable to your portrait, and after the player chooses an avatar, assign a number to it.
First of all, say you have 3 different avatars to choose from, name them something like this:
Then at the top of your script, where the variables are inititally set, define one for your character's portraits and set up the dynamic image, something like this:Code: Select all
"character1.jpg" "character2.jpg" "character3.jpg"
That will set the default character to 1, and prepare the dynamic image for later.Code: Select all
default avatar = 1 image characterPortrait = DynamicImage("character[avatar].jpg" )
Then you let the player choose which one they want to be, so you need some kind of menu with the 'avatar' variable gets set. It'll look something like this:
Now that the player has chosen their avatar, you just need to reference it wherever you want the portrait image to appear. To show it, you just need to show the dynamic image that we set up:Code: Select all
menu: "Choose Character 1": $ avatar = 1 "Choose Character 2": $ avatar = 2 "Choose Character 3": $ avatar = 3
That should work. Let me know if you get stuck.Code: Select all
show characterPortrait
Re: How to allow the player to choose their character?
i'm not sure exactly where to put what variables since im pretty new at this. Is there an easy way to explain where to place things? Also ty for responding! ^__^
https://gutrotz.itch.io/
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
- mitoky
- Veteran
- Posts: 316
- Joined: Sat Feb 07, 2015 9:12 pm
- Projects: The Purring Demon's Love, circus eterie
- Contact:
Re: How to allow the player to choose their character?
Oh ok, no problem.
Okay, so lets start with this part first:
Code: Select all
"character1.jpg"
"character2.jpg"
"character3.jpg"
So this part of the code only tells you that you must name your files in the same way and is not part of the code itself.
The next part is this one:
Code: Select all
default avatar = 1
image characterPortrait = DynamicImage("character[avatar].jpg" )
On default, declared images etc are inside the script.rpy on the top, but you can make a seperate .rpy file too to declare it there as Ren'Py reads all files as "one".
So which file isn't really important. The only important thing is that they have to be declared outside of any labels etc to work correctly and without any intending.
Example how it could look inside the script.rpy:
Code: Select all
default avatar = 1
image characterPortrait = DynamicImage("character[avatar].jpg" )
label start:
"Your game starts here--"
Code: Select all
menu:
"Choose Character 1":
$ avatar = 1
"Choose Character 2":
$ avatar = 2
"Choose Character 3":
$ avatar = 3
Code: Select all
label start:
"Chose your Avatar!"
menu:
"Choose Character 1":
$ avatar = 1
"Choose Character 2":
$ avatar = 2
"Choose Character 3":
$ avatar = 3
Code: Select all
show characterPortrait
All summed up, teh example would look like this:
Code: Select all
default avatar = 1
image characterPortrait = DynamicImage("character[avatar].jpg" )
label start:
"Chose your Avatar!"
menu:
"Choose Character 1":
$ avatar = 1
"Choose Character 2":
$ avatar = 2
"Choose Character 3":
$ avatar = 3
show characterPortrait
"Hey, thats you!"
Re: How to allow the player to choose their character?
this works perfect! is there a way to do it w/ images? not sure if image maps would to best with that?
https://gutrotz.itch.io/
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
- mitoky
- Veteran
- Posts: 316
- Joined: Sat Feb 07, 2015 9:12 pm
- Projects: The Purring Demon's Love, circus eterie
- Contact:
Re: How to allow the player to choose their character?
When using images i think it would be the best to make a character selection screen instead and call it.
Re: How to allow the player to choose their character?
is there a certain recipe/thread i should look into for that? If not would you recc i start a new thread? or is this something simple enough to answer here?
https://gutrotz.itch.io/
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
Check out my itch.io!
viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!
- mitoky
- Veteran
- Posts: 316
- Joined: Sat Feb 07, 2015 9:12 pm
- Projects: The Purring Demon's Love, circus eterie
- Contact:
Re: How to allow the player to choose their character?
It would be easy to write a code but if you plan to code the game it would be good to get familiar with coding and try it yourself first as this is more bacis ( no scolding, only advice (: )
For what you need look up "renpy documentation" and look into 1.) screens and 2.) buttons (imagebuttons, imagemaps or imagebuttons). And try to write the code yourself first. If it doesnt works, then try to seek for help.
Doing things from scratch rather than someones base helps to learn and understand.
Who is online
Users browsing this forum: No registered users