Skip to content
Exodia edited this page Sep 21, 2023 · 58 revisions

Routine system

Routine

Commitment

The Commitment class is the fundamental element.

Usage

INFO: For don't create problems if you not implement this in your project, the df_routine are not defined by default empty. BUT not save the changes.

For implement this you need to add this in your project:

init python:
    from pythonpackages.nqtr.routine import Commitment
    from pythonpackages.nqtr.action_talk import TalkObject

# habitual routine
# dictionary that cannot be modified at runtime, only by modifying the code. (content is not based on saves, but from the code)
define df_routine = {
}

Add an Commitment in dictionary

Recommended

(code-snippets: DR_RoutineAdd_in_dict)

# dictionary editable at runtime, but it is strongly discouraged to pre-enter elements (dictionary contents are based only on saves)
default routine = {}

# habitual routine
# dictionary that cannot be modified at runtime, only by modifying the code. (content is not based on saves, but from the code)
define df_routine = {
    "alice_sleep" : Commitment(
        ch_talkobj_dict={
            "alice" : TalkObject(
                name="talk_alice_sleep",
                label_name="talk_sleep",
                conversation_background = None,
            ),
        },
        hour_start=20, hour_stop=10,
        location_id="house", room_id="alice_room",
        background ="bg alice roomsleep",
    ),
    # alice_go_school have more priority than alice_read, because it is before in the dictionary
    "alice_go_school" : Commitment(
        characters="alice", # characters can be a string or a list of strings
        hour_start=10, hour_stop=14,
        location_id="school",
        disabled="weekend",
    ),
    "alice_read" : Commitment(
        ch_talkobj_dict={
            "alice" : TalkObject(
                name="talk_alice_read",
                conversation_background ="bg alice terrace talk"
            ),
        },
        hour_start=10, hour_stop=20,
        location_id="house", room_id="terrace",
        background ="bg alice terrace",
    ),
}

Add an Commitment

(code-snippets: DR_RoutineAdd)

python:
    routine["stagealice1"] = Commitment(characters="alice", hour_start=14, hour_stop=20, location_id="house", room_id="terrace")

Characters and TalkObject

How show up, into the Commitment class, you can set the characters and ch_talkobj_dict properties.

Into the creation of Commitment class, the characters and ch_talkobj_dict properties are unified.

characters

Commitment(
    ch_talkobj_dict={
        characters="alice", # characters can be a string or a list of strings
        hour_start=20, hour_stop=10,
        location_id="house", room_id="alice_room",
        background ="bg alice roomsleep",
    },
),

The characters property can be a string or a list of strings. You can use this property for set the characters into the your Commitment.

This is very important for the know where the character is.

If there are more Commitments with the same character, the System will prioritize the Commitment with the highest priority.

For add the icon of character you must use the Character Disct Method.

ch_talkobj_dict

Commitment(
    ch_talkobj_dict={
        "alice" : TalkObject(
            name="talk_alice_read",
            conversation_background ="bg alice terrace talk"
        ),
        hour_start=20, hour_stop=10,
        location_id="house", room_id="alice_room",
        background ="bg alice roomsleep",
    },
),

The ch_talkobj_dict property have the same function of [characters property], but is a dictionary and you can use this property for set the add Conversation Action into the your Commitment.

For add the icon of character you must use the Character Disct Method.

Disabled

For disable a commitment you can use the property disabled. This property can be set to bool or a string.

If is string: you can put a key of flags ( the sistem get the value of flag). Explained here: Flags - Ability to edit flags in constants

Exemple:

define df_routine = {
    # alice_go_school have more priority than alice_read, because it is before in the dictionary
    "alice_go_school" : Commitment(
        characters="alice", # characters can be a string or a list of strings
        hour_start=10, hour_stop=14,
        location_id="school",
        disabled="weekend",
    ),
    "alice_read" : Commitment(
        ch_talkobj_dict={
            "alice" : TalkObject(
                name="talk_alice_read",
                conversation_background ="bg alice terrace talk"
            ),
        },
        hour_start=10, hour_stop=20,
        location_id="house", room_id="terrace",
        background ="bg alice terrace",
    ),
}

Events

IMPORTANT: in case at the end of the event the same event occurs again the event will be deleted (to avoid loops). to not delete it you can use some stratagems with these functions: Methods for closing a label

By Events we mean: a label that is automatically started as soon as the player is in a certain position and/or at a certain time and/or based on the disabled check.

To implement it simply pass it by parameter to a Commitment event_label_name

Add an Event in dictionary

Recommended

(code-snippets: DR_EventAdd_in_dict)

Add an Event

(code-snippets: DR_EventAdd)

Add event by if

If you want to add an event based on a condition, you can use the label check_event_custom.

For example:

label check_event_custom:
    # Custom code
    # if (cur_room == ...):
        # ...
    return

Priority

Returns the commitments of the ch (NCPs) in that Location at that time. Prioritize the special commitment and then the first commitment found.

Clone this wiki locally