Ren'Py Quest System Screen Problem

TanyaThe

New Member
Jan 8, 2018
7
4
Hello, I've been trying to get the following code for quest system + screen working correctly, but there is this one problem -> When I "jump" into the label inside of the script.rpy in "label start" it's not problem at all. When I "jump" into the label using the quests logic, when starting quests it jumps to the correct label, text is also correct, the file itself reads just fine. BUT the problem is when I try to enter main menu while on any quest. It returns me to the label/screen that I've started the quest on. Even the quick-menu disappears when I'm in quest's label, as you can see on the screenshots.
Start label -> screenshot0002.png
Quest's label -> screenshot0001.png

I don't really know why is that happening, that's why I'm asking here on forum. I would really appreciate every help and suggestions anyone would have.
Code is here ->

Code:
default quest_info = {
    "Alice": [
        {"id": "1", "title": "Find the Lost Book", "status": "available", "locked": False, "label": "quest_alice_1", "description": "Alice's favorite book is missing. \n Help her find it in the library."},
        # More quests for Alice
    ],
    "Bob": [
        {"id": "1", "title": "Gather Herbs", "status": "available", "locked": False, "label": "quest_bob_1", "description": "Bob needs herbs for his potion. \n Collect them in the forest."},
        # More quests for Bob
    ],
    "Alexa": [
        {"id": "1", "title": "Help her", "status": "available", "locked": False, "label": "quest_alexa_1", "description": "Alexa needs help, go to her."},
        # More quests for Alexa
    ],
    # Additional characters and their quests
}


default current_quest = (None, None)  

screen quest_overview():
    zorder 100
    modal True

    frame:
        xalign 0.5 yalign 0.5
        xsize 1600
        ysize 900

    hbox:
        xpos 0.10
        ypos 0.2
        spacing 350

        vbox:
            spacing 25
            for char_name, quests in quest_info.items():
                for quest in quests:
                    if quest['status'] == "available" and not quest['locked']:
                        textbutton f"{char_name}: {quest['title']}" action [SetVariable('current_quest', (char_name, quest['id'])), Show("quest_overview")]
        vbox id "quest_details":
            $ current_quest_details = None
            $ char_name, quest_id = current_quest if current_quest else (None, None)
            if char_name and quest_id:
                for name, quests in quest_info.items():
                    if name == char_name:
                        for quest in quests:
                            if quest['id'] == quest_id:
                                $ current_quest_details = quest
                                break
                        if current_quest_details:
                            break

            if current_quest_details:
                text f"Character: {char_name}"
                text f"Quest: {current_quest_details['title']}"
                text "Description: {}".format(current_quest_details.get('description', 'No description available.'))
                textbutton "Start Quest" action [SetVariable('current_quest', (None, None)), Jump(current_quest_details['label'])]
            else:
                text "Select a quest to view details."

    vbox:
        xalign 0.90 yalign 0.108
        textbutton "Close":
            idle_background Frame("images/UI/button glossy idle.png", 12, 12)
            hover_background Frame("images/UI/button glossy hover.png", 12, 12)
            action [SetVariable('current_quest', (None, None)), Return()]



init python:

    def check_quest_status():
        completed_quests = []
        active_quests = []
        available_quests = []
        for char, quests in quest_info.items():
            for quest in quests:
                if quest["status"] == "completed":
                    completed_quests.append(quest["title"])
                elif quest["status"] == "active":
                    active_quests.append(quest["title"])
                elif quest["status"] == "available":
                    available_quests.append(quest["title"])
        # Check quests status in console
        print("Completed Quests:", completed_quests)
        print("Active Quests:", active_quests)
        print("Available Quests:", available_quests)
 

Hysocs

Newbie
Mar 5, 2024
17
8
For the quick menu disappearing, I don't see anything tbh, unless
Python:
Modal True
is causing it, but I doubt it. From my understanding, it's hard to hide the quick menu as nothing covers it. The only way I know to remove it is
Python:
 $ renpy.hide_quick_menu()
Also, from my experience, don't use Return() for closing (Its like a rewind and not a go back button); it's the cause of a lot of problems and might be causing yours. Instead, hide the screen with the close button or set a var via it and have the screen only show when the var is true (Also you are setting current quest to none at close and on quest start meaning if something is going to check what quest you are on its gona be none if you close the menu)

if its not that try looking at this line
Python:
textbutton "Start Quest" action [SetVariable('current_quest', (None, None)), Jump(current_quest_details['label'])]
other than that i would need to see more code, or maybe I'm missing it. The structure of the code is weird.

Throw it into ChatGPT and see what it says, though it kinda looks like this might be due to it. Sorry if I'm wrong.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,130
14,809
BUT the problem is when I try to enter main menu while on any quest. It returns me to the label/screen that I've started the quest on. Even the quick-menu disappears when I'm in quest's label,
Both are generally the sign of a context level issue.
With the symptoms you describe, I'm tempted to say that the Jump is done in the main menu context. Therefore, how do you call the "quest_overview" screen ?



