Code: Select all
init python:
import renpy.store as store
import renpy.exports as renpy
class Chara(store.object):
def __init__(self, name, pronouns, description, meet = False):
#imageName = "",
self.name = name
self.pronouns = pronouns
self.description = description
#self.imageName = "characters/"+ imageName + ".png"
self.meet = meet
Code: Select all
class CharaList(store.object):
def __init__(self):
self.chara_list = []
def metChara(self, chara):
self.chara_list.append(chara)
def removeChara(self, chara):
self.chara_list.remove(chara)
def hasChara(self, chara):
if chara in self.chara_list:
return True
else:
return False
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00gamemenu.rpy", line 173, in script
$ ui.interact()
File "renpy/common/00gamemenu.rpy", line 173, in <module>
$ ui.interact()
File "game/characters_screen.rpy", line 10, in execute
screen CharactersUI:
File "game/characters_screen.rpy", line 10, in execute
screen CharactersUI:
File "game/characters_screen.rpy", line 13, in execute
hbox:
File "game/characters_screen.rpy", line 14, in execute
frame:
File "game/characters_screen.rpy", line 18, in execute
vbox:
File "game/characters_screen.rpy", line 24, in execute
if CharaList.hasChara(Bug):
File "game/characters_screen.rpy", line 24, in <module>
if CharaList.hasChara(Bug):
TypeError: unbound method hasChara() must be called with CharaList instance as first argument (got Chara instance instead)
Code: Select all
screen charactersButton:
textbutton _("characters"):
xalign 1.0
yalign 0.0
xoffset -30
yoffset 30
action ShowMenu("CharactersUI")
#character screen goes here
screen CharactersUI:
tag charactersUI
add "UI/moon.png"
hbox:
frame:
style_prefix "characters"
ysize 1080
xsize 640
vbox:
xalign 0.5
yalign 0.5
textbutton _(Player.name):
action SetVariable("selectedCharacter", Player)
xsize 640
if CharaList.hasChara(Bug):
textbutton _(Bug.name):
action SetVariable("selectedCharacter", Bug)
xsize 640
textbutton _("Return"):
yalign 0.5
yoffset 90
xoffset 20
action Return()
## Right frame
## Notice that we're using selectedCharacter to show the variables here.
frame:
ysize 1080
xsize 1280
vbox:
xoffset 20
yoffset 20
text "Name: [selectedCharacter.name]"
text "Pronouns: [selectedCharacter.pronouns]"
text "Description: [selectedCharacter.description]"