Build devblog

This commit is contained in:
Griatch 2022-07-05 20:44:03 +02:00
parent f060ffdc7c
commit ff0679fbdd
12 changed files with 280 additions and 42 deletions

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>
@ -877,7 +883,7 @@
<p>Next I added one new migration in the Account app - this is the migration that copies the data from the player to the equivalent account-named copies in the database. Since Player will not exist if you run this from scratch you have to make sure that the Player model exists at that point in the migration chain. You can't just do this with a normal import and traceback, you need to use the migration infrastructure. This kind of check works:</p>
</li>
</ul>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>  <span style="color: #408080; font-style: italic"># ... </span>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>  <span style="color: #3D7B7B; font-style: italic"># ... </span>
@ -887,19 +893,19 @@
        PlayerDB <span style="color: #666666">=</span> apps<span style="color: #666666">.</span>get_model(<span style="color: #BA2121">&quot;players&quot;</span>, <span style="color: #BA2121">&quot;PlayerDB&quot;</span>)
    <span style="color: #008000; font-weight: bold">except</span> <span style="color: #D2413A; font-weight: bold">LookupError</span>:
    <span style="color: #008000; font-weight: bold">except</span> <span style="color: #CB3F38; font-weight: bold">LookupError</span>:
        <span style="color: #008000; font-weight: bold">return</span>
    <span style="color: #408080; font-style: italic"># copy data from player-tables to database tables here </span>
    <span style="color: #3D7B7B; font-style: italic"># copy data from player-tables to database tables here </span>
 <span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">Migrations</span>(migrations<span style="color: #666666">.</span>Migration):
    <span style="color: #408080; font-style: italic"># ... </span>
    <span style="color: #3D7B7B; font-style: italic"># ... </span>
    operations <span style="color: #666666">=</span> [
@ -923,7 +929,7 @@
    <span style="color: #408080; font-style: italic"># ... </span>
    <span style="color: #3D7B7B; font-style: italic"># ... </span>
@ -931,9 +937,9 @@
    <span style="color: #BA2121">&quot;Returns bool if table exists or not&quot;</span>
    sql_check_exists <span style="color: #666666">=</span> <span style="color: #BA2121">&quot;SELECT * from </span><span style="color: #BB6688; font-weight: bold">%s</span><span style="color: #BA2121">;&quot;</span> <span style="color: #666666">%</span> tablename
    sql_check_exists <span style="color: #666666">=</span> <span style="color: #BA2121">&quot;SELECT * from </span><span style="color: #A45A77; font-weight: bold">%s</span><span style="color: #BA2121">;&quot;</span> <span style="color: #666666">%</span> tablename
    <span style="color: #408080; font-style: italic">### [Renaming Django&#39;s Auth User and App](https://evennia.blogspot.com/2017/08/renaming-djangos-auth-user-and-app.html)</span>
    <span style="color: #3D7B7B; font-style: italic">### [Renaming Django&#39;s Auth User and App](https://evennia.blogspot.com/2017/08/renaming-djangos-auth-user-and-app.html)</span>
</pre></div>
<p><a href="https://4.bp.blogspot.com/-DRHk1mmLB0Y/WaCUd8tmYbI/AAAAAAAAHaU/QXkryhYVJBIVWPykT08nSokCHfFc6-2LACLcBGAs/s1600/birds-1976981_640.jpg"><img src="https://4.bp.blogspot.com/-DRHk1mmLB0Y/WaCUd8tmYbI/AAAAAAAAHaU/QXkryhYVJBIVWPykT08nSokCHfFc6-2LACLcBGAs/s400/birds-1976981_640.jpg" alt="" /></a></p>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>
@ -757,7 +763,7 @@ This is a brass key.
objects<span style="color: #666666">.</span>Movable):
<span style="color: #408080; font-style: italic"># ... </span>
<span style="color: #3D7B7B; font-style: italic"># ... </span>
</pre></div>
<p>This class will offer actions to open, insert a code and move the object around. It will need some more configuration and addition of messages to show etc. But overall, this method-to-command solution ended up being very stable and extremely easy to use to make complex, interactive objects.</p>
@ -765,7 +771,7 @@ This is a brass key.
<p>I think of the escape room as going through a series of <em>states</em>. A change of state could for example be that the user solved a puzzle to open a secret wall. That wall is now open, making new items and puzzles available. This means room description should change along with new objects being created or old ones deleted.</p>
<p>I chose to represent states as Python modules in a folder. To be a state, each module needs to have a global-level class <strong>State</strong> inheriting from my new <strong>BaseState</strong> class. This class has methods for initializing and cleaning up the state, as well as was for figuring out which state to go to next. As the system initializes the new state, it gets the current room as argument, so it can modify it.</p>
<p>This is a (simplified) example of a state module:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># module `state_001_start.py` </span>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #3D7B7B; font-style: italic"># module `state_001_start.py` </span>
@ -789,9 +795,9 @@ MUG_DESC <span style="color: #666666">=</span> <span style="color: #BA2121">&quo
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">at_focus_drink</span>(<span style="color: #008000">self</span>, caller, <span style="color: #666666">**</span>kwargs):
caller<span style="color: #666666">.</span>msg(<span style="color: #BA2121">f&quot;You drink </span><span style="color: #BB6688; font-weight: bold">{</span><span style="color: #008000">self</span><span style="color: #666666">.</span>key<span style="color: #BB6688; font-weight: bold">}</span><span style="color: #BA2121">.&quot;</span>)
caller<span style="color: #666666">.</span>msg(<span style="color: #BA2121">f&quot;You drink </span><span style="color: #A45A77; font-weight: bold">{</span><span style="color: #008000">self</span><span style="color: #666666">.</span>key<span style="color: #A45A77; font-weight: bold">}</span><span style="color: #BA2121">.&quot;</span>)
<span style="color: #008000">self</span><span style="color: #666666">.</span>next_state() <span style="color: #408080; font-style: italic"># trigger next state </span>
<span style="color: #008000">self</span><span style="color: #666666">.</span>next_state() <span style="color: #3D7B7B; font-style: italic"># trigger next state </span>
@ -1074,7 +1080,7 @@ MUG_DESC <span style="color: #666666">=</span> <span style="color: #BA2121">&quo
<p>A new year has come around and it's time to both look back at the old and onward to the future of <a href="https://www.evennia.com/">Evennia</a>, the Python MUD creation system!</p>
<h4>Last year</h4>
<p><a href="https://2.bp.blogspot.com/-BKHBV0L443U/W7EgLdZIQmI/AAAAAAAAJZs/CpmGtCk6U_QyoXGIEyQbIPBUmAbPbOgawCPcBGAYYCw/s1600/Screenshot%2Bfrom%2B2018-09-30%2B21-09-55.png"><img src="https://2.bp.blogspot.com/-BKHBV0L443U/W7EgLdZIQmI/AAAAAAAAJZs/CpmGtCk6U_QyoXGIEyQbIPBUmAbPbOgawCPcBGAYYCw/s320/Screenshot%2Bfrom%2B2018-09-30%2B21-09-55.png" alt="" /></a></p>
<p>Last year saw the release of <a href="https://www.blogger.com/blogger.g?blogID=8338260444057832583#editor/target=post%3BpostID=7101674864552615043%3BonPublishedMenu=allposts%3BonClosedMenu=allposts%3BpostNum=2%3Bsrc=postname">Evennia 0.8</a>. This version of Evennia changes some fundamental aspects of the server infrastructure so that the server can truly run in daemon mode as you would expect (no more running it in a GnuScreen session if you want to see logging to the terminal). It also adds the new Online Creation System, which lets builders create and define prototypes using a menu system as well as big improvements in the web client, such as multiple window-panes (allows the user to assign text to different windows to keep their client uncluttered) as well as plenty of fixes and features to help ease life for the Evennia developer. Thanks again to everyone who helped out and contributed to the release of Evennia 0.8!</p>
<p>Last year saw the release of <a href="https://www.blogger.com/blogger.g?blogID=8338260444057832583#editor/target=post;postID=7101674864552615043;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=2;src=postname">Evennia 0.8</a>. This version of Evennia changes some fundamental aspects of the server infrastructure so that the server can truly run in daemon mode as you would expect (no more running it in a GnuScreen session if you want to see logging to the terminal). It also adds the new Online Creation System, which lets builders create and define prototypes using a menu system as well as big improvements in the web client, such as multiple window-panes (allows the user to assign text to different windows to keep their client uncluttered) as well as plenty of fixes and features to help ease life for the Evennia developer. Thanks again to everyone who helped out and contributed to the release of Evennia 0.8!</p>
<p>On a personal note, I spoke about Evennia at PyCon Sweden this December, which was fun. I might put up my talk and make a more detailed blog post about that in the future, but my talk got a surprising amount of attention and positive feedback. Clearly many people have fond memories of MUDs and enjoy seeing they are not only still around but are possible to create in Python!</p>
<h4>This year</h4>
<p><a href="https://1.bp.blogspot.com/-zNtXFGrN344/XC0MhJjWzcI/AAAAAAAAJ1M/UDd_QQRYuh8GNuXefblRIh6qfcDB9784QCLcBGAs/s1600/61SA0Wq1P1L.png"><img src="https://1.bp.blogspot.com/-zNtXFGrN344/XC0MhJjWzcI/AAAAAAAAJ1M/UDd_QQRYuh8GNuXefblRIh6qfcDB9784QCLcBGAs/s200/61SA0Wq1P1L.png" alt="" /></a></p>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-closed">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>
@ -647,27 +653,27 @@ Here the blog starts...
<p>I wrote my own <code>build_devblog.py</code> program that simple reads all <code>.md</code> files from a directory. It figures out the date and title (from file name or meta-header) and runs <code>mistletoe</code> on it. I create a dataclass with all the post-relevant properties on it. So far so good. Now we need to inject this into an HTML structure.</p>
<h3>The html</h3>
<p>Next I prepared a little <code>post.html</code> Jinja template:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>&lt;h1 id=<span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.anchor</span> <span style="color: #BC7A00">}}</span>&gt;
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>&lt;h1 id=<span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.anchor</span> <span style="color: #9C6500">}}</span>&gt;
<span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.title</span> <span style="color: #BC7A00">}}</span>
<span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.title</span> <span style="color: #9C6500">}}</span>
&lt;a class=&quot;devblog-headerlink&quot; href=&quot;<span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.permalink</span> <span style="color: #BC7A00">}}</span>&quot; title=&quot;Permalink to this blog post&quot;&gt;&lt;/a&gt;
&lt;a class=&quot;devblog-headerlink&quot; href=&quot;<span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.permalink</span> <span style="color: #9C6500">}}</span>&quot; title=&quot;Permalink to this blog post&quot;&gt;&lt;/a&gt;
&lt;div class=&quot;devblog-title-date&quot;&gt;- <span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.date_pretty</span> <span style="color: #BC7A00">}}</span>&lt;/div&gt;
&lt;div class=&quot;devblog-title-date&quot;&gt;- <span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.date_pretty</span> <span style="color: #9C6500">}}</span>&lt;/div&gt;
&lt;/h1&gt;
<span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.html</span> <span style="color: #BC7A00">}}</span>
<span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.html</span> <span style="color: #9C6500">}}</span>
&lt;footer class=&quot;devblog-footer&quot;&gt;
&lt;span class=&quot;devblog-copyrights&quot;&gt;
<span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.image_copyrights</span> <span style="color: #BC7A00">}}</span>
<span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.image_copyrights</span> <span style="color: #9C6500">}}</span>
&lt;/span&gt;
&lt;a class=&quot;devblog-to-toplink&quot; href=&quot;<span style="color: #BC7A00">{{</span> <span style="color: #19177C">blogpost.permalink</span> <span style="color: #BC7A00">}}</span>&quot; title=&quot;Link to top of post&quot;&gt;⇬(top)&lt;/a&gt;
&lt;a class=&quot;devblog-to-toplink&quot; href=&quot;<span style="color: #9C6500">{{</span> <span style="color: #19177C">blogpost.permalink</span> <span style="color: #9C6500">}}</span>&quot; title=&quot;Link to top of post&quot;&gt;⇬(top)&lt;/a&gt;
&lt;/footer&gt;
</pre></div>

