<pclass="last">You are reading an old version of the Evennia documentation. <ahref="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
<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>
</ul>
<dlclass="py class">
<dtid="evennia.scripts.models.ScriptDB">
<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>
<dt>The TypedObject supplies the following (inherited) properties:</dt><dd><p>key - main name
name - alias for key
typeclass_path - the path to the decorating typeclass
typeclass - auto-linked typeclass
date_created - time stamp of object creation
permissions - perm strings
dbref - #id of object
db - persistent attribute storage
ndb - non-persistent attribute storage</p>
</dd>
<dt>The ScriptDB adds the following properties:</dt><dd><p>desc - optional description of script
obj - the object the script is linked to, if any
account - the account the script is linked to (exclusive with obj)
interval - how often script should run
start_delay - if the script should start repeating right away
repeats - how many times the script should repeat
persistent - if script should survive a server reboot
is_active - bool if script is currently running</p>
</dd>
</dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.db_desc">
<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
object the first time, the query is executed.</p>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.db_obj">
<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
object the first time, the query is executed.</p>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.objects">
<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>
<dd></dd></dl>
<dlclass="py method">
<dtid="evennia.scripts.models.ScriptDB.obj">
<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
name.</p>
</dd></dl>
<dlclass="py method">
<dtid="evennia.scripts.models.ScriptDB.object">
<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>
<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_date_created</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_date_created"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
object the first time, the query is executed.</p>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.db_key">
<codeclass="sig-name descname">db_key</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_key"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_lock_storage</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_lock_storage"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_id</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_obj_id"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.db_tags">
<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
<codeclass="sig-name descname">db_typeclass_path</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.db_typeclass_path"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
object the first time, the query is executed.</p>
</dd></dl>
<dlclass="py method">
<dtid="evennia.scripts.models.ScriptDB.desc">
<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>
<dd></dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.id">
<codeclass="sig-name descname">id</code><aclass="headerlink"href="#evennia.scripts.models.ScriptDB.id"title="Permalink to this definition">¶</a></dt>
<dd><p>A wrapper for a deferred-loading field. When the value is read from this
object the first time, the query is executed.</p>
</dd></dl>
<dlclass="py method">
<dtid="evennia.scripts.models.ScriptDB.interval">
<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>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.path">
<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
<p><strong>**Pizza.toppings**</strong> and <strong>**Topping.pizzas**</strong> are <strong>**ManyToManyDescriptor**</strong>
instances.</p>
<p>Most of the implementation is delegated to a dynamically defined manager
class built by <strong>**create_forward_many_to_many_manager()**</strong> defined below.</p>
</dd></dl>
<dlclass="py method">
<dtid="evennia.scripts.models.ScriptDB.repeats">
<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>
</dd></dl>
<dlclass="py attribute">
<dtid="evennia.scripts.models.ScriptDB.typename">
<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>
<pclass="last">You are reading an old version of the Evennia documentation. <ahref="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
</div>
<divclass="footer"role="contentinfo">
© Copyright 2023, The Evennia developer community.
Created using <ahref="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.