<spanid="evennia-scripts-models"></span><h1>evennia.scripts.models<aclass="headerlink"href="#module-evennia.scripts.models"title="Permalink to this headline">¶</a></h1>
<p>Scripts are entities that perform some sort of action, either only
once or repeatedly. They can be directly linked to a particular
Evennia Object or be stand-alonw (in the latter case it is considered
a ‘global’ script). Scripts can indicate both actions related to the
game world as well as pure behind-the-scenes events and effects.
Everything that has a time component in the game (i.e. is not
hard-coded at startup or directly created/controlled by players) is
handled by Scripts.</p>
<p>Scripts have to check for themselves that they should be applied at a
particular moment of time; this is handled by the is_valid() hook.
Scripts can also implement at_start and at_end hooks for preparing and
cleaning whatever effect they have had on the game object.</p>
<p>Common examples of uses of Scripts:</p>
<ulclass="simple">
<li><p>Load the default cmdset to the account object’s cmdhandler
when logging in.</p></li>
<li><p>Switch to a different state, such as entering a text editor,
start combat or enter a dark room.</p></li>
<li><p>Merge a new cmdset with the default one for changing which
commands are available at a particular time</p></li>
<li><p>Give the account/object a time-limited bonus/effect</p></li>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.scripts.models.</code><codeclass="sig-name descname">ScriptDB</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">args</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/models.html#ScriptDB"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.models.ScriptDB"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">db_desc</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_desc"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_obj</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_obj"title="Permalink to this definition">¶</a></dt>
<dd><p>Accessor to the related object on the forward side of a many-to-one or
<codeclass="sig-name descname">db_account</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_account"title="Permalink to this definition">¶</a></dt>
<dd><p>Accessor to the related object on the forward side of a many-to-one or
<codeclass="sig-name descname">db_interval</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_interval"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_start_delay</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_start_delay"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_repeats</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_repeats"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_persistent</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_persistent"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_is_active</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_is_active"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">objects</code><emclass="property"> = <evennia.scripts.manager.ScriptDBManager object></em><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.objects"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">obj</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.obj"title="Permalink to this definition">¶</a></dt>
<dd><p>Property wrapper that homogenizes access to either the
db_account or db_obj field, using the same object property
<emclass="property">property </em><codeclass="sig-name descname">object</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.object"title="Permalink to this definition">¶</a></dt>
<dd><p>Property wrapper that homogenizes access to either the
db_account or db_obj field, using the same object property
<emclass="property">exception </em><codeclass="sig-name descname">DoesNotExist</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.DoesNotExist"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-name descname">MultipleObjectsReturned</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.MultipleObjectsReturned"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">account</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.account"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_account</strong>.</p>
<codeclass="sig-name descname">db_account_id</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_account_id"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_attributes</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_attributes"title="Permalink to this definition">¶</a></dt>
<dd><p>Accessor to the related objects manager on the forward and reverse sides of
<codeclass="sig-name descname">db_obj_id</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_obj_id"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
<codeclass="sig-name descname">db_tags</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_tags"title="Permalink to this definition">¶</a></dt>
<dd><p>Accessor to the related objects manager on the forward and reverse sides of
<emclass="property">property </em><codeclass="sig-name descname">desc</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.desc"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_desc</strong>.</p>
<codeclass="sig-name descname">get_next_by_db_date_created</code><spanclass="sig-paren">(</span><emclass="sig-param">*</em>, <emclass="sig-param">field=<django.db.models.fields.DateTimeField: db_date_created></em>, <emclass="sig-param">is_next=True</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.get_next_by_db_date_created"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">get_previous_by_db_date_created</code><spanclass="sig-paren">(</span><emclass="sig-param">*</em>, <emclass="sig-param">field=<django.db.models.fields.DateTimeField: db_date_created></em>, <emclass="sig-param">is_next=False</em>, <emclass="sig-param">**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.get_previous_by_db_date_created"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">interval</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.interval"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_interval</strong>.</p>
<emclass="property">property </em><codeclass="sig-name descname">is_active</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.is_active"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_is_active</strong>.</p>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.scripts.models.ScriptDB'</em><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.path"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">persistent</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.persistent"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_persistent</strong>.</p>
<codeclass="sig-name descname">receiver_script_set</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.receiver_script_set"title="Permalink to this definition">¶</a></dt>
<dd><p>Accessor to the related objects manager on the forward and reverse sides of
<emclass="property">property </em><codeclass="sig-name descname">repeats</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.repeats"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_repeats</strong>.</p>
<codeclass="sig-name descname">sender_script_set</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.sender_script_set"title="Permalink to this definition">¶</a></dt>
<dd><p>Accessor to the related objects manager on the forward and reverse sides of
<emclass="property">property </em><codeclass="sig-name descname">start_delay</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.start_delay"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for getting database field <strong>db_start_delay</strong>.</p>
<codeclass="sig-name descname">typename</code><emclass="property"> = 'SharedMemoryModelBase'</em><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.typename"title="Permalink to this definition">¶</a></dt>