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.
-
henvu50
- Veteran
- Posts: 322
- Joined: Wed Aug 22, 2018 1:22 am
-
Contact:
#1
Post
by henvu50 » Thu Sep 06, 2018 11:58 am
Code: Select all
for item in arrayTest:
# what index array number are we on ?
text arrayTest.index(item) + "\n"
How do I get the index number the loop is on? When it loops, I should have access to a number that represents what count the loop is on, how do I access the loop count number?
-
rames44
- Veteran
- Posts: 232
- Joined: Sun May 29, 2016 4:38 pm
-
Contact:
#2
Post
by rames44 » Thu Sep 06, 2018 12:06 pm
Well, one way is
Code: Select all
i = 0
for item in arrayTest:
(Use i as the index)
i += 1
-
MaydohMaydoh
- Regular
- Posts: 165
- Joined: Mon Jul 09, 2018 5:49 am
- Projects: Fuwa Fuwa Panic
- Tumblr: maydohmaydoh
- Location: The Satellite of Love
-
Contact:
#3
Post
by MaydohMaydoh » Thu Sep 06, 2018 12:11 pm
What you want is range and len
Code: Select all
for i in range(len(arrayTest)):
text arrayTest[i]
-
henvu50
- Veteran
- Posts: 322
- Joined: Wed Aug 22, 2018 1:22 am
-
Contact:
#4
Post
by henvu50 » Thu Sep 06, 2018 12:19 pm
Thanks, I changed my code accordingly.
Is it safe to use $ in a vbox for a loop? Doesn't $ make the variable global? If I use $ index somewhere else couldn't it conflict?
Code: Select all
vbox:
$ index = 10
for item in reversed(arrayTest):
text "[index]"
$ index -= 1
-
Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
-
Contact:
#5
Post
by Remix » Thu Sep 06, 2018 4:12 pm
or...
Code: Select all
for idx, item in enumerate( arrayTest ):
text "[idx] : [item]"
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#6
Post
by trooper6 » Thu Sep 06, 2018 5:17 pm
$ doesn’t make a variable global. $ is used to indicate the line is a line of python code and not RenPy code.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe:
http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
Users browsing this forum: Google [Bot], span4ev