mirror of
https://github.com/evennia/evennia.git
synced 2026-03-18 22:06:30 +01:00
656 lines
No EOL
48 KiB
HTML
656 lines
No EOL
48 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>evennia.scripts.ondemandhandler — Evennia latest documentation</title>
|
||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="evennia.scripts.scripthandler" href="evennia.scripts.scripthandler.html" />
|
||
<link rel="prev" title="evennia.scripts.monitorhandler" href="evennia.scripts.monitorhandler.html" />
|
||
</head><body>
|
||
|
||
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.scripthandler.html" title="evennia.scripts.scripthandler"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.monitorhandler.html" title="evennia.scripts.monitorhandler"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.scripts.html" accesskey="U">evennia.scripts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.scripts.ondemandhandler</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
|
||
<div class="documentwrapper">
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||
</a></p>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">evennia.scripts.ondemandhandler</a><ul>
|
||
<li><a class="reference internal" href="#usage">Usage</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.scripts.monitorhandler.html"
|
||
title="previous chapter">evennia.scripts.monitorhandler</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.scripts.scripthandler.html"
|
||
title="next chapter">evennia.scripts.scripthandler</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.scripts.ondemandhandler.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
<h3>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li><a href="evennia.scripts.ondemandhandler.html">latest (main branch)</a></li>
|
||
|
||
<li><a href="../4.x/index.html">v4.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../3.x/index.html">v3.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../2.x/index.html">v2.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../1.x/index.html">v1.0.0 branch (outdated)</a></li>
|
||
|
||
<li><a href="../0.x/index.html">v0.9.5 branch (outdated)</a></li>
|
||
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.scripts.ondemandhandler">
|
||
<span id="evennia-scripts-ondemandhandler"></span><h1>evennia.scripts.ondemandhandler<a class="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>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>
|
||
<ol class="arabic simple">
|
||
<li><dl class="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>
|
||
<ol class="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 <a href="#id1"><span class="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>
|
||
<section id="usage">
|
||
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">ON_DEMAND_HANDLER</span>
|
||
|
||
<span class="c1"># create a new on-demand task</span>
|
||
|
||
<span class="n">flower</span> <span class="o">=</span> <span class="n">create_object</span><span class="p">(</span><span class="n">Flower</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rose"</span><span class="p">)</span>
|
||
|
||
<span class="n">ON_DEMAND_HANDLER</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span>
|
||
<span class="n">flower</span><span class="p">,</span> <span class="n">category</span><span class="o">=</span><span class="s2">"flowering"</span><span class="p">,</span>
|
||
<span class="n">stages</span><span class="o">=</span><span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="s2">"seedling"</span><span class="p">,</span> <span class="mi">120</span><span class="p">:</span> <span class="s2">"sprouting"</span><span class="p">,</span>
|
||
<span class="mi">300</span><span class="p">:</span> <span class="s2">"blooming"</span><span class="p">,</span> <span class="mi">600</span><span class="p">:</span> <span class="s2">"wilted"</span><span class="p">,</span> <span class="mi">700</span><span class="p">:</span> <span class="s2">"dead"</span><span class="p">})</span>
|
||
|
||
<span class="c1"># later, when we want to check the state of the plant (e.g. in a command),</span>
|
||
|
||
<span class="n">state</span> <span class="o">=</span> <span class="n">ON_DEMAND_HANDLER</span><span class="o">.</span><span class="n">get_stage</span><span class="p">(</span><span class="s2">"flowering"</span><span class="p">,</span> <span class="n">last_checked</span><span class="o">=</span><span class="n">plant</span><span class="o">.</span><span class="n">planted_time</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<dl class="py class">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.scripts.ondemandhandler.</code><code class="sig-name descname">OnDemandTask</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span></em>, <em class="sig-param"><span class="n">stages</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">autostart</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>Stores information about an on-demand task.</p>
|
||
<p>Default property:
|
||
- <strong>default_stage_function (callable)</strong>: This is called if no stage function is given in the</p>
|
||
<blockquote>
|
||
<div><p>stages dict. This is meant for changing the task itself (such as restarting it). Actual
|
||
game code should be handled elsewhere, by checking this task. See the <strong>stagefunc_*</strong> static
|
||
methods for examples of how to manipulate the task when a stage is reached.</p>
|
||
</div></blockquote>
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.runtime">
|
||
<em class="property">static </em><code class="sig-name descname">runtime</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.runtime"><span class="viewcode-link">[source]</span></a><a class="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.
|
||
It’s a callable to allow easier unit testing.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_loop">
|
||
<em class="property">static </em><code class="sig-name descname">stagefunc_loop</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">task</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.stagefunc_loop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_loop" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Attach this to the last stage to have the task start over from
|
||
the beginning</p>
|
||
<p class="rubric">Example</p>
|
||
<p>stages = {0: “seedling”, 120: “flowering”, 300: “dead”, (“_loop”,
|
||
OnDemandTask.stagefunc_loop)}</p>
|
||
<p>Note that the “respawn” state will never actually be visible as a state to
|
||
the user, instead once it reaches this state, it will <em>immediately</em> loop
|
||
and the new looped state will be shown and returned to the user. So it
|
||
can an idea to mark that end state with a <strong>_</strong> just to indicate this fact.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_bounce">
|
||
<em class="property">static </em><code class="sig-name descname">stagefunc_bounce</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">task</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.stagefunc_bounce"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.stagefunc_bounce" title="Permalink 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
|
||
for the bounce to continue indefinitely.</p>
|
||
<p class="rubric">Example</p>
|
||
<dl class="simple">
|
||
<dt>stages = {0: (“cool”, OnDemandTask.stagefunc_bounce),</dt><dd><p>50: “lukewarm”,
|
||
150: “warm”,
|
||
300: “hot”,
|
||
300: (“HOT!”, OnDemandTask.stagefunc_bounce)}</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py attribute">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.default_stage_function">
|
||
<code class="sig-name descname">default_stage_function</code><em class="property"> = None</em><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.default_stage_function" title="Permalink to this definition">¶</a></dt>
|
||
<dd></dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span></em>, <em class="sig-param"><span class="n">stages</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">autostart</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="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>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Examples</p>
|
||
<dl>
|
||
<dt>stages = {0: “seedling”,</dt><dd><blockquote>
|
||
<div><p>120: “sprouting”,
|
||
300: “blooming”,
|
||
600: “wilted”,
|
||
700: “dead”</p>
|
||
</div></blockquote>
|
||
<p>}</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.check">
|
||
<code class="sig-name descname">check</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">autostart</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.check" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Check the current stage of the task and return the time-delta to the next stage.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Keyword Arguments</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>autostart</strong> (<em>bool</em><em>, </em><em>optional</em>) – If this is set, and the task has not been started yet,
|
||
it will be started by this check. This is mainly used internally.</p></li>
|
||
<li><p><strong>**kwargs</strong> – Will be passed to the stage function, if one is called.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>tuple</em> – A tuple (dt, stage) where <strong>dt</strong> is the time-delta (in seconds) since the test
|
||
started (or since it started its latest iteration). and <strong>stage</strong> is the name of the
|
||
current stage. If no stages are defined, <strong>stage</strong> will always be <strong>None</strong>. Use <strong>get_dt</strong> and
|
||
<strong>get_stage</strong> to get only one of these values.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.get_dt">
|
||
<code class="sig-name descname">get_dt</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.get_dt"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.get_dt" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get the time-delta since last check.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>int</em> – The time since the last check, or 0 if this is the first time the task is checked.
|
||
<a href="#id1"><span class="problematic" id="id2">**</span></a>kwargs: Will be passed to the stage function, if one is called.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.set_dt">
|
||
<code class="sig-name descname">set_dt</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dt</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.set_dt"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="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>
|
||
<p class="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>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.get_stage">
|
||
<code class="sig-name descname">get_stage</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.get_stage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandTask.get_stage" title="Permalink 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
|
||
still update the last_checked time.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>str or None</em> – The current stage of the task, or <strong>None</strong> if no stages are set.
|
||
<a href="#id3"><span class="problematic" id="id4">**</span></a>kwargs: Will be passed to the stage function, if one is called.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandTask.set_stage">
|
||
<code class="sig-name descname">set_stage</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">stage</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandTask.set_stage"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="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>
|
||
<p class="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>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.scripts.ondemandhandler.</code><code class="sig-name descname">OnDemandHandler</code><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>A singleton handler for managing on-demand state changes. Its main function is to persistently
|
||
track the time (in seconds) between a state change and the next. How you make use of this
|
||
information is up to your particular system.</p>
|
||
<p>Contrary to just using the <strong>time</strong> module, this will also account for server restarts.</p>
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.__init__"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.load">
|
||
<code class="sig-name descname">load</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.load"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.save">
|
||
<code class="sig-name descname">save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.save"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.add">
|
||
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">stages</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">autostart</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler.add" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Add a new on-demand task.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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
|
||
check and start the timer.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><p><em>OnDemandTask</em> –</p>
|
||
<dl class="simple">
|
||
<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
|
||
manually.</p>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.batch_add">
|
||
<code class="sig-name descname">batch_add</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">tasks</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.batch_add"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>*tasks</strong> (<a class="reference internal" href="#evennia.scripts.ondemandhandler.OnDemandTask" title="evennia.scripts.ondemandhandler.OnDemandTask"><em>OnDemandTask</em></a>) – A set of OnDemandTasks to add.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.remove">
|
||
<code class="sig-name descname">remove</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler.remove" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Remove an on-demand task.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>OnDemandTask or None</em> – The removed task, or <strong>None</strong> if no task was found.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.batch_remove">
|
||
<code class="sig-name descname">batch_remove</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">keys</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.batch_remove"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>*keys</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.all">
|
||
<code class="sig-name descname">all</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">all_on_none</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler.all" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get all on-demand tasks.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="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>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="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
|
||
manually.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.clear">
|
||
<code class="sig-name descname">clear</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">all_on_none</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.clear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler.clear" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Clear all on-demand tasks.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<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>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.get">
|
||
<code class="sig-name descname">get</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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
|
||
tasks with no category.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>OnDemandTask or None</em> – The task, or <strong>None</strong> if no task was found.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.get_dt">
|
||
<code class="sig-name descname">get_dt</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get_dt"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler.get_dt" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get the time-delta since the task started.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>int or None</em> – The time since the last check, or <strong>None</strong> if no task was found.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.set_dt">
|
||
<code class="sig-name descname">set_dt</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span></em>, <em class="sig-param"><span class="n">dt</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.set_dt"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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>
|
||
<p class="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>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.get_stage">
|
||
<code class="sig-name descname">get_stage</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.get_stage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.ondemandhandler.OnDemandHandler.get_stage" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get the current stage of an on-demand task.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>str or None</em> – The current stage of the task, or <strong>None</strong> if no task was found.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.ondemandhandler.OnDemandHandler.set_stage">
|
||
<code class="sig-name descname">set_stage</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span></em>, <em class="sig-param"><span class="n">category</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">stage</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/ondemandhandler.html#OnDemandHandler.set_stage"><span class="viewcode-link">[source]</span></a><a class="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>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>key</strong> (<em>str</em><em>, </em><em>callable</em><em>, </em><a class="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>
|
||
<p class="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>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.scripthandler.html" title="evennia.scripts.scripthandler"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.monitorhandler.html" title="evennia.scripts.monitorhandler"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia latest</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.scripts.html" >evennia.scripts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.scripts.ondemandhandler</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2024, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |