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.
I was wondering if there is a way I could check if self.list (self.status) holds variable poison. I tried doing it this way but it doesn't work... Any ideas how to fix this problem?
Nero wrote: ↑Sun Dec 16, 2018 12:26 am
I was wondering if there is a way I could check if self.list (self.status) holds variable poison. I tried doing it this way but it doesn't work... Any ideas how to fix this problem?
Nero wrote: ↑Sun Dec 16, 2018 7:08 am
Yeah I know tried it myself but you have idea how to work around it with deepcopy?
I don't really know what deepcopy does, but apparently deepcopy(spell) is not the same as spell, so if you check for spell in the list you will get a miss.
I tried to add a new variable to hold deepcopy(spell) and then check for that variable. That seemed to work.
abra=deepcopy(spell)
self.status.append(abra)
if abra in self.status:
In my case it does that for example if I have list with 5 (spells) in it and I declared each spell have duration time in class Debuff .. so if I create function that will run every turn (turn based game) and function will do duration -= 1 every time it loops ... if I dont use deepcopy the cooldown duration will be decreased by 5(because 5 spells are in list) instead of 1 so that's not what I want and deepcopy corrects this bug.
And mysteriously this actually works very well what you did, sadly I don't see much logic behind it I guess deepcopy creates something in variable name if appended through it. Anyways thanks for your help!
def add_status(self, spell):
from copy import deepcopy #import deepcopy so we can append a new object with the same properties
spell=deepcopy(spell)
self.status.append(spell)
if spell in self.status:
renpy.say(None, "Works")