I have quests in my game and I want the player to progress through them step by step. All information about the current step is written in the protagonist's notebook.
I have been playing around with it for a few days now so probably there is some useless code that I left when I came up with new ideas. I thought some of the old code could become useful later. Feel free to erase anything useless.
This is what it looks like now:
Class and list:
Code: Select all
init python:
import renpy.store as store
import renpy.exports as renpy
class QuestC(object):
def __init__(self, ID, name, description, update, active = False, completed = False):
self.ID = ID
self.name = name
self.description = description
self.update = update
self.active = active
self.completed = completed
def StartQuest(self):
if self.active == False:
self.active = True
def UpdateQuest(self):
self.update += 1
Steps = []
Quest = []
q = 0
u = 0
while q < 100:
Quest.append(QuestC(q, "none", "none", u))
q += 1Code: Select all
label quest_list:
$ Quest[0] = QuestC(0, "Apple Hunter", "This stranger asked me to buy him an apple.", 0, False, False)
$ Steps0 = ["I should find a store where they sell apples.", "An apple costs 5 coins. Hopefully, I have enough.", "I bought an apple. Now it is time to deliver it to the stranger."]
returnCode: Select all
screen quest_info():
$ info_quest_name = Quest[index].name
$ info_quest_description = Quest[index].description
$ info_quest_steps = Quest[index].update
vbox:
hbox:
xalign 0.5
text "{size=+12}[info_quest_name]{/size}"
hbox:
text "[info_quest_description]":
justify True
hbox:
text "[info_quest_steps]":
justify TrueCode: Select all
label start:
call quest_list
"Hey, you! Buy me an apple!"
$ Quest[0].StartQuest()
# The protagonist finds and enters the store. He sees the price of an apple.
$ Quest[0].UpdateQuest()
# The protagonist buys an apple.
$ Quest[0].UpdateQuest()
So now with this code, the numbers of progression from self.update += 1 appear in the notebook. Instead of the numbers, I want the text from the list Steps0 to appear. I feel that it is simple to write but I still lack knowledge about lists and classes so I struggle a bit. Could you help me?