I'm back from being away and trying to get Layered Images to work for me. PyTom recommended I use attribute_function to solve my conundrum...but I don't seem to be able to get it to work. Perhaps some of you all can figure out how I need to write this code?
Problem: Given separate eyes, brows, and mouth images. Supplying the happy attribute, would return happy eyes, happy brows, and happy mouth. But what to do if you want a different combination of eyes, brows, and mouth images.
So given these images:
rex_base
rex_pants_long
rex_pants_short
rex_shirt
rex_eyebrow_neutral
rex_eyebrow_angry
rex_eyebrow_happy
rex_eyebrow_sad
rex_eye_neutral
rex_eye_angry
rex_eye_happy
rex_eye_sad
rex_mouth_neutral
rex_mouth_angry
rex_mouth_happy
rex_mouth_sad
Say you want the following emotions:
happy: eyebrow_happy, eye_happy, mouth_happy
angry: eyebrow_angry, eye_angry, mouth_angry
sad: eyebrow_sad, eye_sad, mouth_sad
manic: eyebrow_angry, eye_angry, mouth_happy
wistful: eyebrow_sad, eye_sad, mouth_happy
Okay...so how to do this with the attribute_function?
Looking at the random picker from the Patreon tutorial, I've tried this:
Code: Select all
define r = Character("Rex", image="rex")
init python:
class Picker(object):
def __init__(self, options):
self.options = [ i.split() for i in options ]
def __call__(self, attributes):
rv = set(attributes)
choices = [ ]
for i in self.options:
if i[0] in attributes:
rv.add(i[1:])
return rv
layeredimage rex:
attribute_function Picker([
"manicE eyebrow_angry eye_angry mouth_happy",
"wistfulE eyebrow_sad eye_sad mouth_happy"
])
always "rex_base"
group pants auto:
attribute long default
always "rex_shirt"
group eyebrow auto:
attribute neutral default
group eye auto:
attribute neutral default
group mouth auto:
attribute neutral default
group hand auto:
attribute neutral default
label start:
scene black
show rex
r "This is Rex."
r sad "This sad works."
r happy "This happy works."
r angry "This angry works."
r manicE "This manic doesn't work."
Any help would be appreciated! If we can figure this out, I think this would be useful to everyone who is using separate eyes, brows, and mouth images.
Note: I get an error Unhashable type: list--perhaps that will help with the troubleshooting!