I apologize in advance for grammar errors, English isn't my first language.
I've been working on a some basics tools to help me in creating a visual novel, but I have troubles to overcome one difficulty. I'm currently trying to create a python class that would automatically scan and index the images for both backgrounds and characters, but I miss one crucial information. First, I'll explain how my system works, and then expose the problem I'm facing. Don't bother about the python code behind the commands or how to implement them, I'll take care of it.
The Idea.
I've already created three classes for the differents entities I'll be using (code can be found here: http://pastebin.com/qGxAjnxE, but isn't complete nor needed to understand.). The thing to remember here is that I can use the say statement using this form:
Code: Select all
t = NPC("Thierry", "#A46BBD", True)
t.who "My name's [t.name]"Code: Select all
Images
----|Characters
--------|Thierry
-----------|thierry_happy.png
-----------|thierry_sad.png
--------|Hans
----|Backgrounds ...Code: Select all
t = NPC("Thierry", "#A46BBD", True)
t.update_images()The problem.
The problem is that I don't know how to add the images using python code. My first idea was to stock every image linked to an entity for example inside a dictionnary. I could have something like this:
Code: Select all
t_dictionnary = {"happy" = "images/t_happy.png", "sad" = "images/t_sad.png"}Code: Select all
show t.who t.images.happyCode: Select all
FROM:
define t = Character("Thierry", color = "#FABA62", show_two_window=True)
image t angry = "images/characters/thierry/angry_thierry.png"
TO SOMETHING LIKE THIS:
init python:
t = entity_class(Character("Thierry", color = "#FABA62", show_two_window=True))
t.add_image("angry", "images/characters/thierry/angry_thierry.png")