Page 1 of 1

Variable value not showing in quest text.

Posted: Sat Mar 23, 2024 8:17 am
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"
                
                

Re: Variable value not showing in quest text.

Posted: Sat Mar 23, 2024 9:30 am
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)

Re: Variable value not showing in quest text.

Posted: Sat Mar 23, 2024 2:55 pm
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"