evennia/docs/source/Contribs/Contrib-Custom-Gametime.md
2022-01-08 00:58:56 +01:00

1.6 KiB

Custom gameime

Contrib - Griatch 2017, vlgeoff 2017

This reimplements the evennia.utils.gametime module but supporting a custom calendar for your game world. It allows for scheduling events to happen at given in-game times, taking this custom calendar into account.

Installation

Import and use this in the same way as you would the normal evennia.utils.gametime module.

Customize the calendar by adding a TIME_UNITS dict to your settings (see example below).

Usage:

    from evennia.contrib.base_systems import custom_gametime

    gametime = custom_gametime.realtime_to_gametime(days=23)

    # scedule an event to fire every in-game 10 hours
    custom_gametime.schedule(callback, repeat=True, hour=10)

The calendar can be customized by adding the TIME_UNITS dictionary to your settings file. This maps unit names to their length, expressed in the smallest unit. Here's the default as an example:

TIME_UNITS = {
    "sec": 1,
    "min": 60,
    "hr": 60 * 60,
    "hour": 60 * 60,
    "day": 60 * 60 * 24,
    "week": 60 * 60 * 24 * 7,
    "month": 60 * 60 * 24 * 7 * 4,
    "yr": 60 * 60 * 24 * 7 * 4 * 12,
    "year": 60 * 60 * 24 * 7 * 4 * 12, }

When using a custom calendar, these time unit names are used as kwargs to the converter functions in this module. Even if your calendar uses other names for months/weeks etc the system needs the default names internally.


This document page is generated from evennia/contrib/base_systems/custom_gametime/README.md. Changes to this file will be overwritten, so edit that file rather than this one.