What am I doing wrong when trying to organize 'asset' folders? Will 'config.searchpath' help?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Bishima
Newbie
Posts: 10
Joined: Fri Nov 29, 2019 10:45 am
Contact:

What am I doing wrong when trying to organize 'asset' folders? Will 'config.searchpath' help?

#1 Post by Bishima »

Hello,

This has been driving me a bit mad and I'm not sure what the issue is. I wanted to clean up my 'game' folder by organizing all my assets into sub-folders (images/sprites, audio/music, fonts, ect). My game was working fine before but I thought this would be easier to manage and look nicer as the assets are really starting to pile up. I have no idea what I am doing wrong but my attempts to organize the files seems to have broken my entire game and I wonder if I should just go back to being disorganized but functional.

I've looked at multiple tutorials and thought I had figured it out. What is driving me mad is that the game seems to be picking and choosing when it works and when it doesn't work.

For example, I organized the 'image' folder into subfolders 'sprites' and 'bgs.' At first this didn't work at all and Renpy couldn't find any of the images, but I heard this was something built ready-made into the program. Then bam, randomly it started working and it was loading sprites and bgs just fine without me having to do anything extra. Then suddenly it decided it no longer wanted to find certain bgs to the point it wouldn't load anything. (Like I would try and skip past the scene it was failing to load since I was troubleshooting something else but it wouldn't even let me go to a different scene that didn't use the image).

This particular bg is attached to an animation so I wondered if that was why? But then I don't understand why Renpy can't find the file as normal since it's called in the same way either way.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While loading <'Image' 'Hall Lab Close.jpg'>:
  File "game/d route.rpy", line 548, in script
    show mal with hpunch
IOError: Couldn't find file 'Hall Lab Close.jpg'.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/d route.rpy", line 548, in script
    show mal with hpunch
  File "/Applications/renpy-7.3.5-sdk/renpy/ast.py", line 1389, in execute
    renpy.exports.with_statement(trans, paired)
  File "/Applications/renpy-7.3.5-sdk/renpy/exports.py", line 1601, in with_statement
    return renpy.game.interface.do_with(trans, paired, clear=clear)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 2251, in do_with
    clear=clear)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 2702, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 3194, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 2094, in draw_screen
    renpy.config.screen_height,
  File "renpy/display/render.pyx", line 490, in renpy.display.render.render_screen (gen/renpy.display.render.c:6805)
    rv = render(root, width, height, st, st)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/motion.py", line 179, in render
    child = render(self.child, width, height, st, at)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "accelerator.pyx", line 110, in renpy.display.accelerator.transform_render
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/image.py", line 500, in render
    return wrap_render(self.target, width, height, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/image.py", line 306, in wrap_render
    rend = render(child, w, h, st, at)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "accelerator.pyx", line 110, in renpy.display.accelerator.transform_render
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/im.py", line 583, in render
    return cache.get(self, render=True)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/im.py", line 266, in get
    surf = image.load()
  File "/Applications/renpy-7.3.5-sdk/renpy/display/im.py", line 628, in load
    surf = renpy.display.pgrender.load_image(renpy.loader.load(self.filename), self.filename)
  File "/Applications/renpy-7.3.5-sdk/renpy/loader.py", line 576, in load
    raise IOError("Couldn't find file '%s'." % name)
IOError: Couldn't find file 'Hall Lab Close.jpg'.

Darwin-17.7.0-x86_64-i386-64bit
Ren'Py 7.3.5.606
Perchance to Dream 1.0
Fri Aug 12 08:25:37 2022
Another maddening example is my quest to add a 'fonts' folder which is going miserably. While it seems to work fine for GUI fonts as I can merely set it like so:

Code: Select all

define gui.name_text_font = "fonts/whitrabt.ttf"
And it works fine, the issues begin since I have certain characters who use special fonts at specific times.

Code: Select all

define fema = Character("Fema", color="779ed1", what_slow_cps=80, what_font="fonts/Hhenum-Regular.otf")

Code: Select all

n "{font=fonts/LongCang-Regular.ttf}{b}Why didn't you?{/b}{/font}"
Again, this becomes an issue with Renpy sometimes reading the fonts properly, and sometimes literally closing out the game since it can't read the fonts. It seems to be especially picky when I change font mid-line:

Code: Select all

fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
Results in:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/d route.rpy", line 594, in script
    fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
Exception: Could not find font u'whitrabt.ttf'.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/d route.rpy", line 594, in script
    fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
  File "/Applications/renpy-7.3.5-sdk/renpy/ast.py", line 708, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "/Applications/renpy-7.3.5-sdk/renpy/exports.py", line 1345, in say
    who(what, *args, **kwargs)
  File "/Applications/renpy-7.3.5-sdk/renpy/character.py", line 1142, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "/Applications/renpy-7.3.5-sdk/renpy/character.py", line 842, in do_display
    **display_args)
  File "/Applications/renpy-7.3.5-sdk/renpy/character.py", line 591, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "/Applications/renpy-7.3.5-sdk/renpy/ui.py", line 297, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 2702, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 3194, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/core.py", line 2094, in draw_screen
    renpy.config.screen_height,
  File "renpy/display/render.pyx", line 490, in renpy.display.render.render_screen (gen/renpy.display.render.c:6805)
    rv = render(root, width, height, st, st)
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/screen.py", line 675, in render
    child = renpy.display.render.render(self.child, w, h, st, at)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 1127, in render
    st, at)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/display/layout.py", line 722, in render
    surf = render(child, width, height, cst, cat)
  File "renpy/display/render.pyx", line 166, in renpy.display.render.render (gen/renpy.display.render.c:4075)
    cpdef render(d, object widtho, object heighto, double st, double at):
  File "renpy/display/render.pyx", line 259, in renpy.display.render.render (gen/renpy.display.render.c:3520)
    rv = d.render(widtho, heighto, st, at)
  File "/Applications/renpy-7.3.5-sdk/renpy/text/text.py", line 1996, in render
    virtual_layout = Layout(self, width, height, renders, drawable_res=False, size_only=True)
  File "/Applications/renpy-7.3.5-sdk/renpy/text/text.py", line 626, in __init__
    glyphs = ts.glyphs(s, self)
  File "/Applications/renpy-7.3.5-sdk/renpy/text/text.py", line 242, in glyphs
    fo = font.get_font(self.font, self.size, self.bold, self.italic, 0, self.antialias, self.vertical, self.hinting, layout.oversample)
  File "/Applications/renpy-7.3.5-sdk/renpy/text/font.py", line 699, in get_font
    face = load_face(fn)
  File "/Applications/renpy-7.3.5-sdk/renpy/text/font.py", line 640, in load_face
    raise Exception("Could not find font {0!r}.".format(orig_fn))
