Help making Phoenix Wright style UI

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.
Message
Author
User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Help making Phoenix Wright style UI

#1 Post by Lekkuen »

First of all, Hello everyone.

For my VN I'm wanting to make it so when you approach a character you have to hit a button for either talk, Examine, back, or tasks before you can converse or whatnot with them.

I'm trying to figure out how to make one sort of like the bottom part here

Image

Without the court record and stuff. So any help even if just a push in the right direction would be appreciated
Last edited by Lekkuen on Thu Sep 11, 2014 12:46 pm, edited 1 time in total.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Help making Phoenix Wright style UI

#2 Post by OokamiKasumi »

Lekkuen wrote:...For my NV I'm wanting to make it so when you approach a character you have to hit a button for either talk, Examine, back, or tasks before you can converse or whatnot with them.
Menu choices and jumping to 'labeled' menus would accomplish this. You can also add flags to keep from repeating conversations.

Code: Select all

label Ms_marigold:
    menu marigold_01:
        if t_m01:
            "Talk.": 
                m "You already spoke to me."

        else: 
            "Talk.": 
                $ t_m01 = True
                jump talk_m01

        if ex_m01:
            "examine:"
                 "You already examined this."

        else:
            "Examine.": 
                $ ex_m01 = True
                jump examine_m01
            
        "Tasks":
            jump tasks_list

        "Return":
            pass
Lekkuen wrote:I'm trying to figure out how to make one sort of like the bottom part here ... Without the court record and stuff. So any help even if just a push in the right direction would be appreciated
This is just a matter of changing the location of the buttons, and setting them up to be 2 columns.
-- You would do this in screens.rpy under screen choice.

Code: Select all

screen choice:
    window:
        style "menu_window"       
        #These are what you use to adjust the Position of the buttons. They are currently set to be in the Center. 
        xalign 0.5 #across
        yalign 0.5 #up-down
       
        $i = 0
       
        hbox:
            spacing 2
            vbox:
                style "menu"
                spacing 2
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action: 
                             
                            button:
                                action action
                                style "menu_choice_button"                       
                               
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"
           
            if i % 2 == 0:
                $i = 1
            else:
                $i = 1               
                            
            vbox:
                style "menu"
                spacing 2
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action: 
                             
                            button:
                                action action
                                style "menu_choice_button"                     
                               
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"

screen choice2:
    window: 
        style "menu_window" 
        #These are what you use to adjust the Position of the buttons. They are currently set to be in the Center. 
        xalign 0.5 #across
        yalign 0.5 #up-down


        vbox:
            style "menu"
            spacing 5
            
            for caption, action, chosen in items:
                 
                if action:  
                    
                    button:
                        action action
                        style "menu_choice_button"                        
 
                        text caption style "menu_choice"
                     
                else:
                    text caption style "menu_caption"
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#3 Post by Lekkuen »

First, thanks for being willing to help a nooblet out. ^_^


My first time with all this so things are confusing even with the tutorials for me.


So I would need to put both of those in for it to work?

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Help making Phoenix Wright style UI

#4 Post by OokamiKasumi »

Lekkuen wrote:First, thanks for being willing to help a nooblet out. ^_^
My pleasure. I was once a newbie too.
Lekkuen wrote:My first time with all this so things are confusing even with the tutorials.
Perfectly understandable.
Lekkuen wrote:So I would need to put both of those in for it to work?
Well, you do need to set up a menu of some kind or the buttons won't appear. I just used what you'd posted: talk, Examine, back, and tasks. The flags ($ t_m01 = True) are there to keep from getting the same answer, over and over.

Don't forget! Right after 'start' you'll need to list ALL of the flags used in your game as False before you can switch any of them to True.

Code: Select all

label start:
    $ t_m01 = False
    $ t_m02 = False
    $ ex_m01 = False
    $ ex_m02 = False
As for the second, longer code -- YES. Copy and Replace the whole 'screen choice' code with that code. It's set up to put the menu buttons into two columns. You may need to adjust the yalign to make the buttons appear lower on the screen rather than in the center, but that should be the only thing you need to play with.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#5 Post by Lekkuen »

Alright so I put that stuff in to look at it first before adjusting anything, and get this error

Expected menuitem
if t_m01:

A search said that is normally an indentation error but indenting it more didn't do anything.

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#6 Post by Lekkuen »

