Making user to decided two characters ?

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
nixrlz
Newbie
Posts: 5
Joined: Sun Aug 13, 2017 11:50 am
Contact:

Making user to decided two characters ?

#1 Post by nixrlz »

i've been trying to make a VN where the user can decided which character they want to play and to let them choose , i decided to make a branch button so they can choose it base on the image i display in the screen.
the problem is what is the python code for that? i've been looking for tutorial but non able to solve my problem so far.
i cant make an image as a choices button and to make the script remember the characther that the user choose. please help with example code so i can understand . thankyou !

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Making user to decided two characters ?

#2 Post by Milkymalk »

So basically you want two buttons that set a variable when clicked or branch off to a different path. You don't need (much) python, you need screen language instead.
https://www.renpy.org/doc/html/screens.html
Keywords that will be useful are Frame, Hbox, Vbox and Imagebutton (and the actions SetVariable and Jump from here: https://www.renpy.org/doc/html/screen_actions.html).
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Sarchalen
Regular
Posts: 29
Joined: Tue Aug 08, 2017 5:23 pm
Projects: Sugawara Chronicle
Contact:

Re: Making user to decided two characters ?

#3 Post by Sarchalen »

Pretty much what he said ^ Theres a few ways to do it but the easiest is probably to set it up like a menu, though with a different screen than your usual menus that displays your "character picker" Essentially it's just a menu that looks a little different. You can use your button to set a variable, you've just got to make sure to do a check to make sure only one button can be enabled at a time. You don't want some weird bug popping up if someone were to press both buttons.

nixrlz
Newbie
Posts: 5
Joined: Sun Aug 13, 2017 11:50 am
Contact:

Re: Making user to decided two characters ?

#4 Post by nixrlz »

but how to make the system to remember the choice we choose , like if there is a 2 choice between mc1 and mc2 , how to make them remember as one 1 variable?

User avatar
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: Making user to decided two characters ?

#5 Post by Remix »

Very basic example...

Code: Select all

define g = Character("Girl")
define b = Character("Boy")

label start:
    "Words"
    menu:
        "Girl":
            $ player = Character(kind=g)
        "Boy":
            $ player = Character(kind=b)
    player "Words said by chosen type"
I am not too sure how that handles images though, whether 'show player happy' would effectively look for 'g happy' or 'b happy' (to cut down on repeated code) -
Maybe test it with different image='img_tag' parameters in the defines...
If it works ok with a menu as above, just tweak it to use imagebuttons
Frameworks & Scriptlets:

nixrlz
Newbie
Posts: 5
Joined: Sun Aug 13, 2017 11:50 am
Contact:

Re: Making user to decided two characters ?

#6 Post by nixrlz »

Remix wrote: Fri Aug 18, 2017 1:30 pm Very basic example...

Code: Select all

define g = Character("Girl")
define b = Character("Boy")

label start:
    "Words"
    menu:
        "Girl":
            $ player = Character(kind=g)
        "Boy":
            $ player = Character(kind=b)
    player "Words said by chosen type"
I am not too sure how that handles images though, whether 'show player happy' would effectively look for 'g happy' or 'b happy' (to cut down on repeated code) -
Maybe test it with different image='img_tag' parameters in the defines...
If it works ok with a menu as above, just tweak it to use imagebuttons
yes i use that to determine the character but my problem remain unsolved
the question is How do I link user choice to two variable ?
FOR EXAMPLE :

$ USERCHOICE = "X" OR "Y"

X = IMAGE_CHARACTER1

Y= IMAGE_CHARACTER2

the chosen X or Y become 1 variable = image CHOOSENCHARATER

so i can just type

show image CHOOSENCHARACTER

and the shown image will depend on user choice(whether it's X or Y)

User avatar
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: Making user to decided two characters ?

#7 Post by Remix »

It seems to work fine using string interpolation in the image name = "" bits...

Code: Select all

define g = Character("Girl")
define b = Character("Boy")

default image_tag = "girl"
image player happy = "images/[image_tag]_happy.png"

label start:
    "Words"
    menu:
        "Girl":
            $ player = Character(kind=g)
        "Boy":
            $ player, image_tag = Character(kind=b), "boy"
    player "Words said by chosen type"
    # shows images/boy_happy.png for choice 'boy' else girl_happy.png
    show player happy at truecenter
    "words"
Other than the imagebuttons question, does that cover your needs?

imagebutton .... action [ SetVariable( player, Character(kind=g) ), SetVariable( image_tag, "girl" ) ] should/might steer you on your way
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Google [Bot]