2020-07-14 00:21:00 +02:00
<!DOCTYPE html>
2020-10-15 01:31:30 +02:00
< html >
2020-07-14 00:21:00 +02:00
< head >
< meta charset = "utf-8" / >
2021-05-16 00:06:01 +02:00
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / > < meta name = "generator" content = "Docutils 0.17.1: http://docutils.sourceforge.net/" / >
2022-02-06 18:34:09 +00:00
< title > 10. Creating things — Evennia 1.0-dev documentation< / title >
2020-07-14 00:21:00 +02: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" / >
2020-10-19 22:46:24 +02:00
< link rel = "search" title = "Search" href = "../../../search.html" / >
2022-09-17 23:44:19 +00:00
< link rel = "next" title = "11. Searching for things" href = "Beginner-Tutorial-Searching-Things.html" / >
< link rel = "prev" title = "9. Parsing Command input" href = "Beginner-Tutorial-More-on-Commands.html" / >
2020-07-14 00:21:00 +02:00
< / 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 >
2020-10-19 22:46:24 +02:00
< li class = "right" >
2022-09-17 23:44:19 +00:00
< a href = "Beginner-Tutorial-Searching-Things.html" title = "11. Searching for things"
2020-10-19 22:46:24 +02:00
accesskey="N">next< / a > |< / li >
< li class = "right" >
2022-09-17 23:44:19 +00:00
< a href = "Beginner-Tutorial-More-on-Commands.html" title = "9. Parsing Command input"
2020-10-19 22:46:24 +02:00
accesskey="P">previous< / a > |< / li >
2020-10-15 01:31:30 +02:00
< li class = "nav-item nav-item-0" > < a href = "../../../index.html" > Evennia 1.0-dev< / a > » < / li >
2022-02-06 18:34:09 +00:00
< li class = "nav-item nav-item-1" > < a href = "../../Howtos-Overview.html" > Tutorials and Howto’ s< / a > » < / li >
< li class = "nav-item nav-item-2" > < a href = "../Beginner-Tutorial-Intro.html" > Beginner Tutorial< / a > » < / li >
< li class = "nav-item nav-item-3" > < a href = "Beginner-Tutorial-Part1-Intro.html" accesskey = "U" > Part 1: What we have< / a > » < / li >
< li class = "nav-item nav-item-this" > < a href = "" > < span class = "section-number" > 10. < / span > Creating things< / a > < / li >
2020-07-14 00:21:00 +02:00
< / ul >
2021-06-23 18:58:26 +02:00
< div class = "develop" > develop branch< / div >
2020-07-14 00:21:00 +02:00
< / div >
< div class = "document" >
2022-10-23 09:04:07 +00:00
2020-07-14 00:21:00 +02:00
< div class = "documentwrapper" >
2022-10-23 09:04:07 +00:00
< 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 = "#" > 10. Creating things< / a > < ul >
< li > < a class = "reference internal" href = "#creating-objects" > 10.1. Creating Objects< / a > < / li >
< li > < a class = "reference internal" href = "#creating-accounts" > 10.2. Creating Accounts< / a > < / li >
< / ul >
< / li >
< / ul >
< h4 > Previous topic< / h4 >
< p class = "topless" > < a href = "Beginner-Tutorial-More-on-Commands.html"
title="previous chapter">< span class = "section-number" > 9. < / span > Parsing Command input< / a > < / p >
< h4 > Next topic< / h4 >
< p class = "topless" > < a href = "Beginner-Tutorial-Searching-Things.html"
title="next chapter">< span class = "section-number" > 11. < / span > Searching for things< / a > < / p >
< div role = "note" aria-label = "source link" >
<!-- h3>This Page</h3 -->
< ul class = "this-page-menu" >
< li > < a href = "../../../_sources/Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Creating-Things.md.txt"
rel="nofollow">Show Page Source< / a > < / li >
< / ul >
< / div > < h3 > Links< / h3 >
< ul >
< li > < a href = "https://www.evennia.com" > Home page< / a > < / li >
< li > < a href = "https://github.com/evennia/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 > Versions< / h3 >
< ul >
< li > < a href = "Beginner-Tutorial-Creating-Things.html" > 1.0-dev (develop branch)< / a > < / li >
< li > < a href = "../../../../0.9.5/index.html" > 0.9.5 (v0.9.5 branch)< / a > < / li >
< / ul >
< / div >
< / div >
2020-07-14 00:21:00 +02:00
< div class = "bodywrapper" >
< div class = "body" role = "main" >
2021-10-26 21:41:11 +02:00
< section class = "tex2jax_ignore mathjax_ignore" id = "creating-things" >
2022-02-06 18:34:09 +00:00
< h1 > < span class = "section-number" > 10. < / span > Creating things< a class = "headerlink" href = "#creating-things" title = "Permalink to this headline" > ¶< / a > < / h1 >
2020-07-14 00:21:00 +02:00
< p > We have already created some things - dragons for example. There are many different things to create
in Evennia though. In the last lesson we learned about typeclasses, the way to make objects persistent in the database.< / p >
< p > Given the path to a Typeclass, there are three ways to create an instance of it:< / p >
< ul >
< li > < p > Firstly, you can call the class directly, and then < code class = "docutils literal notranslate" > < span class = "pre" > .save()< / span > < / code > it:< / p >
2021-10-26 21:41:11 +02:00
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > obj = SomeTypeClass(db_key=...)
obj.save()
2020-07-14 00:21:00 +02:00
< / pre > < / div >
< / div >
< p > This has the drawback of being two operations; you must also import the class and have to pass
the actual database field names, such as < code class = "docutils literal notranslate" > < span class = "pre" > db_key< / span > < / code > instead of < code class = "docutils literal notranslate" > < span class = "pre" > key< / span > < / code > as keyword arguments.< / p >
< / li >
< li > < p > Secondly you can use the Evennia creation helpers:< / p >
2021-10-26 21:41:11 +02:00
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > obj = evennia.create_object(SomeTypeClass, key=...)
2020-07-14 00:21:00 +02:00
< / pre > < / div >
< / div >
< p > This is the recommended way if you are trying to create things in Python. The first argument can either be
the class < em > or< / em > the python-path to the typeclass, like < code class = "docutils literal notranslate" > < span class = "pre" > " path.to.SomeTypeClass" < / span > < / code > . It can also be < code class = "docutils literal notranslate" > < span class = "pre" > None< / span > < / code > in which
case the Evennia default will be used. While all the creation methods
2021-10-26 21:41:11 +02:00
are available on < code class = "docutils literal notranslate" > < span class = "pre" > evennia< / span > < / code > , they are actually implemented in < a class = "reference internal" href = "../../../api/evennia.utils.create.html" > < span class = "doc std std-doc" > evennia/utils/create.py< / span > < / a > .< / p >
2020-07-14 00:21:00 +02:00
< / li >
< li > < p > Finally, you can create objects using an in-game command, such as< / p >
2021-10-26 21:41:11 +02:00
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > create/drop obj:path.to.SomeTypeClass
2020-07-14 00:21:00 +02:00
< / pre > < / div >
< / div >
< p > As a developer you are usually best off using the two other methods, but a command is usually the only way
to let regular players or builders without Python-access help build the game world.< / p >
< / li >
< / ul >
2021-05-16 00:06:01 +02:00
< section id = "creating-objects" >
2022-02-06 18:34:09 +00:00
< h2 > < span class = "section-number" > 10.1. < / span > Creating Objects< a class = "headerlink" href = "#creating-objects" title = "Permalink to this headline" > ¶< / a > < / h2 >
2020-07-14 00:21:00 +02:00
< p > This is one of the most common creation-types. These are entities that inherits from < code class = "docutils literal notranslate" > < span class = "pre" > DefaultObject< / span > < / code > at any distance.
They have an existence in the game world and includes rooms, characters, exits, weapons, flower pots and castles.< / p >
2021-10-26 21:41:11 +02:00
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > > py
> import evennia
> rose = evennia.create_object(key=" rose" )
2020-07-14 00:21:00 +02:00
< / pre > < / div >
< / div >
< p > Since we didn’ t specify the < code class = "docutils literal notranslate" > < span class = "pre" > typeclass< / span > < / code > as the first argument, the default given by < code class = "docutils literal notranslate" > < span class = "pre" > settings.BASE_OBJECT_TYPECLASS< / span > < / code >
(< code class = "docutils literal notranslate" > < span class = "pre" > typeclasses.objects.Object< / span > < / code > ) will be used.< / p >
2021-05-16 00:06:01 +02:00
< / section >
< section id = "creating-accounts" >
2022-02-06 18:34:09 +00:00
< h2 > < span class = "section-number" > 10.2. < / span > Creating Accounts< a class = "headerlink" href = "#creating-accounts" title = "Permalink to this headline" > ¶< / a > < / h2 >
2020-07-14 00:21:00 +02:00
< p > An < em > Account< / em > is an out-of-character (OOC) entity, with no existence in the game world.
You can find the parent class for Accounts in < code class = "docutils literal notranslate" > < span class = "pre" > typeclasses/accounts.py< / span > < / code > .< / p >
< p > < em > TODO< / em > < / p >
2021-05-16 00:06:01 +02:00
< / section >
< / section >
2020-07-14 00:21:00 +02:00
< / 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 >
2020-10-19 22:46:24 +02:00
< li class = "right" >
2022-09-17 23:44:19 +00:00
< a href = "Beginner-Tutorial-Searching-Things.html" title = "11. Searching for things"
2020-10-19 22:46:24 +02:00
>next< / a > |< / li >
< li class = "right" >
2022-09-17 23:44:19 +00:00
< a href = "Beginner-Tutorial-More-on-Commands.html" title = "9. Parsing Command input"
2020-10-19 22:46:24 +02:00
>previous< / a > |< / li >
2020-10-15 01:31:30 +02:00
< li class = "nav-item nav-item-0" > < a href = "../../../index.html" > Evennia 1.0-dev< / a > » < / li >
2022-02-06 18:34:09 +00:00
< li class = "nav-item nav-item-1" > < a href = "../../Howtos-Overview.html" > Tutorials and Howto’ s< / a > » < / li >
< li class = "nav-item nav-item-2" > < a href = "../Beginner-Tutorial-Intro.html" > Beginner Tutorial< / a > » < / li >
< li class = "nav-item nav-item-3" > < a href = "Beginner-Tutorial-Part1-Intro.html" > Part 1: What we have< / a > » < / li >
< li class = "nav-item nav-item-this" > < a href = "" > < span class = "section-number" > 10. < / span > Creating things< / a > < / li >
2020-07-14 00:21:00 +02:00
< / ul >
2021-06-23 18:58:26 +02:00
< div class = "develop" > develop branch< / div >
2020-07-14 00:21:00 +02:00
< / div >
< div class = "footer" role = "contentinfo" >
© Copyright 2020, The Evennia developer community.
2020-10-15 01:31:30 +02:00
Created using < a href = "https://www.sphinx-doc.org/" > Sphinx< / a > 3.2.1.
2020-07-14 00:21:00 +02:00
< / div >
< / body >
< / html >