Some time ago, I managed to make my Creature objects "pretend" to be characters when used in say statements (this post mostly summarizes it: http://lemmasoft.renai.us/forums/viewto ... 097#p57552). This way I use the same objects (and hence the same variables) to track in-game info and for say statements.
Now I want to go one step further and reuse those creature objects for my Show statements. Each Creature object has enough information to retrieve the actual displayable to show, depending on different fields, so I came up with something like this:
Code: Select all
init python:
class Creature(renpy.Displayable):
# I'm omitting a lot of stuff here
def render(self, width, height, st, at):
return sprites[self.spriteKey][self.mood].render(width, height, st, at)
def event(self, ev, x, y, st):
return sprites[self.spriteKey][self.mood].event(ev, x, y, st)
def visit(self):
return [ sprites[self.spriteKey][self.mood] ]
Creature objects are meant to be saved; they are all created after the init phase; and their fields change quite often.
The actual "selection" logics are a bit deeper than taking the creature's mood, but the idea is essentially the same.
The goal is to be able to have code like this:
Code: Select all
show priest at right
priest "Welcome to the Temple."