For the quick menu disappearing, I don't see anything tbh, unless
Python:
Modal True
is causing it, but I doubt it.
It can't cause this. The modal screen property prevent the propagation of clicks, it don't change what will be displayed.


From my understanding, it's hard to hide the quick menu as nothing covers it.
It's relatively easy.
As you said, there's a function for this, as well as a configuration variable. There's all the ways to hide the overlays or to stop them, temporarily or defintively, to be displayed. And of course there's the direct edition of the config.overlay_screens list, and the direct hiding of the screen itself.

But I highly doubt that it's what happen here ; it looks like Ren'Py consider that the quick menu should not be displayed, not that it is hidden.


Also, from my experience, don't use Return() for closing (Its like a rewind and not a go back button); it's the cause of a lot of problems and might be causing yours.
:WaitWhat: Of course that Return() is a go back button...
It's what its name say, it's what the instruction do in all language, and, not surprisingly, it's what the screen action do. And it happen that it's precisely how one should close a called screen.


Instead, hide the screen with the close button or set a var via it and have the screen only show when the var is true [...]
It wasn't the right day to run out of aspirin...


The structure of the code is weird.
:WaitWhat: It's one of the most rational code I've seen in thread opening since a long time.


Please post more code, specifically where you are calling / showing the screen quest_overview
And my faith in humanity rise again.
 

TanyaThe

New Member
Jan 8, 2018
7
4
Sorry for late response, got little to nothing of time to spend on this. Here is code for script.rpy ->

Code:
image bg MCHome = "images/background/PlayerHomeM_Morning1.png"
# Defining the characters names.
define mc = Character("[MCname]")
define al = Character(_("Alice"), color="#c8ffc8")

label start:
    #Locking the quests that I don't want to be available since start of the game.
    $ quest_info["Bob"][0]["status"] = "locked"
    $ quest_info["Alexa"][0]["status"] = "locked"
    #Giving a choice for player to name his character.
    python:
        MCname = renpy.input("What is your name?")
        MCname = MCname.strip()
        #Default name if player dont want unique one.
        if not MCname:
            MCname = "Kazuya"
    #Showing HUD screen
    show screen persistent_hud
    scene bg MCHome
    "Welcome to the game!"
    #Changing Alices variable "met" to True.
    $ character_info["Alice"]["met"] = True
    $ renpy.notify("You've met Alice")

    mc "Welcome to the game!1"

    "Welcome to the game!2"

    "Welcome to the game!3"

    "Welcome to the game!4"
as for the Alices quest I have this code here ->

Code:
label quest_alice_1:
    show screen persistent_hud
   
    al "[MCname], I need your help to find a lost book that is very dear to me."
    "Will you help Alice find her book?"
    # Giving the player a choice to continue with the selected quest or to return back.
    menu:
        "Yes, I'll help you.":
            # Actions to mark the quest as active and proceed
            $ quest_info["Alice"][0]["status"] = "active"
            mc "You have my word, Alice. Let's find that book."
            jump quest_alice_1_progress

        "I'm sorry, I can't right now.":
            al "I understand, maybe another time."
            return

label quest_alice_1_progress:
    # Progress through the Alices quest.

    show screen persistent_hud
    "You and Alice spend hours searching for the book..."
    # Mark the quest as completed
    $ quest_info["Alice"][0]["status"] = "completed"
    "Finally, you find the book tucked away in an old chest."
    # Marking other quests as available
    $ quest_info["Bob"][0]["status"] = "available"
    $ quest_info["Alexa"][0]["status"] = "available"
    return
For the HUD I have this simple textbutton ->

Code:
screen persistent_hud():
    frame:
        background "#000000"  # Bar background color
        hbox:
            spacing 10  # Space between buttons
            # Define each button within this hbox
            textbutton "Relationships" action ShowMenu("character_overview"):
                text_color "#ff0000"
                hover_background "#051df7"
            textbutton "Stats" action ShowMenu("stats_screen"):
                text_color "#ff0000"
                hover_background "#051df7"
                # Add more buttons as needed
            textbutton "Quests" action ShowMenu("quest_overview"):
                text_color "#ff0000"
                hover_background "#051df7"
I think the problem is with how I don't have some kind of loop for maingame and I'm accessing the screens straight from the default screen with text box not hidden, but really don't know, am no specialist :D I appreciate all of the responses and again sorry for the late reply.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,130
14,809
Code:
label quest_alice_1:
    show screen persistent_hud
[...]
label quest_alice_1_progress:
    # Progress through the Alices quest.

    show screen persistent_hud
You don't have to show the screen every single time. Shown screen will continue to be shown until explicitly hidden.


Code:
[code]screen persistent_hud():
[...]
            textbutton "Relationships" action ShowMenu("character_overview"):
[...]
            textbutton "Stats" action ShowMenu("stats_screen"):
[...]
            textbutton "Quests" action ShowMenu("quest_overview"):
[...]
So it's what I was hinting to. The screens are at a different context level, what mess everything.
Replace ShowMenu by Show and your code will be fixed.
 
  • Like
Reactions: gojira667