So messed around with it more, thinking it's because those labels weren't what was actually used so tried changing them to what was already in the game but still can't figure out what's wrong with the menuitem right there.

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Help making Phoenix Wright style UI

#7 Post by OokamiKasumi »

Lekkuen wrote:So messed around with it more, thinking it's because those labels weren't what was actually used so tried changing them to what was already in the game but still can't figure out what's wrong with the menuitem right there.
Post your code. It'll be easier to see what went wrong.

Something to be aware of:
-- Renpy reads code from Top to Bottom, so if you don't have a jump taking the game elsewhere, it will automatically go to the label Below the last label it read. I keep mistakes from happening by putting most of my labeled menus Somewhere Else in the game, usually a whole other tab / .rpy file, especially for labels I use more than once. This way it won't read and show certain sections of the game until they are actually needed.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#8 Post by Lekkuen »

I'm not home so can't post it for a bit. But I literally copied and pasted yours to look at it and I got error at first if

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#9 Post by Lekkuen »

OK this is the part that gets an error.

Code: Select all

 menu:
        if t_m01:
            "Talk.": 
                m "You already spoke to me."

        else: 
            "Talk.": 
                $ t_m01 = True
                jump talk_m01

        if ex_m01:
            "Examine":
                 "You already examined this."

        else:
            "Examine.": 
                $ ex_m01 = True
                jump examine_m01
            
        "Tasks":
            jump tasks_list

        "Return":
            pass
it says

Code: Select all

File "game/script.rpy", line 26: expected menuitem
    if t_m01:
    ^

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: Help making Phoenix Wright style UI

#10 Post by OokamiKasumi »

Did you remember to list these flags as False right after the 'start' label?

Code: Select all

label start:
    $ t_m01 = False
    $ ex_m01 = False
The fastest way to check if the problem is the flags is by removing them from the menu:

Code: Select all

label Ms_marigold:
    menu:
        "Talk.":
            jump talk_m01

        "Examine.":
            jump examine_m01
           
        "Tasks":
            jump tasks_list

        "Return":
            pass
If it still won't work, try this alternate way to do the same menu:

Edited:

Code: Select all

label Ms_marigold:
    menu marigold_01:
        "Talk." if talk_m01==True:
            m "You already spoke to me."
            jump marigold_01 #This takes you back to this same menu to try again. 

        "Talk." if talk_m01==False:
            $ t_m01 = True
            jump talk_m01

        "examine" if ex_m01==True:
            "You already examined this."
            jump marigold_01

        "Examine." if ex_m01==False:
            $ ex_m01 = True
            jump examine_m01
           
        "Tasks":
            jump tasks_list

        "Return":
            pass
Or this one:

Edited:

Code: Select all

label Ms_marigold:
    menu marigold_01:
        "Talk.":
            if t_m01:
                m "You already spoke to me."
                jump marigold_01 #This takes you back to this same menu. 
            else:
                jump talk_m01

        "Examine.":
            if ex_m01:
                "You already examined this."
                jump marigold_01
            else:
                jump examine_m01
           
        "Tasks":
            jump tasks_list

        "Return":
            pass
Last edited by OokamiKasumi on Sat Sep 27, 2014 5:31 am, edited 2 times in total.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#11 Post by Lekkuen »

Yeah When I removed them it worked fine like you said but I have them listed

Code: Select all

label start:
    $ t_m01 = False
    $ t_m02 = False
    $ ex_m01 = False
    $ ex_m02 = False


So I tried the alternate ones you listed and get this

Code: Select all

File "game/script.rpy", line 29: expected 'name' not found.
    jump menu marigold_01 
        ^

File "game/script.rpy", line 36: expected 'name' not found.
    jump menu marigold_01
        ^
The entire code from that is

Code: Select all

label start:
    $ t_m01 = False
    $ t_m02 = False
    $ ex_m01 = False
    $ ex_m02 = False
    scene bg white
    show Yi at Position(xpos=0.4, ypos=118, xanchor=0, yanchor=0)
    
label Ms_marigold:
    menu marigold_01:
        "Talk." if talk_m01==True:
            m "You already spoke to me."
            jump menu marigold_01 #This takes you back to this same menu to try again. 

        "Talk." if talk_m01==False:
            $ t_m01 = True
            jump talk_m01

        "examine" if ex_m01==True:
            "You already examined this."
            jump menu marigold_01

        "Examine." if if ex_m01==False:
            $ ex_m01 = True
            jump examine_m01
           
        "Tasks":
            jump tasks_list

        "Return":
            pass
