Copy doc tools from develop

This commit is contained in:
Griatch 2020-07-12 20:01:44 +02:00
parent bd65641755
commit 6af2fc6819
127 changed files with 2927 additions and 1427 deletions

View file

@ -5,27 +5,27 @@
## Table of Contents
- [Removing default commands](Coding-FAQ#removing-default-commands)
- [Preventing character from moving based on a condition](Coding-FAQ#preventing-character-from-moving-based-on-a-condition)
- [Reference initiating object in an EvMenu command](Coding-FAQ#reference-initiating-object-in-an-evmenu-command)
- [Adding color to default Evennia Channels](Coding-FAQ#adding-color-to-default-evennia-channels)
- [Selectively turn off commands in a room](Coding-FAQ#selectively-turn-off-commands-in-a-room)
- [Select Command based on a condition](Coding-FAQ#select-command-based-on-a-condition)
- [Automatically updating code when reloading](Coding-FAQ#automatically-updating-code-when-reloading)
- [Changing all exit messages](Coding-FAQ#changing-all-exit-messages)
- [Add parsing with the "to" delimiter](Coding-FAQ#add-parsing-with-the-to-delimiter)
- [Store last used session IP address](Coding-FAQ#store-last-used-session-ip-address)
- [Use wide characters with EvTable](Coding-FAQ#non-latin-characters-in-evtable)
- [Removing default commands](./Coding-FAQ#removing-default-commands)
- [Preventing character from moving based on a condition](./Coding-FAQ#preventing-character-from-moving-based-on-a-condition)
- [Reference initiating object in an EvMenu command](./Coding-FAQ#reference-initiating-object-in-an-evmenu-command)
- [Adding color to default Evennia Channels](./Coding-FAQ#adding-color-to-default-evennia-channels)
- [Selectively turn off commands in a room](./Coding-FAQ#selectively-turn-off-commands-in-a-room)
- [Select Command based on a condition](./Coding-FAQ#select-command-based-on-a-condition)
- [Automatically updating code when reloading](./Coding-FAQ#automatically-updating-code-when-reloading)
- [Changing all exit messages](./Coding-FAQ#changing-all-exit-messages)
- [Add parsing with the "to" delimiter](./Coding-FAQ#add-parsing-with-the-to-delimiter)
- [Store last used session IP address](./Coding-FAQ#store-last-used-session-ip-address)
- [Use wide characters with EvTable](./Coding-FAQ#non-latin-characters-in-evtable)
## Removing default commands
**Q:** How does one *remove* (not replace) e.g. the default `get` [Command](Commands) from the Character [Command Set](Command-Sets)?
**Q:** How does one *remove* (not replace) e.g. the default `get` [Command](./Commands) from the Character [Command Set](./Command-Sets)?
**A:** Go to `mygame/commands/default_cmdsets.py`. Find the `CharacterCmdSet` class. It has one method named `at_cmdset_creation`. At the end of that method, add the following line: `self.remove(default_cmds.CmdGet())`. See the [Adding Commands Tutorial](Adding-Command-Tutorial) for more info.
**A:** Go to `mygame/commands/default_cmdsets.py`. Find the `CharacterCmdSet` class. It has one method named `at_cmdset_creation`. At the end of that method, add the following line: `self.remove(default_cmds.CmdGet())`. See the [Adding Commands Tutorial](./Adding-Command-Tutorial) for more info.
## Preventing character from moving based on a condition
**Q:** How does one keep a character from using any exit, if they meet a certain condition? (I.E. in combat, immobilized, etc.)
**A:** The `at_before_move` hook is called by Evennia just before performing any move. If it returns `False`, the move is aborted. Let's say we want to check for an [Attribute](Attributes) `cantmove`. Add the following code to the `Character` class:
**A:** The `at_before_move` hook is called by Evennia just before performing any move. If it returns `False`, the move is aborted. Let's say we want to check for an [Attribute](./Attributes) `cantmove`. Add the following code to the `Character` class:
```python
def at_before_move(self, destination):
@ -39,7 +39,7 @@ def at_before_move(self, destination):
## Reference initiating object in an EvMenu command.
**Q:** An object has a Command on it starts up an EvMenu instance. How do I capture a reference to that object for use in the menu?
**A:** When an [EvMenu](EvMenu) is started, the menu object is stored as `caller.ndb._menutree`. This is a good place to store menu-specific things since it will clean itself up when the menu closes. When initiating the menu, any additional keywords you give will be available for you as properties on this menu object:
**A:** When an [EvMenu](./EvMenu) is started, the menu object is stored as `caller.ndb._menutree`. This is a good place to store menu-specific things since it will clean itself up when the menu closes. When initiating the menu, any additional keywords you give will be available for you as properties on this menu object:
```python
class MyObjectCommand(Command):
@ -81,7 +81,7 @@ Additional hint: To make colors easier to change from one place you could instea
## Selectively turn off commands in a room
**Q:** I want certain commands to turn off in a given room. They should still work normally for staff.
**A:** This is done using a custom cmdset on a room [locked with the 'call' lock type](Locks). Only if this lock is passed will the commands on the room be made available to an object inside it. Here is an example of a room where certain commands are disabled for non-staff:
**A:** This is done using a custom cmdset on a room [locked with the 'call' lock type](./Locks). Only if this lock is passed will the commands on the room be made available to an object inside it. Here is an example of a room where certain commands are disabled for non-staff:
```python
# in mygame/typeclasses/rooms.py
@ -114,7 +114,7 @@ After `@reload`, make some `BlockingRooms` (or switch a room to it with `@typecl
## Select Command based on a condition
**Q:** I want a command to be available only based on a condition. For example I want the "werewolf" command to only be available on a full moon, from midnight to three in-game time.
**A:** This is easiest accomplished by putting the "werewolf" command on the Character as normal, but to [lock](Locks) it with the "cmd" type lock. Only if the "cmd" lock type is passed will the command be available.
**A:** This is easiest accomplished by putting the "werewolf" command on the Character as normal, but to [lock](./Locks) it with the "cmd" type lock. Only if the "cmd" lock type is passed will the command be available.
```python
# in mygame/commands/command.py
@ -128,7 +128,7 @@ class CmdWerewolf(Command):
def func(self):
# ...
```
Add this to the [default cmdset as usual](Adding-Command-Tutorial). The `is_full_moon` [lock function](Locks#lock-functions) does not yet exist. We must create that:
Add this to the [default cmdset as usual](./Adding-Command-Tutorial). The `is_full_moon` [lock function](./Locks#lock-functions) does not yet exist. We must create that:
```python
# in mygame/server/conf/lockfuncs.py