How to declare an extension as an image?
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.
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.
How to declare an extension as an image?
(This symbol (%) indicates an indentation)
Hey everyone! I'm creating a project, and what I'm trying to do is NOT have to write:
image charselect = Movie(size=(1920,1080), channel ="movie", play="movies/charselect.webm", loop=True)
over and over again.
The code I am using to accoplish this, is:
$ from os import listdir
$ for file in listdir("movies")
$ name = file.split(".")[0]
$ renpy.image(name, "movies"+file)
$ for file in listdir("movies")
$ name = file.split(".")[0]
$ renpy.image(name, "movies/fechap1"+file)
It was originally written to me like this:
$ from os import listdir:
(%) for file in listdir("movies")
(%) name = file.split(".")[0]
(%) renpy.image(name, "movies"+file)
(%) for file in listdir("movies")
(%) name = file.split(".")[0]
(%) renpy.image(name, "movies/fechap1"+file)
I can't, for the life of me, figure out where I'm going wrong. I keep getting the error "Invalid syntax:
for file in listdir("movies")
and I have no clue why! Anyone have any ideas?
P.S. This is my first post, apologies if I messed anything up!
Hey everyone! I'm creating a project, and what I'm trying to do is NOT have to write:
image charselect = Movie(size=(1920,1080), channel ="movie", play="movies/charselect.webm", loop=True)
over and over again.
The code I am using to accoplish this, is:
$ from os import listdir
$ for file in listdir("movies")
$ name = file.split(".")[0]
$ renpy.image(name, "movies"+file)
$ for file in listdir("movies")
$ name = file.split(".")[0]
$ renpy.image(name, "movies/fechap1"+file)
It was originally written to me like this:
$ from os import listdir:
(%) for file in listdir("movies")
(%) name = file.split(".")[0]
(%) renpy.image(name, "movies"+file)
(%) for file in listdir("movies")
(%) name = file.split(".")[0]
(%) renpy.image(name, "movies/fechap1"+file)
I can't, for the life of me, figure out where I'm going wrong. I keep getting the error "Invalid syntax:
for file in listdir("movies")
and I have no clue why! Anyone have any ideas?
P.S. This is my first post, apologies if I messed anything up!
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
- Contact:
Re: How to declare an extension as an image?
Use renpy.list_files.
Observe that renpy.image can only be called inside an init block and that the next parameter can be a displayable itself. In short, you can just do...
Observe that renpy.image can only be called inside an init block and that the next parameter can be a displayable itself. In short, you can just do...
Code: Select all
init python:
...
renpy.image("name", Movie(..., play="path.webm"))
Re: How to declare an extension as an image?
I'm not fully understanding the code there, or in the renpy documentation to be honest.
According to the documentation, I could use
to list all the files in the directory "movies" correct? If thats the case, I think what you're saying is I can then use
Right? If so, how does it define all of the files in "Movies" as images?
I guess, I'm saying I don't understand how this code block works, or how it would help define all of the webm files in a folder as images, so I can call them with the
scene command.
According to the documentation, I could use
Code: Select all
renpy.list_files ("game/movies", common=True)Code: Select all
Init python:
renpy.image ("movies", Movie("insertfilename", play="movies/charselect.webm", loop=True)
I guess, I'm saying I don't understand how this code block works, or how it would help define all of the webm files in a folder as images, so I can call them with the
scene command.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
- Contact:
Re: How to declare an extension as an image?
Returns a list of files, with / as the directory separator.
Code: Select all
init python hide:
for f in renpy.list_files():
parts = f.split("/")
fparts = parts[-1].split(".")
name, ext = " ".join(fparts[:-1]), fparts[-1]
if ext.lower() == "webm": renpy.image(name, Movie(play=f)) # if your filename is like `name1.name2.name3.webm`, it should be declared as `image name1 name2 name3 = Movie(...)`
Re: How to declare an extension as an image?
That worked beautifully! I ran the code and commented out the code I was using before, and had no issues! One day I hope to get that good at coding. Later on, I'm probably going to pick it apart and see if I can understand it fully. If you need anything feel free to let me know, however unlikely it is I can help I'm willing to try!
Once more- THANK YOU SO MUCH!
Once more- THANK YOU SO MUCH!
Who is online
Users browsing this forum: Bing [Bot]