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.
Interpolation Changes Interpolations in strings are now treated as Python expressions, this results in mostly equivelent behaviour when interpreting fields except when item getters are in use. For example:
Interpolation Changes Interpolations in strings are now treated as Python expressions, this results in mostly equivelent behaviour when interpreting fields except when item getters are in use. For example:
class SomeClass:
def __init__(self):
self.dictionary = {
"a": "foo",
"b": "bar",
"c": "baz"
}
#How to make this automatically for every field inside self.dictionary ?
@property
def a(self):
return self.dictionary["a"]
#So i could call everything like
default class = SomeClass()
print(class.a) # "foo"
sinezub wrote: ↑Fri Mar 08, 2024 6:06 am
yea, I tried it, but get attribute error. NoneType have no attribute 'style'. looks like it's cant find right image or something like that.
That is another problem and is likely one you should be solving instead.
sinezub wrote: ↑Fri Mar 08, 2024 6:06 am
I'm actually curious now about how to refactor the class to make getters for every field in dictionary.
class SomeClass:
def __init__(self):
self.dictionary = {
"a": "foo",
"b": "bar",
"c": "baz"
}
#How to make this automatically for every field inside self.dictionary ?
@property
def a(self):
return self.dictionary["a"]
#So i could call everything like
default class = SomeClass()
print(class.a) # "foo"