2022-11-14 22:43:45 +01:00
<!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/" / >
2023-10-19 20:22:27 +00:00
< title > Wilderness system — Evennia 2.x documentation< / title >
2022-11-14 22:43:45 +01:00
< 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 = "XYZgrid" href = "Contrib-XYZGrid.html" / >
< link rel = "prev" title = "Slow Exit" href = "Contrib-Slow-Exit.html" / >
< / head > < body >
2023-10-19 20:22:27 +00:00
2022-11-14 22:43:45 +01:00
< 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 = "Contrib-XYZGrid.html" title = "XYZgrid"
accesskey="N">next< / a > |< / li >
< li class = "right" >
< a href = "Contrib-Slow-Exit.html" title = "Slow Exit"
accesskey="P">previous< / a > |< / li >
2023-10-19 20:22:27 +00:00
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Evennia 2.x< / a > » < / li >
2022-11-14 22:43:45 +01:00
< li class = "nav-item nav-item-1" > < a href = "Contribs-Overview.html" accesskey = "U" > Contribs< / a > » < / li >
< li class = "nav-item nav-item-this" > < a href = "" > Wilderness system< / a > < / li >
< / ul >
2023-06-10 08:53:19 +00:00
< / div >
2022-11-14 22:43:45 +01:00
< 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 = "#" > Wilderness system< / a > < ul >
< li > < a class = "reference internal" href = "#installation" > Installation< / a > < / li >
< li > < a class = "reference internal" href = "#usage" > Usage< / a > < / li >
< li > < a class = "reference internal" href = "#customisation" > Customisation< / a > < / li >
< li > < a class = "reference internal" href = "#example" > Example< / a > < / li >
< li > < a class = "reference internal" href = "#implementation-details" > Implementation details< / a > < / li >
< / ul >
< / li >
< / ul >
< h4 > Previous topic< / h4 >
< p class = "topless" > < a href = "Contrib-Slow-Exit.html"
title="previous chapter">Slow Exit< / a > < / p >
< h4 > Next topic< / h4 >
< p class = "topless" > < a href = "Contrib-XYZGrid.html"
title="next chapter">XYZgrid< / a > < / p >
< div role = "note" aria-label = "source link" >
<!-- h3>This Page</h3 -->
< ul class = "this-page-menu" >
< li > < a href = "../_sources/Contribs/Contrib-Wilderness.md.txt"
rel="nofollow">Show Page Source< / a > < / li >
< / ul >
< / div > < h3 > Links< / h3 >
< ul >
2023-10-19 20:22:27 +00:00
< 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 >
2022-11-14 22:43:45 +01:00
< 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 >
2023-10-19 20:22:27 +00:00
< h3 > Doc Versions< / h3 >
2022-11-14 22:43:45 +01:00
< ul >
2023-10-19 20:22:27 +00:00
< li > < a href = "Contrib-Wilderness.html" > 2.x (main branch)< / a > < / li >
2022-11-15 20:29:38 +00:00
< ul >
2023-10-19 20:22:27 +00:00
< li > < a href = "../1.3.0/index.html" > 1.3.0 (v1.3.0 branch)< / a > < / li >
< li > < a href = "../0.9.5/index.html" > 0.9.5 (v0.9.5 branch)< / a > < / li >
2022-11-15 20:29:38 +00:00
2022-11-14 22:43:45 +01:00
< / ul >
< / div >
< / div >
< div class = "bodywrapper" >
< div class = "body" role = "main" >
< section class = "tex2jax_ignore mathjax_ignore" id = "wilderness-system" >
< h1 > Wilderness system< a class = "headerlink" href = "#wilderness-system" title = "Permalink to this headline" > ¶< / a > < / h1 >
< p > Contribution by titeuf87, 2017< / p >
< p > This contrib provides a wilderness map without actually creating a large number
of rooms - as you move, you instead end up back in the same room but its description
changes. This means you can make huge areas with little database use as
2022-11-25 10:59:06 +00:00
long as the rooms are relatively similar (e.g. only the names/descs changing).< / p >
2022-11-14 22:43:45 +01:00
< section id = "installation" >
< h2 > Installation< a class = "headerlink" href = "#installation" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > This contrib does not provide any new commands. Instead the default < code class = "docutils literal notranslate" > < span class = "pre" > py< / span > < / code > command
is used to call functions/classes in this contrib directly.< / p >
< / section >
< section id = "usage" >
< h2 > Usage< a class = "headerlink" href = "#usage" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > A wilderness map needs to created first. There can be different maps, all
with their own name. If no name is provided, then a default one is used. Internally,
the wilderness is stored as a Script with the name you specify. If you don’ t
specify the name, a script named “default” will be created and used.< / p >
2023-10-19 20:22:27 +00:00
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > py from evennia.contrib.grid import wilderness; wilderness.create_wilderness()
2022-11-14 22:43:45 +01:00
< / pre > < / div >
< / div >
< p > Once created, it is possible to move into that wilderness map:< / p >
2023-10-19 20:22:27 +00:00
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > py from evennia.contrib.grid import wilderness; wilderness.enter_wilderness(me)
2022-11-14 22:43:45 +01:00
< / pre > < / div >
< / div >
< p > All coordinates used by the wilderness map are in the format of < code class = "docutils literal notranslate" > < span class = "pre" > (x,< / span > < span class = "pre" > y)< / span > < / code >
tuples. x goes from left to right and y goes from bottom to top. So < code class = "docutils literal notranslate" > < span class = "pre" > (0,< / span > < span class = "pre" > 0)< / span > < / code >
is the bottom left corner of the map.< / p >
2022-11-25 10:59:06 +00:00
< blockquote >
< div > < p > You can also add a wilderness by defining a WildernessScript in your GLOBAL_SCRIPT
settings. If you do, make sure define the map provider.< / p >
< / div > < / blockquote >
2022-11-14 22:43:45 +01:00
< / section >
< section id = "customisation" >
< h2 > Customisation< a class = "headerlink" href = "#customisation" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > The defaults, while useable, are meant to be customised. When creating a
new wilderness map it is possible to give a “map provider”: this is a
python object that is smart enough to create the map.< / p >
< p > The default provider, < code class = "docutils literal notranslate" > < span class = "pre" > WildernessMapProvider< / span > < / code > , just creates a grid area that
2022-11-25 10:59:06 +00:00
is unlimited in size.< / p >
< p > < code class = "docutils literal notranslate" > < span class = "pre" > WildernessMapProvider< / span > < / code > can be subclassed to create more interesting
2022-11-14 22:43:45 +01:00
maps and also to customize the room/exit typeclass used.< / p >
2022-11-25 10:59:06 +00:00
< p > The < code class = "docutils literal notranslate" > < span class = "pre" > WildernessScript< / span > < / code > also has an optional < code class = "docutils literal notranslate" > < span class = "pre" > preserve_items< / span > < / code > property, which
when set to < code class = "docutils literal notranslate" > < span class = "pre" > True< / span > < / code > will not recycle rooms that contain any objects. By default,
a wilderness room is recycled whenever there are no players left in it.< / p >
2022-11-14 22:43:45 +01:00
< p > There is also no command that allows players to enter the wilderness. This
still needs to be added: it can be a command or an exit, depending on your
needs.< / p >
< / section >
< section id = "example" >
< h2 > Example< a class = "headerlink" href = "#example" title = "Permalink to this headline" > ¶< / a > < / h2 >
< p > To give an example of how to customize, we will create a very simple (and
small) wilderness map that is shaped like a pyramid. The map will be
provided as a string: a “.” symbol is a location we can walk on.< / p >
< p > Let’ s create a file < code class = "docutils literal notranslate" > < span class = "pre" > world/pyramid.py< / span > < / code > :< / p >
< div class = "highlight-python notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "c1" > # mygame/world/pyramid.py< / span >
< span class = "n" > map_str< / span > < span class = "o" > =< / span > < span class = "s1" > ' ' ' < / span >
< span class = "s1" > .< / span >
< span class = "s1" > ...< / span >
< span class = "s1" > .....< / span >
< span class = "s1" > .......< / span >
< span class = "s1" > ' ' ' < / span >
< span class = "kn" > from< / span > < span class = "nn" > evennia.contrib.grid< / span > < span class = "kn" > import< / span > < span class = "n" > wilderness< / span >
< span class = "k" > class< / span > < span class = "nc" > PyramidMapProvider< / span > < span class = "p" > (< / span > < span class = "n" > wilderness< / span > < span class = "o" > .< / span > < span class = "n" > WildernessMapProvider< / span > < span class = "p" > ):< / span >
< span class = "k" > def< / span > < span class = "nf" > is_valid_coordinates< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > wilderness< / span > < span class = "p" > ,< / span > < span class = "n" > coordinates< / span > < span class = "p" > ):< / span >
< span class = "s2" > " Validates if these coordinates are inside the map" < / span >
< span class = "n" > x< / span > < span class = "p" > ,< / span > < span class = "n" > y< / span > < span class = "o" > =< / span > < span class = "n" > coordinates< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > lines< / span > < span class = "o" > =< / span > < span class = "n" > map_str< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s2" > " < / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "p" > )< / span >
< span class = "c1" > # The reverse is needed because otherwise the pyramid will be< / span >
< span class = "c1" > # upside down< / span >
< span class = "n" > lines< / span > < span class = "o" > .< / span > < span class = "n" > reverse< / span > < span class = "p" > ()< / span >
< span class = "n" > line< / span > < span class = "o" > =< / span > < span class = "n" > lines< / span > < span class = "p" > [< / span > < span class = "n" > y< / span > < span class = "p" > ]< / span >
< span class = "n" > column< / span > < span class = "o" > =< / span > < span class = "n" > line< / span > < span class = "p" > [< / span > < span class = "n" > x< / span > < span class = "p" > ]< / span >
< span class = "k" > return< / span > < span class = "n" > column< / span > < span class = "o" > ==< / span > < span class = "s2" > " ." < / span >
< span class = "k" > except< / span > < span class = "ne" > IndexError< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "kc" > False< / span >
< span class = "k" > def< / span > < span class = "nf" > get_location_name< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > coordinates< / span > < span class = "p" > ):< / span >
< span class = "s2" > " Set the location name" < / span >
< span class = "n" > x< / span > < span class = "p" > ,< / span > < span class = "n" > y< / span > < span class = "o" > =< / span > < span class = "n" > coordinates< / span >
< span class = "k" > if< / span > < span class = "n" > y< / span > < span class = "o" > ==< / span > < span class = "mi" > 3< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "s2" > " Atop the pyramid." < / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "s2" > " Inside a pyramid." < / span >
< span class = "k" > def< / span > < span class = "nf" > at_prepare_room< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > coordinates< / span > < span class = "p" > ,< / span > < span class = "n" > caller< / span > < span class = "p" > ,< / span > < span class = "n" > room< / span > < span class = "p" > ):< / span >
< span class = "s2" > " Any other changes done to the room before showing it" < / span >
< span class = "n" > x< / span > < span class = "p" > ,< / span > < span class = "n" > y< / span > < span class = "o" > =< / span > < span class = "n" > coordinates< / span >
< span class = "n" > desc< / span > < span class = "o" > =< / span > < span class = "s2" > " This is a room in the pyramid." < / span >
< span class = "k" > if< / span > < span class = "n" > y< / span > < span class = "o" > ==< / span > < span class = "mi" > 3< / span > < span class = "p" > :< / span >
< span class = "n" > desc< / span > < span class = "o" > =< / span > < span class = "s2" > " You can see far and wide from the top of the pyramid." < / span >
2023-10-19 20:22:27 +00:00
< span class = "n" > room< / span > < span class = "o" > .< / span > < span class = "n" > ndb< / span > < span class = "o" > .< / span > < span class = "n" > active_desc< / span > < span class = "o" > =< / span > < span class = "n" > desc< / span >
2022-11-14 22:43:45 +01:00
< / pre > < / div >
< / div >
2023-10-19 20:22:27 +00:00
< p > Note that the currently active description is stored as < code class = "docutils literal notranslate" > < span class = "pre" > .ndb.active_desc< / span > < / code > . When
looking at the room, this is what will be pulled and shown.< / p >
< blockquote >
< div > < p > Exits on a room are always present, but locks hide those not used for a
location. So make sure to < code class = "docutils literal notranslate" > < span class = "pre" > quell< / span > < / code > if you are a superuser (since the superuser ignores
locks, those exits will otherwise not be hidden)< / p >
< / div > < / blockquote >
2022-11-14 22:43:45 +01:00
< p > Now we can use our new pyramid-shaped wilderness map. From inside Evennia we
create a new wilderness (with the name “default”) but using our new map provider:< / p >
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > py from world import pyramid as p; p.wilderness.create_wilderness(mapprovider=p.PyramidMapProvider())
2023-10-19 20:22:27 +00:00
py from evennia.contrib.grid import wilderness; wilderness.enter_wilderness(me, coordinates=(4, 1))
2022-11-14 22:43:45 +01:00
< / pre > < / div >
< / div >
< / section >
< section id = "implementation-details" >
< h2 > Implementation details< a class = "headerlink" href = "#implementation-details" title = "Permalink to this headline" > ¶< / a > < / h2 >
2022-11-25 10:59:06 +00:00
< p > When a character moves into the wilderness, they get their own room. If
they move, instead of moving the character, the room changes to match the
new coordinates.< / p >
< p > If a character meets another character in the wilderness, then their room
merges. When one of the character leaves again, they each get their own
separate rooms.< / p >
< p > Rooms are created as needed. Unneeded rooms are stored away to avoid the
overhead cost of creating new rooms again in the future.< / p >
2022-11-14 22:43:45 +01:00
< hr class = "docutils" / >
< p > < small > This document page is generated from < code class = "docutils literal notranslate" > < span class = "pre" > evennia/contrib/grid/wilderness/README.md< / span > < / code > . Changes to this
file will be overwritten, so edit that file rather than this one.< / small > < / p >
< / 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 = "Contrib-XYZGrid.html" title = "XYZgrid"
>next< / a > |< / li >
< li class = "right" >
< a href = "Contrib-Slow-Exit.html" title = "Slow Exit"
>previous< / a > |< / li >
2023-10-19 20:22:27 +00:00
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Evennia 2.x< / a > » < / li >
2022-11-14 22:43:45 +01:00
< li class = "nav-item nav-item-1" > < a href = "Contribs-Overview.html" > Contribs< / a > » < / li >
< li class = "nav-item nav-item-this" > < a href = "" > Wilderness system< / a > < / li >
< / ul >
< / div >
2023-10-19 20:22:27 +00:00
2022-11-14 22:43:45 +01:00
< div class = "footer" role = "contentinfo" >
2023-10-19 20:22:27 +00:00
© Copyright 2023, The Evennia developer community.
2022-11-14 22:43:45 +01:00
Created using < a href = "https://www.sphinx-doc.org/" > Sphinx< / a > 3.2.1.
< / div >
< / body >
< / html >