<spanid="evennia-scripts-ondemandhandler"></span><h1>evennia.scripts.ondemandhandler<aclass="headerlink"href="#module-evennia.scripts.ondemandhandler"title="Permalink to this headline">¶</a></h1>
<p>Helper to handle on-demand requests, allowing a system to change state only when a player or system
actually needs the information. This is a very efficient way to handle gradual changes, requiring
not computer resources until the state is actually needed.</p>
<p>The truth is that most of the time, players are not looking at most of the things in the game. They
_only_ need to know about which state the flower is in when they are actually looking at it, or
when they are in the same room as it (so it can be incorporated in the room description). This is
where on-demand handling comes in.</p>
<p>This is the basic principle, using the flowering system as an example.</p>
<olclass="arabic simple">
<li><dlclass="simple">
<dt>Someone plants a seed in a room (could also be automated). The seed is in a “seedling” state.</dt><dd><p>We store the time it was planted (this is the important bit).</p>
</dd>
</dl>
</li>
<li><p>A player enters the room or looks at the plant. We check the time it was planted, and calculate</p></li>
</ol>
<blockquote>
<div><p>how much time has passed since it was planted. If enough time has passed, we change the state to
“sprouting” and probably change its description to reflect this.</p>
</div></blockquote>
<olclass="arabic simple"start="3">
<li><p>If a player looks at the plant and not enough time has passed, it keeps the last updated state.</p></li>
<li><p>Eventually, it will be bloom time, and the plant will change to a “blooming” state when the
player looks.</p></li>
<li><p>If no player ever comes around to look at the plant, it will never change state, and if they show
up after a long time, it may not show as a “wilted” state or be outright deleted when observed,
since too long time has passed and the plant has died.</p></li>
</ol>
<p>With a system like this you could have growing plants all over your world and computing usage would
<p>There is only one situation where this system is not ideal, and that is when a player should be
informed of the state change _even if they perform no <ahref="#id1"><spanclass="problematic"id="id2">action_</span></a>. That is, even if they are just idling
in the room, they should get a message like ‘the plant suddenly blooms’ (or, more commonly, for
messages like ‘you are feeling hungry’). For this you still probably need to use one of Evennia’s
built-in timers or tickers instead. But most of the time you should really consider using on-demand
handling instead.</p>
<sectionid="usage">
<h2>Usage<aclass="headerlink"href="#usage"title="Permalink to this headline">¶</a></h2>
<emclass="property">static </em><codeclass="sig-name descname">runtime</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.runtime"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.runtime"title="Permalink to this definition">¶</a></dt>
<dd><p>Wraps the gametime.runtime() function.</p>
<p>Need to import here to avoid circular imports during server reboot.
<emclass="property">static </em><codeclass="sig-name descname">stagefunc_loop</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">task</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.stagefunc_loop"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_loop"title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><codeclass="sig-name descname">stagefunc_bounce</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">task</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.stagefunc_bounce"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_bounce"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">default_stage_function</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.default_stage_function"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span></em>, <emclass="sig-param"><spanclass="n">stages</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">autostart</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em>) – A unique identifier for the task.</p></li>
<li><p><strong>stages</strong> (<em>dict</em><em>, </em><em>optional</em>) – A dictionary <strong>{dt: str}</strong> or <strong>{int or float: (str, callable)}</strong>
of time-deltas (in seconds) and the stage name they represent. If the value is a
tuple, the first element is the name of the stage and the second is a callable
that will be called when that stage is <em>first</em> reached. Warning: This callable
is <em>only</em> triggered if the stage is actually checked/retrieved while the task is
in that stage checks - it’s _not_ guaranteed to be called, even if the task
time-wise goes through all its stages. Each callable must be picklable (so normally
it should be a stand-alone function), and takes one argument - this OnDemandTask,
which it can be modified in-place as needed. This can be used to loop a task or do
other changes to the task.</p></li>
<li><p><strong>autostart</strong> (<em>bool</em><em>, </em><em>optional</em>) – If <strong>last_checked</strong> is <strong>None</strong>, and this is <strong>False</strong>, then the
time will not start counting until the first call of <strong>get_dt</strong> or <strong>get_stage</strong>. If
<strong>True</strong>, creating the task will immediately make a hidden check and start the timer.</p></li>
<codeclass="sig-name descname">check</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">autostart</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.check"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.check"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">get_dt</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.get_dt"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.get_dt"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">set_dt</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">dt</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.set_dt"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.set_dt"title="Permalink to this definition">¶</a></dt>
<dd><p>Set the time-delta since the task started manually. This allows you to ‘cheat’ the system
and set the time manually. This is useful for testing or when a system manipulates the state
somehow (like using a potion that speeds up the growth of a plant).</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>dt</strong> (<em>int</em>) – The time-delta to set. This is an absolute value in seconds, same as returned
by <strong>get_dt</strong>.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Setting this will not on its own trigger any stage functions - this will only happen
as normal, next time the state is checked and the stage is found to have changed.</p>
<codeclass="sig-name descname">get_stage</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.get_stage"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.get_stage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">set_stage</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">stage</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.set_stage"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.set_stage"title="Permalink to this definition">¶</a></dt>
<dd><p>Set the stage of the task manually. This allows you to ‘cheat’ the system and set the stage
manually. This is useful for testing or when a system manipulates the state somehow (like
using a potion that speeds up the growth of a plant). The given stage must be previously
created for the given task. If task has no stages, this will do nothing.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>stage</strong> (<em>str</em><em>, </em><em>optional</em>) – The stage to set. If <strong>None</strong>, the task will be reset to its
initial (first) state.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Setting this will not on its own trigger any stage functions - this will only happen
as normal, next time the state is checked and the stage is found to have changed.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.scripts.ondemandhandler.</code><codeclass="sig-name descname">OnDemandHandler</code><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-name descname">load</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.load"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.load"title="Permalink to this definition">¶</a></dt>
<dd><p>Load the on-demand timers from ServerConfig storage.</p>
<p>This should be automatically called when Evennia starts.</p>
<codeclass="sig-name descname">save</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.save"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.save"title="Permalink to this definition">¶</a></dt>
<dd><p>Save the on-demand timers to ServerConfig storage. Should be called when Evennia shuts down.</p>
<codeclass="sig-name descname">add</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">stages</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">autostart</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.add"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.add"title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new on-demand task.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – A unique identifier for the task. If this
is a callable, it will be called without arguments. If a db-Object, it will be
converted to a string representation (which will include its (#dbref). If an
<strong>OnDemandTask</strong>, then all other arguments are ignored and the task is simply added
as-is.</p></li>
<li><p><strong>category</strong> (<em>str</em><em> or </em><em>callable</em><em>, </em><em>optional</em>) – A category to group the task under. If given, it
must also be given when checking the task.</p></li>
<li><p><strong>stages</strong> (<em>dict</em><em>, </em><em>optional</em>) – A dictionary {dt: str}, of time-deltas (in seconds) and the
stage which should be entered after that much time has passed. autostart (bool,</p></li>
<li><p><strong>optional</strong><strong>)</strong>– If <strong>True</strong>, creating the task will immediately make a hidden
<dt>The created task (or the same that was added, if given an <strong>OnDemandTask</strong></dt><dd><p>as a <strong>key</strong>). Use <strong>task.get_dt()</strong> and <strong>task.get_stage()</strong> to get data from it
<codeclass="sig-name descname">batch_add</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">tasks</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.batch_add"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.batch_add"title="Permalink to this definition">¶</a></dt>
<dd><p>Add multiple on-demand tasks at once.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>*tasks</strong> (<aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a>) – A set of OnDemandTasks to add.</p>
<codeclass="sig-name descname">remove</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.remove"title="Permalink to this definition">¶</a></dt>
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifier for the task. If a
callable, will be called without arguments. If an Object, will be converted to a
string. If an <strong>OnDemandTask</strong>, then all other arguments are ignored and the task
will be used to identify the task to remove.</p></li>
<codeclass="sig-name descname">batch_remove</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">*</span><spanclass="n">keys</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.batch_remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.batch_remove"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove multiple on-demand tasks at once, potentially within a given category.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>*keys</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifiers for the tasks. If
a callable, will be called without arguments. If an Object, will be converted to a
string. If an <strong>OnDemandTask</strong>, then all other arguments are ignored and the task will
be used to identify the task to remove.</p></li>
<li><p><strong>category</strong> (<em>str</em><em> or </em><em>callable</em><em>, </em><em>optional</em>) – The category of the tasks.</p></li>
<codeclass="sig-name descname">all</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">all_on_none</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.all"title="Permalink to this definition">¶</a></dt>
<dd><p>Get all on-demand tasks.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of the tasks.</p></li>
<li><p><strong>all_on_none</strong> (<em>bool</em><em>, </em><em>optional</em>) – Determines what to return if <strong>category</strong> is <strong>None</strong>.
If <strong>True</strong>, all tasks will be returned. If <strong>False</strong>, only tasks without a category
will be returned.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>dict</em>– A dictionary of all on-demand task, on the form <strong>{(key, category): task), …}</strong>.
Use <strong>task.get_dt()</strong> or <strong>task.get_stage()</strong> to get the time-delta or stage of each task
<codeclass="sig-name descname">clear</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">all_on_none</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.clear"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.clear"title="Permalink to this definition">¶</a></dt>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of the tasks to clear. What <strong>None</strong> means is
determined by the <strong>all_on_none</strong> kwarg.</p></li>
<li><p><strong>all_on_none</strong> (<em>bool</em><em>, </em><em>optional</em>) – Determines what to clear if <strong>category</strong> is <strong>None</strong>. If
<strong>True</strong>, clear all tasks, if <strong>False</strong>, only clear tasks with no category.</p></li>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Get an on-demand task. This will _not_ check it.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifier for the task. If a
<codeclass="sig-name descname">get_dt</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get_dt"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.get_dt"title="Permalink to this definition">¶</a></dt>
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifier for the task. If a
callable, will be called without arguments. If an Object, will be converted to a
string. If an <strong>OnDemandTask</strong>, then all other arguments are ignored and the task
will be used to identify the task to get the time-delta from.</p></li>
<li><p><strong>**kwargs</strong>– Will be passed to the stage function, if one is called.</p></li>
<codeclass="sig-name descname">set_dt</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span></em>, <emclass="sig-param"><spanclass="n">dt</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.set_dt"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.set_dt"title="Permalink to this definition">¶</a></dt>
<dd><p>Set the time-delta since the task started manually. This allows you to ‘cheat’ the system
and set the time manually. This is useful for testing or when a system manipulates the state
somehow (like using a potion that speeds up the growth of a plant).</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifier for the task. If a
<codeclass="sig-name descname">get_stage</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get_stage"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.get_stage"title="Permalink to this definition">¶</a></dt>
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifier for the task. If a
callable, will be called without arguments. If an Object, will be converted to a
string. If an <strong>OnDemandTask</strong>, then all other arguments are ignored and the task
will be used to identify the task to get the stage from.</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of the task.</p></li>
<li><p><strong>**kwargs</strong>– Will be passed to the stage function, if one is called.</p></li>
<codeclass="sig-name descname">set_stage</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">key</span></em>, <emclass="sig-param"><spanclass="n">category</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">stage</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.set_stage"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.set_stage"title="Permalink to this definition">¶</a></dt>
<dd><p>Set the stage of an on-demand task manually. This allows you to ‘cheat’ the system and set
the stage manually. This is useful for testing or when a system manipulates the state
somehow (like using a potion that speeds up the growth of a plant). The given stage must
be previously created for the given task. If task has no stages, this will do nothing.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><aclass="reference internal"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a><em> or </em><em>Object</em>) – The unique identifier for the task. If a
callable, will be called without arguments. If an Object, will be converted to a
string. If an <strong>OnDemandTask</strong>, then all other arguments are ignored and the task
will be used to identify the task to set the stage for.</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of the task.</p></li>
<li><p><strong>stage</strong> (<em>str</em><em>, </em><em>optional</em>) – The stage to set. If <strong>None</strong>, the task will be reset to its
initial (first) state.</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Setting this will not on its own trigger any stage functions - this will only happen
as normal, next time the state is checked and the stage is found to have changed.</p>