I'm trying to find a simular functionality to the renpy.show() method for displaying (multiple) images on a layer.
From what I understand renpy will scan my images folder and with the filenames it finds I can display my images.
For reasons I won't get into I need the same functionality with a path instead of solely a filename.
for example.
if my images folder contains the following file: images/npcs/sam/body.png
I would currently do renpy.show(body).
But what I need is for the same functionality with class.method('images/npcs/sam/body.png')
Below is an example how the code would operate.
Code: Select all
label test:
"an empty room"
$ NPC.Show("sam")
"sam entered the room"
return
Code: Select all
class NPC(object):
@staticmethod
def Show(name):
npc = world.GetNpc(name)
renpy.show(npc.path) # npc.path contains the string 'images/npcs/sam/body.png'
return
Anything would be appreciated.
thanks in advance!
EDIT:
A current route I am exploring is creating images in code and excluding the 'images/npcs' directory from being scanned for images.
This seems to work until I try to create the images inside my buildWorld() function where the following error is thrown
Exception: Images may only be declared inside init blocks
Code: Select all
init python:
renpy.image("images/npcs/sam/body.png", Image("images/npcs/sam/body.png")) <- Works
class World(object):
def __init__(self):
self.npcsPath = "images/npcs"
self.npcs = []
def BuildWorld(self):
renpy.image("images/npcs/sam/body.png", Image("images/npcs/sam/body.png")) <- Exception thrown
EDIT EDIT:
I was being a little dumb dumb. I may have had my World class inside a init python block, but the code instantiating my world and calling the BuildWorld class were in a regular python block
So I changed
Code: Select all
label preloopinit:
python:
world = World()
world.BuildWorld()
return
Code: Select all
label preloopinit:
init python:
world = World()
world.BuildWorld()
return
Now I only need to exclude the images/npcs folder from being automatically converted to Images to get rid of the duplicates.