Elmiwisa wrote:First, is there a reason you need to force an interaction in the first place?
No not really but I dislike polling as it's the most static variant of how to implement such a behavior. It may be fine for just a few objects or within microcontrollers as there is no need to have a look at resources, but there are plenty of better solutions for most cases in which polling is used.
The thing is: you can call the method a thousand times but nothing will change since a change is always triggered by the class itself (so no need for polling as the class could signalize RenPy "Hey wake up - I've changed something, so tell me when it's time to draw the new stuff"). This approach would be way less resource intensive and even though modern computers can handle such stuff but it may lead to problems on some weaker smartphones...it's basically like spamming into various pointers of the CPU without any need

But I don't know much about the internal code structure of RenPy - maybe there is a good reason for using polling. I just wanted to know if there is some way to get around it.
Elmiwisa wrote:
Otherwise, you could also maintain a list of all image that use that object, and manually update each of them using per_interact(). I have no clues on what are other consequence of each method though (including any potential issue with rollback and the like). This much technical details is beyond me. Perhaps at this point you can only hope that PyTom will come in and save the day.
Yeah, well I guess it's okay now. My problem was that I had a really though calculation to figure out which images in which order I have to draw and my mind told me "Gosh, you don't want to let the system calculate all this stuff every time the user clicks" as I'd like to have multiple of such complex elements on the screen.
My solution (which keeps my mind from shouting at me :p):
Code: Select all
class Foo(object):
changed = True
def setSomeStuff(self, stuff):
# configure the class/change attributes/ whatever
self.changed = False
def draw(self):
if not self.changed: # return cached calcs
return self.chached_stuff
# calculate
self.cached_stuff = calculated_stuff
self.cached = True
return calculated_stuff
This doesn't calculate all the complex stuff with lambda functions, filters and maps all the time but only when something changed internally within the class. It's basically just a small in-class cache...