How would I implement this?Have you perhaps considered a factory or dispatcher style pattern? Personally I'd edge toward one overlord class that just holds and spawns sub classes for events, basically a handler or over-seer class. Init that in a 0 or -1 offset and just register/amend/delete events from that. Ren'py should have no probs saving/loading that.
The class is defined in init -1. The only other init I have is not at an offset, it's just init.What init offset are you using?
I just call the chooseEvent method with the value of the type of event I want to choose from.How do you interact with the object?
Code: Select all
$ chooseEvent('officeEvent')Code: Select all
default patrolEvent_default_Obj = Event ('patrolEvent', 'True', 'patrolEvent_default')The objects themselves are just placed in separate .rpy files sorted by event type, paired by the above object and the label that object calls when chosen by the chooseEvent method.
Code: Select all
def chooseEvent(type):
list = []
for obj in Event.getinstances():
if eval(obj.isActive) and obj.triggered == False and obj.eventType == type:
list.append(obj)
if len(list) == 0:
return(False)
else:
renpy.call((renpy.random.choice(list)).doEvent)
return(True)However, after loading... nothing happens. I'm guessing that len(list) returns zero, and chooseEvent returns (False) instead of calling doEvent, because the game just continues to the next code block.
If that's true, then for some reason all of the Event objects either disappear, or all their isActive turn False, or all their triggered turn true, or all their eventTypes turn into smoke.