View file

@ -13,7 +13,7 @@
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="
Latest Evennia dev blog: Into 2022 with thanks and plans: <br>I didn't write an end-of-the year summary for 2021, so this first devblog of 2022 will also look back a bit at the past year. It also helps me get used to using this new blog platform I wrote about in the previous post. ...
Latest Evennia dev blog: Tutorial-writing and Attributes galore: It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time! ...
---
Evennia is a modern Python library and server for creating text-based
multi-player games and virtual worlds (also known as MUD, MUSH, MU,
@ -49,11 +49,17 @@
<ul>
<li>
<a href="2022.html"> 2022 (1)
<a href="2022.html"> 2022 (2)
<ul class="devblog-calendar-open">
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore">Jul 5
<span class="devblog-calendar-tooltip-text"> Tutorial-writing and Attributes galore</span>
</a>
</li>
<li class="devblog-calendar-post devblog-calendar-tooltip">
<a href="2022.html#2022-01-06-into-2022-with-thanks-and-plans">Jan 6
<span class="devblog-calendar-tooltip-text"> Into 2022 with thanks and plans</span>
@ -602,6 +608,178 @@
<div class="blog_post">
<h1 id=2022-07-05-tutorial-writing-and-attributes-galore>
Tutorial-writing and Attributes galore
<a class="devblog-headerlink" href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore" title="Permalink to this blog post"></a>
<div class="devblog-title-date">- July 5, 2022</div>
</h1>
<p><img src="images/tutorial.jpg" alt="Tutorial sign" /></p>
<p>It has been a while since I wrote anything for the dev blog of Evennia, the MU creation system - so it's about time!</p>
<p>It's been a busy spring and early summer for me, with lots of real-life work going on away from Evennia land. But that hasn't meant activity on the Evennia code base has slowed!</p>
<h2>Many eyes on Evennia 1.0-dev</h2>
<p>Earlier this year I <a href="https://github.com/evennia/evennia/discussions/2640">invited people to try the Evennia develop branch</a> - what will become Evennia 1.0. A lot of bold beta-testers have since swapped to using the 1.0 branch. While there are plenty of issues being reported, most seem pretty happy about it so far. As mentioned in earlier dev blogs, Evennia 1.0 has a <a href="https://github.com/evennia/evennia/blob/master/CHANGELOG.md">lot of improvements and new features</a>!</p>
<p>As part of this, the amount of PRs being made against develop branch has increased a lot, with awesome community members stepping up to fix bugs and even address long-standing annoyances. This includes everything from big improvements in ANSI parsing, fixes to the 1.0 FuncParser, RPSystem contrib optimizations and much more - <a href="https://github.com/evennia/evennia/pulls?page=2&amp;q=is%3Apr+is%3Aclosed">the list of closed PRs is long</a>.</p>
<p>Another big part are everyone helping to answer questions in chat and suggesting improvements to the community in general. Thanks everyone!</p>
<h2>The Upcoming beginner tutorial</h2>
<p>On my end, I'm working on the Beginner Tutorial for the new 1.0 documentation. This will be a multi-part tutorial where you get to make a little MUD game from scratch. It goes through the basics of Evennia all the way to releasing your little game and I hope it will help people get started. This will also lead to a new contrib - the <code>evadventure</code> package, which should (I plan) have everything the tutorial needs to run. This is useful for those that prefer picking apart existing code over reading about it.</p>
<p>The tutorial game itself is based on <a href="https://www.gmbinder.com/share/-LZGcbbCQaqjIV0TmLx3">Knave</a>, an light Old-School-Renaissance (OSR) tabletop roleplaying ruleset inspired by early editions Dungeons &amp; Dragons. It's simple enough to fit in a tutorial but with enough wrinkles to showcase how to create some basic rpg systems in Evennia:</p>
<ul>
<li>
<p>Using Attributes (STR, DEX etc)</p>
</li>
<li>
<p>Rules (dice rolls, advantage, contested rolls etc)</p>
</li>
<li>
<p>Character generation (Knave chargen is mostly random, but it still showcases Evennia's menu system EvMenu).</p>
</li>
<li>
<p>Inventory management and equipment (including limited storage as well as items worn or wielded).</p>
</li>
<li>
<p>Turn-based combat system (menu based)</p>
<ul>
<li>
<p>Attacking with wielded weapons (or spell rune)</p>
</li>
<li>
<p>Stunts to give you advantages for later turns or give enemies disadvantage for later turns</p>
</li>
<li>
<p>Using items for healing or other effects</p>
</li>
<li>
<p>Fleeing and chasing</p>
</li>
</ul>
</li>
<li>
<p>Alternative Twitch-based combat system (might be a stretch goal)</p>
</li>
<li>
<p>NPCs with very simple AI, Death and respawn</p>
</li>
<li>
<p>Simple Questing system with NPC quest givers and quest states</p>
</li>
<li>
<p>A small example world (tech-demo)</p>
</li>
</ul>
<p>I won't include how to make a Crafting system, since I've added a full <a href="https://www.evennia.com/docs/1.0-dev/Contribs/Contrib-Crafting.html">Crafting contrib</a> to Evennia 1.0 for devs to be inspired by or tear apart.</p>
<h2>Some nice new things about Attributes</h2>
<p>In general news, Evennia 1.0 will see two big improvements when it comes to <a href="https://www.evennia.com/docs/1.0-dev/Components/Attributes.html">Attributes</a>.</p>
<h3>AttributeProperty</h3>
<p>This is a new way to write - and particularly initialize - Attributes. Traditionally in Evennia you need to initialize your object's Attributes something like this:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">evennia</span> <span style="color: #008000; font-weight: bold">import</span> DefaultCharacter
<span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">Character</span>(DefaultCharacter):
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">at_object_creation</span>(<span style="color: #008000">self</span>):
<span style="color: #008000">self</span><span style="color: #666666">.</span>db<span style="color: #666666">.</span>strength <span style="color: #666666">=</span> <span style="color: #666666">10</span>
<span style="color: #008000">self</span><span style="color: #666666">.</span>db<span style="color: #666666">.</span>mana <span style="color: #666666">=</span> <span style="color: #666666">12</span>
</pre></div>
<p>This still works. But with the new <code>AttributeProperty</code> you can now write it like this instead:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">evennia</span> <span style="color: #008000; font-weight: bold">import</span> DefaultCharacter
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">evennia.typeclasses.attributes</span> <span style="color: #008000; font-weight: bold">import</span> AttributeProperty
<span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">Character</span>(DefaultCharacter):
strength <span style="color: #666666">=</span> AttributeProperty(<span style="color: #666666">10</span>)
mana <span style="color: #666666">=</span> AttributeProperty(<span style="color: #666666">10</span>)
</pre></div>
<p>This makes Attributes look more like Django fields, sitting directly on the class. They can also have <code>category</code> and all other values you'd expect. You can still access those Attributes like normal:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>strength <span style="color: #666666">=</span> char<span style="color: #666666">.</span>db<span style="color: #666666">.</span>strength
mana <span style="color: #666666">=</span> char<span style="color: #666666">.</span>attributes<span style="color: #666666">.</span>get(<span style="color: #BA2121">&quot;mana&quot;</span>)
</pre></div>
<p>But you can now also do just</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>strength <span style="color: #666666">=</span> char<span style="color: #666666">.</span>strength
mana <span style="color: #666666">=</span> char<span style="color: #666666">.</span>mana
</pre></div>
<p>directly (you'll need to be careful to not override any existing properties on objects this way of course).</p>
<p>An interesting feature of using an <code>AttributeProperty</code> is that you can choose to <em>not</em></p>
<p>actually create the <code>Attribute</code> under the hood unless the default changed:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">Character</span>(DefaultCharacter):
strength <span style="color: #666666">=</span> AttributeProperty(<span style="color: #666666">10</span>, autocreate<span style="color: #666666">=</span><span style="color: #008000; font-weight: bold">False</span>)
mana <span style="color: #666666">=</span> AttributeProperty(<span style="color: #666666">10</span>, autocreate<span style="color: #666666">=</span><span style="color: #008000; font-weight: bold">False</span>)
</pre></div>
<p>When you now access <code>char.stength</code> you will get <code>10</code> back but you won't actually be hitting the database to load anything - it's just giving you the default. Not until you <em>change</em> the default will the actual <code>Attribute</code> be created. While this can be very powerful for optimization, note that you can of course not access such data via <code>char.db</code> or <code>char.attributes.get</code> either (because no <code>Attribute</code> yet exists). So this functionality can be confusing unless you know what you are doing. Hence <code>autocreate</code> defaults to <code>True</code>.</p>
<h3>Saving Attributes with hidden database objects</h3>
<p>This is one of those classical quirks of Evennia that many have encountered. While Evennia can save a lot of things in an <code>Attribute</code>, including database objects, it cannot do so if it doesnt <em>know</em> those database objects are there. This is fine if you are saving a list or a dict with objects in it - Evennia will go through it and make sure to serialize each db-object in turn.</p>
<p>But if you &quot;hide away&quot; your db-object you will be in trouble:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">MyStore</span>:
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">__init__</span>(<span style="color: #008000">self</span>, dbobj):
<span style="color: #008000">self</span><span style="color: #666666">.</span>dbobj <span style="color: #666666">=</span> dbjobj
char <span style="color: #666666">=</span> Character<span style="color: #666666">.</span>objects<span style="color: #666666">.</span>get(<span style="color: #008000">id</span><span style="color: #666666">=1</span>)
obj<span style="color: #666666">.</span>db<span style="color: #666666">.</span>mystore <span style="color: #666666">=</span> MyStore(char) <span style="color: #3D7B7B; font-style: italic"># leads to Traceback!</span>
</pre></div>
<p>This fails because we store <code>char</code> inside <code>MyStore</code> and there is no way for Evennia to know it's there and to handle it properly.</p>
<p>For the longest time, this was just a limitation you had to accept. But with Evennia 1.0-dev you can now help Evennia out:</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">evennia.utils.dbserialize</span> <span style="color: #008000; font-weight: bold">import</span> dbserialize, dbunserialize
<span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">MyStore</span>:
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">__init__</span>(<span style="color: #008000">self</span>, dbobj):
<span style="color: #008000">self</span><span style="color: #666666">.</span>dbobj <span style="color: #666666">=</span> dbobj
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">__serialize_dbobjs__</span>(<span style="color: #008000">self</span>):
<span style="color: #008000">self</span><span style="color: #666666">.</span>dbobj <span style="color: #666666">=</span> dbserialize(<span style="color: #008000">self</span><span style="color: #666666">.</span>dbobj)
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">__deserialize_dbobjs__</span>(<span style="color: #008000">self</span>):
<span style="color: #008000">self</span><span style="color: #666666">.</span>dbobj <span style="color: #666666">=</span> dbunserialize(<span style="color: #008000">self</span><span style="color: #666666">.</span>dbobj)
char <span style="color: #666666">=</span> Character<span style="color: #666666">.</span>objects<span style="color: #666666">.</span>get(<span style="color: #008000">id</span><span style="color: #666666">=1</span>)
obj<span style="color: #666666">.</span>db<span style="color: #666666">.</span>mystore <span style="color: #666666">=</span> MyStore(char) <span style="color: #3D7B7B; font-style: italic"># now OK!</span>
</pre></div>
<p>With the new <code>__serialize_dbobjs__</code> and <code>__deserialize_dbobjs__</code>, Evennia is told how to properly stow away the db-object (using the tools from <code>evennia.utils</code>) before trying to serialize the entire <code>MyStore</code>. And later, when loading it up, Evennia is helped to know how to restore the db-object back to normal again after the rest of <code>MyStore</code> was already loaded up.</p>
<h2>Moving forward ...</h2>
<p>For Evennia 1.0, the tutorial-writing is the single biggest project that remains - that and the general documentation cleanup of our entirely rewritten documentation.</p>
<p>After that I will dive back in with the issues that has popped up during beta-testing of 1.0-dev and try to wrap up the most serious ones before release. Still some time away, but it's getting there ... slowly!</p>
<footer class="devblog-footer">
<span class="devblog-copyrights">
<p>[Alpha Stock Images](Alpha Stock Images - http://alphastockimages.com/) (released under <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a> )</p>
</span>
<a class="devblog-to-toplink" href="2022.html#2022-07-05-tutorial-writing-and-attributes-galore" title="Link to top of post">⇬(top)</a>
</footer>
</div>
<hr>
<div class="blog_post">
<h1 id=2022-01-06-into-2022-with-thanks-and-plans>
Into 2022 with thanks and plans

File diff suppressed because one or more lines are too long