I don't really get it as when I remove the ifs altogether it has no problem making the menu yet says the menu name is the problem

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#12 Post by Lekkuen »

Also I managed to get the menu low enough for my liking but I can't see any way to move the text over.

Code: Select all

screen choice:
    window:
        style "menu_window"       
        #These are what you use to adjust the Position of the buttons. They are currently set to be in the Center. 
        xalign 0.5 #across
        yalign 1.0 #up-down
       
        $i = 0
       
        hbox:
            spacing 20
            vbox:
                style "menu"
                spacing 10
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action: 
                             
                            button:
                                action action
                                style "menu_choice_button"                       
                               
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"
           
            if i % 2 == 0:
                $i = 1
            else:
                $i = 1               
                            
            vbox:
                style "menu"
                spacing 10
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action: 
                             
                            button:
                                action action
                                style "menu_choice_button"                     
                               
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"

screen choice2:
    window: 
        style "menu_window" 
        #These are what you use to adjust the Position of the buttons. They are currently set to be in the Center. 
        xalign 0.5 #across
        yalign 1.0 #up-down


        vbox:
            style "menu"
            spacing 20
            
            for caption, action, chosen in items:
                 
                if action:  
                    
                    button:
                        action action
                        style "menu_choice_button"                        
 
                        text caption style "menu_choice"
                     
                else:
                    text caption style "menu_caption"
By messing with spacing I've managed to space them apart but is there anyway to move the whole block over so that the words are based in the center of the menu box instead of the end.

User avatar
meiri
Regular
Posts: 177
Joined: Wed Jun 25, 2014 6:21 pm
Projects: Tutor Tabitha, Movement
Organization: Blue Bottlecap Games
Location: East Coast, US
Contact:

Re: Help making Phoenix Wright style UI

#13 Post by meiri »

I would try this code:
*Ps, the init -2: section at the bottom turns the buttons into textbutton-like buttons rather than hyperlink-like buttons, but that can simply be commented out.

Code: Select all

screen choice:
    window:
        style "menu_window"       
        #These are what you use to adjust the Position of the buttons. They are currently set to be in the Center. 
        xalign 0.5 #across
        yalign 0.5 #up-down
       
        $i = 0
       
        hbox:
            xalign 0.5
            yalign 0.5
            spacing 50
            vbox:
                style "menu"
                spacing 50
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action: 
                             
                            button:
                                action action
                                style "menu_choice_button"                       
                               
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"
           
            if i % 2 == 0:
                $i = 1
            else:
                $i = 1               
                            
            vbox:
                xalign 0.5
                yalign 0.5
                style "menu"
                spacing 50
                 
                for caption, action, chosen in items:
                    $i += 1
                    if i % 2 == 1:
                        if action: 
                             
                            button:
                                action action
                                style "menu_choice_button"                     
                               
                                text caption style "menu_choice"
                             
                        else:
                            text caption style "menu_caption"

init -2:
    $ config.narrator_menu = True

#    style menu_window is default

    style menu_choice is button_text:
        clear

    style menu_choice_button is button:
        xminimum int(config.screen_width * 0.2)
        xmaximum int(config.screen_width * 0.2)
What's in a loop? A loop iterated in any other way would output as sweet.
--
Have a look at my GxG kinetic novel, Movement, if you have the chance?

User avatar
Lekkuen
Regular
Posts: 48
Joined: Wed Sep 10, 2014 7:03 pm
Contact:

Re: Help making Phoenix Wright style UI

#14 Post by Lekkuen »

Thanks! That got the menu how I wanted.



Though I still can't figure out my problem with the If/Else part of the codes in script

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Help making Phoenix Wright style UI

#15 Post by Kia »

I saw this as taught: how nostalgic! let's steal this and use it so I made a fast paste prototype of it (see attached file):
to use it just unzip it to your game folder and use "call charOpt" to call it.
it has some problem in returning where it should and since I never used "Jump" in screen code and can't spend more than 10 min on it right now you have to ask others for help on it. ^_^
Attachments
ui.rar
(4.56 KiB) Downloaded 78 times

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]