Here is the whole story.
There is a screen with a background which can be changed. You can unlock new backgorunds either by playing the story or by introducing some codes.
MobileBackground is a class that takes the name of the background in my assets and a boolean which decides if it will be possible to use that background.
mobile_bkg_01 is just an object. I wanted it to be default because you can change it's unlocked value, so I don't see the point of having a define.
Code: Select all
init python:
class MobileBackground:
def __init__(self, name_id, unlocked = False):
self.name_id = name_id
self.unlocked = unlocked
def unlock(self):
self.unlocked = True
renpy.retain_after_load()
default mobile_bkg_01 = MobileBackground("test")
There is also a function checkCode which is called when a user presses submit in a screen after writing something in an input(cheater_code). In this function I check if the written value is in a list(cheater_codes) of CheaterCode objects. If it's there then it will call a function.
Then there is cheater_code_01 which is a CheaterCode object with everything I need.
Code: Select all
init python:
class CheaterCode:
def __init__(self, code, message, func):
self.code = code
self.message = message
self.func = func
def checkCode(cheater_code):
for c in cheater_codes:
if c.code == cheater_code:
renpy.notify("%s"%(c.message))
c.func()
else:
renpy.notify("%s is wrong. Please try with a different one!"%(cheater_code))
define cheater_code_01 = CheaterCode("test", "You have unlocked a new background for your phone.", Function(mobile_bkg_01.unlock))
define cheater_codes = [cheater_code_01]
So my question is how can I refer to a default value in define. I have the same problem when I try something simpler like this:
Code: Select all
default val1 = "Here goes nothing"
default val2 = "Hello world"
define my_list = [val1, val2]
So I guess that if I manage to fix one problem I'll manage to fix both of them.
Thank you!