Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
- Posts: 18
- Joined: Wed Dec 02, 2015 6:16 am
- Projects: There's a Dinosaur in my Bed (working title)
The other day I was testing out a way of playing animations in Renpy. Being fairly inexperienced, my simple method of doing it looked like this:
Code: Select all
I showed this to a friend of mine and he suggested I implement a code that would automatically load all the images without me having to list them all. However, we couldn't get it to work as Renpy just threw error after error at us. So now I have taken to these forums to seek guidance.
My friend's code looked something like this:
Code: Select all
def load_anim(location, lenght, interval):
image img = None
for i in range(length):
$ image fireball = load_anim("spells/fireball", 24, 0.06)
Is there a way to make this concept work? Any and all help is much appreciated!
Last edited by Sondre
on Thu Jun 21, 2018 6:38 am, edited 1 time in total.
- Miko-Class Veteran
- Posts: 659
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
The problem lies here: "image img = None" is NOT Python and can not be used inside a function. It is Ren'py script and can only used outside of functions or python blocks.
You need to be aware that there are actually four(!) languages used by Ren'py: Python, Ren'py script, screen language and ATL. While some things from Python, like loops, can be used in the others, the opposite is not true. Python has no idea how to interpret expressions from the three script languages.
Next: You can't .append a None type variable. .append is a method for lists only.
Also, the return statement needs to be indented one more instance. It belongs to the sub-block of def.
Unfortunately I can not help you with your initial problem. You can try using a for-loop directly inside the image declaration, but I doubt that it will work.
Crappy White Wings
(currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Users browsing this forum: No registered users