Please do not create new links to this page. It comprises a number of independent modules that can be combined to create games. DSE can be downloaded from the frameworks page. This should be called from init code to declare a stat. This should be called after one or more stats have been updated. It ensures that each stat has a value that is between 0 and the maximum value defined for that stat.
Displays a window containing all the stats, in the order registered. The name, bar, value, and max parameters control the display of the corresponding portions of the statistics.
This system is responsible for calling Ren'Py code that implements each of the events. The event dispatcher chooses a list of events that should be run during a given period, and then is responsible for calling each of those events in turn until either all events are exhausted, or one of the events indicates that the period should come to an end.
Events An event consists of a block of Ren'Py code. The name of the event is the name of the label that is called to execute that event. There are three ways of returning from an event. Simply executing a 'return' statement will end the event, and activate any later event in the same period.
Events are declared by calling the event name, This function takes a variable number of arguments. The first argument is always the name of the event, which is also the label that is called to start the event. The second and later arguments are conditions that must be true for the event to occur.
These conditions may either be python expressions in strings, or the result of one of condition functions given below. The event function takes one keyword argument, priority which gives the priority of the event. Events with a smaller priority number are considered before those with a larger priority number, with the default priority being Consideration of events occurs in two phases. First, the conditions are evaluated on each event.
If any condition is false, the event is discarded, otherwise it is added to the event list. Then, the list is filtered and random elements chosen such that only one event is in each choice group, for the events that are in choice groups. The events are always kept in priority order, with lower numbers being higher priority.
The first event in the list is recorded as being executed, and then executed. Execution continues until all events are exhausted, or the period is forced to end.
The following condition functions ship as part of the DSE. Returns True until the event has been executed once, and then returns False. It can be used to ensure that the user will only see and event once. Returns True if there are no higher-priority events scheduled.
Use this on a very-low-priority event that should only occur if no high-priority events occur. Returns True if no higher-priority events have been. If it returns True, it prevents all other events from being considered. Supply this function with one or more events names strings. It returns true if those events have happened already, at any time in the game. It returns true if those events have executed, yesterday or before. Probability is a float between 0. Returns True with the supplied probability, each time it is evaluated.
This defines a group from which only one event can be chosen. DSE randomly picks one of the elements from the group such that all of the other conditions are True. An event can only be in one group at a time. Objects returned from here should not have operators applied to them. The count is used to determine the relative likelyhood of an event in a group being chosen, with a count of 10 being 10 times more likely then a count of 1. The objects returned from condition functions can be combined using the and, or, and not operators.
This should be called at the start of each period, and if it returns True the period should be skipped entirely. Ending a day stops skipping periods, and also changes the events that are considered executed by event. The user must pick one choice for each period, and may change his choice. When the user picks "Done Planning", the values corresponding to each of his choices are assigned to the variables corresponding to the different periods. These functions should be called from inside an init block, usually an init python block.
Defines a new period, with the given name and the given variable. Defines a new choice within a period. Name is the name that is shown to the user. Value is the value that will be assigned to a variable if this is the selected choice. Enable and Show are expressions that determine if the choice will be enabled or shown, respectively.
If either expression evaluates to False, the choice is not selectable. This variable controls the title of the Done Planning button. When the day planner returns, the variables corresponding to those periods will have new values assigned to them. Examples The rest of the files in the DSE distribution form an example game. Each day, it calls the day planner to plan the day, then calls the event functions to evaluate the events for each period.
Conceptual Example This is an illustrated example of how to implement variables for class periods: These are arbitrary values so feel free to change them! This isn't fully documented source code, this is just showing what can be done. The "weekday" is a container that changes. A variable with an integer contains the actual period which keeps track of the time.
So if it's 5 AM, then the actual period might be If the player takes an action, it advances the actual period by the action's period cost and reduces the players energy by an equivalent amount. Sleeping In may cost 4 periods, but also restore energy.
Eat Breakfast may cost 1 period. Go to School Early won't cost any periods. First, we check to see if this is a rest action. Execute an action and calculate its benefits, like below. This isn't a rest action, so let's check to see if the player passes out. Unless you want to do a hybrid action. Run this function again except with the Passed Out credentials, i. There is enough energy to execute the action.