- May 3, 2018
- 1,403
- 1,011
This is my first time using renpy this week, and I found something odd.
Now I'm not the biggest python user, I'm a C# kind of programmer, but it seems renpy doesn't respect static methods? Am I doing anything wrong?
I have a class with a static method and class to represent a character's level of dress
I've notice these are not variables that renpy manages, so if I want 'undo' what the player does, such when going backwards, I have to directly code in this behavior, something simple like
I was having issues where renpy would still remember clothes when going to main menu and starting again, so obviously I need to reset everything at the start of the game. Hence the static method to clear the variables, which I call out at the start
However, It doesn't appear to work. I had to make some sanity check code
It's fine if I have directly reset each property, I've already started getting used to having to make tedious lengthy code with renpy, I just had hoped this was the one place I could make concise simple code, but I guess even fundamental python behavior can't be expected to work. I've already noticed some other inconsistencies in code behavior, but I had caulked it up to ren'py quirks, such as the pain in the butt ATL, but this is the one case I just found python is just plain not working. works just fine when I run the code in a dedicated anaconda interpreter, I just thought I would ask if any more experienced python/ren'py dev's notice code inconsistencies with renpy. like, is it running some older version of python that doesn't handle static methods/variables correctly?
Now I'm not the biggest python user, I'm a C# kind of programmer, but it seems renpy doesn't respect static methods? Am I doing anything wrong?
I have a class with a static method and class to represent a character's level of dress
Python:
#somewhere
init Python:
class Lilith_AA:
hasPants = False
hasUnderwear = False
hasShoes = False
hasShirt = False
#Through testing I found that renpy does not respect this, ie this function does not work as it should, does not clear variables
@staticmethod
def setNude():
hasPants = False
hasUnderwear = False
hasShoes = False
hasShirt = False
Python:
$Lilith_AA.hasPants = False #having this here allows pants to come off when going backwards through dialog
"Some dialog, character puts on pants!"
$Lilith_AA.hasPants = True
Python:
label Day_1: #Main Logic
call Day_1_Prolog
$Lilith_AA.setNude() #considerer this part of initilization so that the variable data doesn't cary over, at least not too badly
jump Day_1_Bathroom # WARNING NON LINEAR #
Python:
label Day_1_Bathroom_viewMirror:
scene Apartment Bathroom with dissolve
# testing something here
$Lilith_AA.setNude() # testing something here
if Lilith_AA.hasPants == True:
"pants"
else:
"no pants" # This should always display, but after putting on pants, the test fails and prints "pants"
#looks like renpy does not respect static function behavior? this is wierd