mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 21:36:30 +01:00
Updated and cleaned the wiki2rest converter. The ReST documentation should look a lot better now, with less weirdness. Using a python google-code snippet to convert now, so no more need for third-party ruby downloads! This should transfer to readthedocs shortly.
This commit is contained in:
parent
43f16094c1
commit
ae0f7a04c5
55 changed files with 3990 additions and 1778 deletions
|
|
@ -1,4 +1,6 @@
|
|||
The ``@py`` command
|
||||
Running python code parsers for testing and debugging
|
||||
|
||||
The \`@py\` command
|
||||
===================
|
||||
|
||||
The ``@py`` command supplied with the default command set of Evennia
|
||||
|
|
@ -10,7 +12,8 @@ to just anybody.
|
|||
|
||||
::
|
||||
|
||||
@py 1+2 <<< 3
|
||||
@py 1+2
|
||||
<<< 3
|
||||
|
||||
Available variables
|
||||
-------------------
|
||||
|
|
@ -33,7 +36,8 @@ found in ``src/utils/utils.py``, but also accessible through
|
|||
|
||||
::
|
||||
|
||||
@py from ev import utils; utils.time_format(33333) <<< Done.
|
||||
@py from ev import utils; utils.time_format(33333)
|
||||
<<< Done.
|
||||
|
||||
Note that we didn't get any return value, all we where told is that the
|
||||
code finished executing without error. This is often the case in more
|
||||
|
|
@ -43,7 +47,9 @@ system to echo it to us explicitly with ``self.msg()``.
|
|||
|
||||
::
|
||||
|
||||
@py from ev import utils; self.msg(utils.time_format(33333)) 09:15 <<< Done.
|
||||
@py from ev import utils; self.msg(utils.time_format(33333))
|
||||
09:15
|
||||
<<< Done.
|
||||
|
||||
If you were to use Python's standard ``print``, you will see the result
|
||||
in your current ``stdout`` (your terminal by default), *if* you are
|
||||
|
|
@ -60,7 +66,14 @@ Locating an object is best done using ``self.search()``:
|
|||
|
||||
::
|
||||
|
||||
@py self.search("red_ball") <<< Ball @py self.search("red_ball").db.color = "red" <<< Done. @py self.search("red_ball").db.color <<< red
|
||||
@py self.search("red_ball")
|
||||
<<< Ball
|
||||
|
||||
@py self.search("red_ball").db.color = "red"
|
||||
<<< Done.
|
||||
|
||||
@py self.search("red_ball").db.color
|
||||
<<< red
|
||||
|
||||
``self.search()`` is by far the most used case, but you can also search
|
||||
other database tables for other Evennia entities like scripts or
|
||||
|
|
@ -69,7 +82,8 @@ entries found in ``ev.search_*``.
|
|||
|
||||
::
|
||||
|
||||
@py ev.search_script("sys_game_time") <<< [<src.utils.gametime.GameTime object at 0x852be2c>]
|
||||
@py ev.search_script("sys_game_time")
|
||||
<<< [<src.utils.gametime.GameTime object at 0x852be2c>]
|
||||
|
||||
(Note that since this becomes a simple statement, we don't have to wrap
|
||||
it in ``self.msg()`` to get the output). You can also use the database
|
||||
|
|
@ -80,17 +94,19 @@ in each manager.
|
|||
|
||||
::
|
||||
|
||||
@py ev.db_scripts.script_search("sys_game_time") <<< [<src.utils.gametime.GameTime object at 0x852be2c>]
|
||||
@py ev.db_scripts.script_search("sys_game_time")
|
||||
<<< [<src.utils.gametime.GameTime object at 0x852be2c>]
|
||||
|
||||
The managers are useful for all sorts of database studies.
|
||||
|
||||
::
|
||||
|
||||
@py ev.db_configvalues.all() <<< [<ConfigValue: default_home]>, <ConfigValue:site_name>, ...]
|
||||
@py ev.db_configvalues.all()
|
||||
<<< [<ConfigValue: default_home]>, <ConfigValue:site_name>, ...]
|
||||
|
||||
In doing so however, keep in mind the difference between `Typeclasses
|
||||
and Database Objects <Typeclasses.html>`_: Using the search commands in
|
||||
the managers will return *!TypeClasses*. Using Django's default search
|
||||
the managers will return *TypeClasses*. Using Django's default search
|
||||
methods (``get``, ``filter`` etc) will return *Database objects*. This
|
||||
distinction can often be disregarded, but as a convention you should try
|
||||
to stick with the manager search functions and work with TypeClasses in
|
||||
|
|
@ -98,7 +114,15 @@ most situations.
|
|||
|
||||
::
|
||||
|
||||
# this uses Evennia's manager method get_id(). # It returns a Character typeclass instance @py ev.db_objects.get_id(1).__class__ <<< Character# this uses the standard Django get() query. # It returns a django database model instance. @py ev.db_objects.get(id=1).__class__ <<< <class 'src.objects.models.ObjectDB'>
|
||||
# this uses Evennia's manager method get_id().
|
||||
# It returns a Character typeclass instance
|
||||
@py ev.db_objects.get_id(1).__class__
|
||||
<<< Character
|
||||
|
||||
# this uses the standard Django get() query.
|
||||
# It returns a django database model instance.
|
||||
@py ev.db_objects.get(id=1).__class__
|
||||
<<< <class 'src.objects.models.ObjectDB'>
|
||||
|
||||
Running a Python Parser outside the game
|
||||
========================================
|
||||
|
|
@ -124,5 +148,12 @@ tab-completion and ``__doc__``-string reading.
|
|||
|
||||
::
|
||||
|
||||
$ python manage.py shellIPython 0.10 -- An enhanced Interactive Python ...In [1]: import ev In [2]: ev.db_objects.all() Out[3]: [<ObjectDB: Harry>, <ObjectDB: Limbo>, ...]
|
||||
$ python manage.py shell
|
||||
|
||||
IPython 0.10 -- An enhanced Interactive Python
|
||||
...
|
||||
|
||||
In [1]: import ev
|
||||
In [2]: ev.db_objects.all()
|
||||
Out[3]: [<ObjectDB: Harry>, <ObjectDB: Limbo>, ...]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue