Variable value not showing in quest text.

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
Swinwappy
Newbie
Posts: 14
Joined: Mon Jun 01, 2020 3:52 am
Contact:

Variable value not showing in quest text.

#1 Post by Swinwappy »

Hey guys,

I have a quest system and quest hud/screen in my game.

The quest code seems to be working fine, except when I open up the quest log, a name variable E.G. [ml] would show up as [ml] and not as their name/value. Everything else works, but adding variables in the text doesn't seem to work.

Does anyone know why this might be?

Cheers.




Example of quest system

Code: Select all

    import renpy.store as store
    import renpy.exports as renpy



    class Quest (store.object):
        def __init__(self, name, desc, available = False, started = False, completed = False):
            self.name = name
            self.desc = desc
            self.available = available
            self.started = started
            self.completed = completed





    class QuestList (store.object):
        def __init__(self):
            self.quest_list = []


        def addQuest(self, quest):
            self.quest_list.append(quest)


        def removeQuest(self, quest):
            self.quest_list.remove(quest)



default quest_whats_up_with_mom = Quest("Talk to mom", "[ml] been upset lately. Maybe we should watch a movie in the evening?", True)

Questlog Screen

Code: Select all


screen questlog:
    image "hud/notepad.png"
    vbox: #quest text on notepad
        xpos .51 ypos .1 xmaximum 550
        for quest in my_quest.quest_list:
            if not(quest.completed) and quest.available:
                text "{color=#212121}[quest.name]{/color}" style "questheadertext"
                text "{color=#212121}[quest.desc]{/color}" style "questbodytext"
                
                

Swinwappy
Newbie
Posts: 14
Joined: Mon Jun 01, 2020 3:52 am
Contact:

Re: Variable value not showing in quest text.

#2 Post by Swinwappy »

fixed it by using this instead:

default quest_whats_up_with_mom = Quest("Talk to mom", "% been upset lately. Maybe we should watch a movie in the evening?" % ml, True)

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Variable value not showing in quest text.

#3 Post by m_from_space »

Swinwappy wrote: Sat Mar 23, 2024 9:30 am fixed it by using this instead:

default quest_whats_up_with_mom = Quest("Talk to mom", "% been upset lately. Maybe we should watch a movie in the evening?" % ml, True)
Another way this can be fixed is to tell Renpy that it should interpolate the contents of a variable (again) by adding the "!i" statement. This is especially useful since the content of "ml" might change during runtime and your "fix" wouldn't update the text.

Code: Select all

text "{color=#212121}[quest.desc!i]{/color}" style "questbodytext"

Post Reply

Who is online

Users browsing this forum: Sirifys-Al