Ren'Py [Solved]Get something from a file if it exists

Jun 28, 2023
15
160
Let's say I want to make a walkthrough file. When I get to a choice in the game I would like to look for the walkthrough and if it exist get the menu and the choices from there, but if it doesn't exist just continu as normal.

Do I have to do like a Try Catch or something?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,141
14,825
Let's say I want to make a walkthrough file. When I get to a choice in the game I would like to look for the walkthrough and if it exist get the menu and the choices from there, but if it doesn't exist just continu as normal.

Do I have to do like a Try Catch or something?
Wow...

You need to hijack the whole process for the menus, with the help of , look at the entries to see if the menu is in the walkthrough, possibly update the said entries, then pass all this to .

Something that would more or less looks like:
Python:
init python:

    def menuWT( items, *args, **kwargs ):

        # Keep only the text to check if this particular menu is in the walkthrough
        choices = [ t for (t, v ) in items ]

        # Search the way you want, return the new menu or None.
        newMenu = isInWalkthrough( choices ):
            items = newMenu

        # Let Ren'Py continue starting there.
        return renpy.display_menu( items, *args, **kwargs )


    store.menu = menuWT
But be aware that items is a tuple with the text of the choice and the action to perform if the choice is selected by the player. Therefore the creation of newMenu will not necessarily be trivial.


This being said, I'm 80% sure that what you want isn't the complex mechanism you talked about, but something that looks like that.
 
  • Like
Reactions: Saki_Sliz
Jun 28, 2023
15
160
I think you see more complex than what I actually mean. Maybe I should have said that it's my own game I just want to separate the walkthrough.

In the game script I have
Python:
menu choice1:
    "Yes.":
        jump choiceYes
    "No.":
        jump choiceNo
And in the walkthrough I have
Python:
menu Choice1_wt:
    "Yes. (Your mom loves you more)":
        jump choiceYes
    "No. (Your mom hates you)":
        jump choiceNo
What I want is in the game script, if the walkthrough exist then jump to Choice1_wt, otherwise continue to Choice1
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,141
14,825
I think you see more complex than what I actually mean.
Have you at least followed the link ?


What I want is in the game script, if the walkthrough exist then jump to Choice1_wt, otherwise continue to Choice1
Oh, so in fact it's the most asked question...

Well, as you word it, the answer is . But as you intent it, the answer is " " ; a small variation of this.
 
  • Like
Reactions: osanaiko