From 2be93714824b22a713dd212301df1ce77dfbe188 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Sat, 15 Jul 2023 16:50:47 +0100 Subject: [PATCH] Bug fixes * Fixed 'Panty Thief' event requirements * Improved event validation to avoid errors in user space * Offset game object initialization to avoid bogus init errors --- .../characters/hermione/events/odd_jobs/init.rpy | 4 ++-- game/scripts/events/queue.rpy | 15 ++++++++++++--- game/scripts/inventory/game.rpy | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/game/scripts/characters/hermione/events/odd_jobs/init.rpy b/game/scripts/characters/hermione/events/odd_jobs/init.rpy index e7bcd06a..225ca1e7 100644 --- a/game/scripts/characters/hermione/events/odd_jobs/init.rpy +++ b/game/scripts/characters/hermione/events/odd_jobs/init.rpy @@ -7,8 +7,8 @@ default her_ev_promoter_job_return = Event(id="her_ev_promoter_job_return", labe default her_ev_promoter_job_hub = Event(id="her_ev_promoter_job_hub", label="her_promoter_job", priority=5, req="states.her.ev.promote_cardgame.offered and poker_outfit_ITEM.unlocked", repeat=True, autoenqueue=True, autodequeue=False, queue="her_eventqueue_jobs_promoter", subevents=["her_ev_promoter_job_return"]) -default her_ev_panty_thief_t1_e1 = Event(id="her_ev_panty_thief_t1_e1", label="hg_pr_panty_thief_T1_E1", req="states.her.tier = 1", autoenqueue=True, autodequeue=False, queue="her_eventqueue_panty_thief") -default her_ev_panty_thief_t2_e1 = Event(id="her_ev_panty_thief_t2_e1", label="hg_pr_panty_thief_T2_E1", req="states.her.tier = 2", autoenqueue=True, autodequeue=False, queue="her_eventqueue_panty_thief") +default her_ev_panty_thief_t1_e1 = Event(id="her_ev_panty_thief_t1_e1", label="hg_pr_panty_thief_T1_E1", req="states.her.tier == 1", autoenqueue=True, autodequeue=False, queue="her_eventqueue_panty_thief") +default her_ev_panty_thief_t2_e1 = Event(id="her_ev_panty_thief_t2_e1", label="hg_pr_panty_thief_T2_E1", req="states.her.tier == 2", autoenqueue=True, autodequeue=False, queue="her_eventqueue_panty_thief") default her_ev_panty_thief_t3_e1 = Event(id="her_ev_panty_thief_t3_e1", label="hg_pr_panty_thief_e1_return", req="game.daytime==False") default her_ev_panty_thief_t3_e1_hub = Event(id="her_ev_panty_thief_t3_e1_hub", label="hg_pr_panty_thief_e1", req="states.her.tier >= 3", autoenqueue=True, autodequeue=False, queue="her_eventqueue_panty_thief", subevents=["her_ev_panty_thief_t3_e1"]) diff --git a/game/scripts/events/queue.rpy b/game/scripts/events/queue.rpy index 4808e79d..9cd6b47e 100644 --- a/game/scripts/events/queue.rpy +++ b/game/scripts/events/queue.rpy @@ -146,8 +146,9 @@ init -1 python: self.completed = False self.completed_failed = False + # Validation if not renpy.has_label(self.label): - raise Exception("Supplied label does not exist.") + raise Exception(f"Supplied label does not exist:\n{self.label}") if autoenqueue: self.enqueue() @@ -221,7 +222,15 @@ init -1 python: def requirements_met(self): if self.req: - return eval(self.req) + try: + return eval(self.req) + except Exception as e: + msg = f"Event '{self.id}' requirements evaluation has failed:\n{e} for '{self.req}'" + if config.developer: + raise Exception(msg) + else: + print(msg) + renpy.notify("An error has occured. Check console for details.") return True def start(self, _caller=None): @@ -386,4 +395,4 @@ init -1 python: init offset = -5 -default eventqueue = EventQueue("mainloop") \ No newline at end of file +default eventqueue = EventQueue("mainloop") diff --git a/game/scripts/inventory/game.rpy b/game/scripts/inventory/game.rpy index e617ee57..78979c24 100644 --- a/game/scripts/inventory/game.rpy +++ b/game/scripts/inventory/game.rpy @@ -1,4 +1,4 @@ -init python: +init -100 python: def show_gold(st, at, old, new): if st > 1.0: return Text("G {}".format(new)), None @@ -86,6 +86,8 @@ screen gold(old, new): timer 3.0 action Hide("gold") +init offset = -99 + default game = Game() # Points change displayable