<spanid="evennia-scripts-ondemandhandler"></span><h1>evennia.scripts.ondemandhandler<aclass="headerlink"href="#module-evennia.scripts.ondemandhandler"title="Link to this heading">¶</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>For example, consider a flowering system, where a seed sprouts, grows and blooms over a certain
time. One _could_ implement this with e.g. a Script or a ticker that gradually moves the flower
along its stages of growth. But what if that flower is in a remote location, and no one is around to
see it? You are then wasting computational resources on something that no one is looking at.</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
only scale by how many players you have exploring your world. The players will not know the
difference between this and a system that is always running, but your server will thank you.</p>
<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="Link to this heading">¶</a></h2>
<emclass="property"><spanclass="k"><spanclass="pre">class</span></span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">evennia.scripts.ondemandhandler.</span></span><spanclass="sig-name descname"><spanclass="pre">OnDemandTask</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">stages</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">autostart</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask"title="Link to this definition">¶</a></dt>
<emclass="property"><spanclass="k"><spanclass="pre">static</span></span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">runtime</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.runtime"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.runtime"title="Link 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"><spanclass="k"><spanclass="pre">static</span></span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">stagefunc_loop</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">task</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.stagefunc_loop"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_loop"title="Link to this definition">¶</a></dt>
<dd><p>Attach this to the last stage to have the task start over from
<emclass="property"><spanclass="k"><spanclass="pre">static</span></span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">stagefunc_bounce</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">task</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.stagefunc_bounce"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_bounce"title="Link to this definition">¶</a></dt>
<dd><p>This endfunc will have the task reverse direction and go through the stages in
reverse order. This stage-function must be placed at both ‘ends’ of the stage sequence
<spanclass="sig-name descname"><spanclass="pre">default_stage_function</span></span><emclass="property"><spanclass="w"></span><spanclass="p"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="pre">None</span></em><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.default_stage_function"title="Link to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">__init__</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">stages</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">autostart</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.__init__"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.__init__"title="Link to this definition">¶</a></dt>
<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>
<spanclass="sig-name descname"><spanclass="pre">check</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">autostart</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.check"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.check"title="Link to this definition">¶</a></dt>
<dd><p>Check the current stage of the task and return the time-delta to the next stage.</p>
<spanclass="sig-name descname"><spanclass="pre">get_dt</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.get_dt"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.get_dt"title="Link to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">set_dt</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">dt</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.set_dt"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.set_dt"title="Link 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>
<spanclass="sig-name descname"><spanclass="pre">get_stage</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.get_stage"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.get_stage"title="Link to this definition">¶</a></dt>
<dd><p>Get the current stage of the task. If no stage was given, this will return <strong>None</strong> but
<spanclass="sig-name descname"><spanclass="pre">set_stage</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">stage</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.set_stage"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandTask.set_stage"title="Link 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>
<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"><spanclass="k"><spanclass="pre">class</span></span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">evennia.scripts.ondemandhandler.</span></span><spanclass="sig-name descname"><spanclass="pre">OnDemandHandler</span></span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler"title="Link to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">__init__</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.__init__"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.__init__"title="Link to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">load</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.load"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.load"title="Link 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>
<spanclass="sig-name descname"><spanclass="pre">save</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.save"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.save"title="Link to this definition">¶</a></dt>
<dd><p>Save the on-demand timers to ServerConfig storage. Should be called when Evennia shuts down.</p>
<spanclass="sig-name descname"><spanclass="pre">add</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">stages</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">autostart</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.add"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.add"title="Link 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>) – 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
<spanclass="sig-name descname"><spanclass="pre">batch_add</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">*</span></span><spanclass="n"><spanclass="pre">tasks</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.batch_add"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.batch_add"title="Link to this definition">¶</a></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>
<spanclass="sig-name descname"><spanclass="pre">remove</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.remove"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.remove"title="Link 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>
<li><p><strong>category</strong> (<em>str</em><em> or </em><em>callable</em><em>, </em><em>optional</em>) – The category of the task.</p></li>
<spanclass="sig-name descname"><spanclass="pre">batch_remove</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">*</span></span><spanclass="n"><spanclass="pre">keys</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.batch_remove"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.batch_remove"title="Link to this definition">¶</a></dt>
<dd><p>Remove multiple on-demand tasks at once, potentially within a given category.</p>
<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>
<spanclass="sig-name descname"><spanclass="pre">all</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">all_on_none</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.all"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.all"title="Link to this definition">¶</a></dt>
<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
<spanclass="sig-name descname"><spanclass="pre">clear</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">all_on_none</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.clear"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.clear"title="Link 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>
<spanclass="sig-name descname"><spanclass="pre">get</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.get"title="Link to this definition">¶</a></dt>
<dd><p>Get an on-demand task. This will _not_ check it.</p>
<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 (only useful to check the task is the same).</p></li>
<li><p><strong>category</strong> (<em>str</em><em>, </em><em>optional</em>) – The category of the task. If unset, this will only return
<spanclass="sig-name descname"><spanclass="pre">get_dt</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get_dt"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.get_dt"title="Link to this definition">¶</a></dt>
<dd><p>Get the time-delta since the task started.</p>
<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>
<spanclass="sig-name descname"><spanclass="pre">set_dt</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">dt</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.set_dt"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.set_dt"title="Link 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>
<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 time-delta 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>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></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>
<spanclass="sig-name descname"><spanclass="pre">get_stage</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get_stage"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.get_stage"title="Link to this definition">¶</a></dt>
<dd><p>Get the current stage of an on-demand task.</p>
<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>
<spanclass="sig-name descname"><spanclass="pre">set_stage</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">key</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">category</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">stage</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.set_stage"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#evennia.scripts.ondemandhandler.OnDemandHandler.set_stage"title="Link 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>
<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>