What's a good way to handle plot flags, weekday and time of day events?

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.
Post Reply
Message
Author
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

What's a good way to handle plot flags, weekday and time of day events?

#1 Post by henvu50 »

My game will consist of a seven day week system. Each day has morning, noon, evening and night. Then I want certain events to happen based upon these conditions and plot flags.

What's the best way to handle these conditions without it all getting too confusing? I also want to avoid repeating the same code as much as possible.

Here's my theory so far, but as you can see it can get VERY messy and confusing:

Code: Select all

#MORNING
if morning
 if mon
   if plotFlag1
   if plotFlag2
   if plotFlag3   
 if tues
   if plotFlag1
   if plotFlag2
   if plotFlag3
 if weds
   if plotFlag1
   if plotFlag2
   if plotFlag3
 if thurs
   if plotFlag1
   if plotFlag2
   if plotFlag3
 if fri
    if plotFlag1
   if plotFlag2
   if plotFlag3
 if sat
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if sun
   if plotFlag1
   if plotFlag2
   if plotFlag3 

#NOON
if noon
   if plotFlag1
   if plotFlag2
   if plotFlag3
 if mon
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if tues
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if weds
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if thurs
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if fri
    if plotFlag1
   if plotFlag2
   if plotFlag3
 if sat
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if sun
   if plotFlag1
   if plotFlag2
   if plotFlag3 

#EVENING
if evening
 if mon
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if tues
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if weds
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if thurs
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if fri
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if sat
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if sun
   if plotFlag1
   if plotFlag2
   if plotFlag3 

#NIGHT
if night
 if mon
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if tues
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if weds
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if thurs
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if fri
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if sat
   if plotFlag1
   if plotFlag2
   if plotFlag3 
 if sun
   if plotFlag1
   if plotFlag2
   if plotFlag3

That looks messy and it's repeating so much code, is there a better way to handle this?


henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

Re: What's a good way to handle plot flags, weekday and time of day events?

#3 Post by henvu50 »

Any other ideas?

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: What's a good way to handle plot flags, weekday and time of day events?

#4 Post by trooper6 »

That cookbook recipe does everything you want. Why wouldn't you either a) use it, or b) read through the code to see how one person did it, so you can then do it your own way?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Google [Bot]