Exception: Could not find font u'whitrabt.ttf'.

Darwin-17.7.0-x86_64-i386-64bit
Ren'Py 7.3.5.606
Perchance to Dream 1.0
Fri Aug 12 08:31:57 2022
I literally have no idea why it's doing this.

Another thing I've tried and failed at is to define file routes separately to make it easier:

Code: Select all

    define hhenum = "fonts/Hhenum-Regular.otf"
    define white_rabbit = "fonts/whitrabt.ttf"
    define long_cang = "fonts/LongCang-Regular.ttf"
This has kind of worked for music so far (again it's weirdly finnicky about it)

Code: Select all

#Music

    define moderato = "audio/music/Z/Moderato in G Minor.mp3"
but I haven't gotten it to work for fonts and idk if that's just beyond Renpy's ability or if I'm doing it wrong.

I also thought that maybe

"define config.searchpath = [ ‘common’, ‘game’ ]"

https://www.renpy.org/doc/html/config.h ... searchpath

could work as I understand it allows you to set your own directories? But I admit I don't know enough about coding to understand it. If someone could explain it to me and if that is even a solution to my problems then I would be very thankful since I can't find much about this function on my own.

Anyways part of me is saying just screw it and go back to my disorganized but functional life but I just can't believe this is as complicated as it seems....there must be something I don't understand?? Anyways appreciate any help before I throw in the towel.

(I did my best to try and explain the issues but I can provide more if needed since it's like...an all-encompassing issue so it's hard to know how much to share to be helpful. Thank you!)

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: What am I doing wrong when trying to organize 'asset' folders? Will 'config.searchpath' help?

#2 Post by Alex »

Bishima wrote: Fri Aug 12, 2022 8:41 am ... This particular bg is attached to an animation so I wondered if that was why? But then I don't understand why Renpy can't find the file as normal since it's called in the same way either way. ...
Ren'Py automaticaly declare images in 'images' folder/subfolders, but if you declaring an ATL animation you need to specify image files with proper path from 'game' folder.

https://www.renpy.org/doc/html/displayi ... ing-images

Bishima wrote: Fri Aug 12, 2022 8:41 am ...

Code: Select all

n "{font=fonts/LongCang-Regular.ttf}{b}Why didn't you?{/b}{/font}"
Again, this becomes an issue with Renpy sometimes reading the fonts properly, and sometimes literally closing out the game since it can't read the fonts. It seems to be especially picky when I change font mid-line:

Code: Select all

fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
Results in:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/d route.rpy", line 594, in script
    fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
Exception: Could not find font u'whitrabt.ttf'.
...
..
You didn't specify the path to font file, so program tried to find it in 'game' folder (and failed).

User avatar
Bishima
Newbie
Posts: 10
Joined: Fri Nov 29, 2019 10:45 am
Contact:

Re: What am I doing wrong when trying to organize 'asset' folders? Will 'config.searchpath' help?

#3 Post by Bishima »

Alex wrote: Fri Aug 12, 2022 10:05 am
Bishima wrote: Fri Aug 12, 2022 8:41 am ... This particular bg is attached to an animation so I wondered if that was why? But then I don't understand why Renpy can't find the file as normal since it's called in the same way either way. ...
Ren'Py automaticaly declare images in 'images' folder/subfolders, but if you declaring an ATL animation you need to specify image files with proper path from 'game' folder.

https://www.renpy.org/doc/html/displayi ... ing-images

Bishima wrote: Fri Aug 12, 2022 8:41 am ...

Code: Select all

n "{font=fonts/LongCang-Regular.ttf}{b}Why didn't you?{/b}{/font}"
Again, this becomes an issue with Renpy sometimes reading the fonts properly, and sometimes literally closing out the game since it can't read the fonts. It seems to be especially picky when I change font mid-line:

Code: Select all

fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
Results in:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/d route.rpy", line 594, in script
    fema "You'll get to be the first {font=whitrabt.ttf}person{/font} ever to experience {font=whitrabt.ttf}artificial{/font} life!"
Exception: Could not find font u'whitrabt.ttf'.
...
..
You didn't specify the path to font file, so program tried to find it in 'game' folder (and failed).
Thanks for your answer. That certainly helped to eliminate some of the headache! I see part of the issue is I don't use text wrapping so I thought I had changed all the font paths but they were hiding on the other side of the scroll bar lol. Rather a silly mistake with an easy fix!

User avatar
Bishima
Newbie
Posts: 10
Joined: Fri Nov 29, 2019 10:45 am
Contact:

Re: What am I doing wrong when trying to organize 'asset' folders? Will 'config.searchpath' help?

#4 Post by Bishima »

Bishima wrote: Fri Aug 12, 2022 8:41 am Another thing I've tried and failed at is to define file routes separately to make it easier:

Code: Select all

    define hhenum = "fonts/Hhenum-Regular.otf"
    define white_rabbit = "fonts/whitrabt.ttf"
    define long_cang = "fonts/LongCang-Regular.ttf"
This has kind of worked for music so far (again it's weirdly finnicky about it)

Code: Select all

#Music

    define moderato = "audio/music/Z/Moderato in G Minor.mp3"
but I haven't gotten it to work for fonts and idk if that's just beyond Renpy's ability or if I'm doing it wrong.

I also thought that maybe

"define config.searchpath = [ ‘common’, ‘game’ ]"

https://www.renpy.org/doc/html/config.h ... searchpath

could work as I understand it allows you to set your own directories? But I admit I don't know enough about coding to understand it. If someone could explain it to me and if that is even a solution to my problems then I would be very thankful since I can't find much about this function on my own.
I feel like I am slowly figuring out all these errors (I was also using a way out-of-date ver of Renpy bc I've been too scared to upgrade but updating it actually helped a lot.

But I still don't really understand the issue with defining fonts as variables or how the config.searchpath option works... 🤔

I also have to see why my music/sound variables are so buggy but switching all those is going to take some time which I was planning to do tonight...so might have some new bugs to figure out soon. 🤪

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]