Quest System Screen Problem

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
User avatar
TanyaThe
Newbie
Posts: 2
Joined: Sat Aug 06, 2022 2:25 pm
Contact:

Quest System Screen Problem

#1 Post by TanyaThe »

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
Start Label
(1.32 MiB) Not downloaded yet
Quest's label ->
screenshot0001.png
Quest's label
(1.32 MiB) Not downloaded yet
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: Select all

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)
Maybe nothing in this life happens by accident. As everything happens for a reason, our destiny slowly takes form...

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: Quest System Screen Problem

#2 Post by jeffster »

The jump itself seems to be alright:

Code: Select all

textbutton "Start Quest" action [SetVariable('current_quest', (None, None)), Jump(current_quest_details['label'])]
It's hard to debug the problem without the actual label/screen where the quest was started.
The problem is likely there somewhere.
Could you maybe post a minimal example of the functional game?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Quest System Screen Problem

#3 Post by Ocelot »

Is, by any chance, your quest overview screen a part of the game menu (the one you get when you press ESC)?
< < insert Rick Cook quote here > >

User avatar
plastiekk
Regular
Posts: 112
Joined: Wed Sep 29, 2021 4:08 am
Contact:

Re: Quest System Screen Problem

#4 Post by plastiekk »

TanyaThe wrote: Mon Mar 25, 2024 1:31 pm ...
Hard to say if you don't show the label like jeffster mentioned before but as a suggestion: Your function check_quest_status() does not contain a return, so it's possible that the next function under it will be executed too. I got some weird result by forgetting to insert a return in renpy-python functions. Just a guess, though.
P.S: does a break in screen-language work? I remember it didn't work in labels to leave a while loop, you need to jump out of it.
Why on earth did I put the bread in the fridge?

User avatar
TanyaThe
Newbie
Posts: 2
Joined: Sat Aug 06, 2022 2:25 pm
Contact:

Re: Quest System Screen Problem

#5 Post by TanyaThe »

Sorry for late response, got little to nothing of time to spend on this. Here is code for script.rpy ->

Code: Select all

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: Select all

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: Select all

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"
            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 :lol:
Ocelot wrote: Tue Mar 26, 2024 3:17 am Is, by any chance, your quest overview screen a part of the game menu (the one you get when you press ESC)?
As for this question -> Nope, it is not.

Thank you everyone for your time and responses.
Maybe nothing in this life happens by accident. As everything happens for a reason, our destiny slowly takes form...

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Quest System Screen Problem

#6 Post by Ocelot »

TanyaThe wrote: Sat Mar 30, 2024 11:44 am As for this question -> Nope, it is not.
Well... Actually it is, just not in the way I thought. ShowMenu shows screen in the menu context, while that screen is shown, you are not in the main game, and jumping from there will not affect main game flow. As soon as you finish showing screen or return from label while in menu context, you return from where you have entered menu.
ShowMenu(screen=_game_menu_screen, *args, _transition=config.intra_transition, **kwargs)
Causes us to enter the game menu, if we're not there already. If we are in the game menu, then this shows a screen or jumps to a label.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot], henne