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.
-
Nero
- Veteran
- Posts: 242
- Joined: Tue Aug 09, 2016 2:59 pm
-
Contact:
#1
Post
by Nero » Thu Jun 04, 2020 1:49 pm
Hi, I have noticed interesting thing about for loops for example I wanna add all items from one list to another if some condition is met. Now thing is when first item is added to a list the for loop will just break (even if i never gave break or return command in code). Now can anyone can explain me how can I force loop until every item has been checked?
This is what i mean:
Code: Select all
skills = []
deck = [Item1(),Item2(),Item3()] # 2 of those items are "Skill" so 2 items should be added to skills list instead of 1
for x in deck:
if x.type == "Skill":
skills.append(x)
deck.remove(x)
# once only 1 item has been added for loop will break now even if i didnt say "break" how can I force it through every item in the list(deck)
Last edited by
Nero on Thu Jun 04, 2020 2:50 pm, edited 1 time in total.
-
Nero
- Veteran
- Posts: 242
- Joined: Tue Aug 09, 2016 2:59 pm
-
Contact:
#2
Post
by Nero » Thu Jun 04, 2020 2:50 pm
Found solution:
Just use reversed so loop would happen for every item.
Users browsing this forum: Bing [Bot], _ticlock_