Update CHANGELOG

This commit is contained in:
Griatch 2023-11-18 13:56:53 +01:00
parent d64c75d03f
commit 40a4bd0592
2 changed files with 18 additions and 8 deletions

View file

@ -25,8 +25,9 @@
- [Fix][pull3274]: Traceback when creating objects with initial nattributes
(InspectorCaracal)
- [Fix][issue3272]: Make sure `ScriptHandler.add` does not fail if passed an
instantiated script.
- Docs: Lots of Typo fixes (iLPdev)
instantiated script. (Volund)
- [Fix][pull3322]: Fix `BaseOption.display` to always return a string.
- Docs: Lots of Typo fixes (iLPdev, InspectorCaracal)
- Beginner tutorial: Cleanup and starting earlier with explaining how to add to
the default cmdsets.
@ -40,6 +41,7 @@
[pull3197]: https://github.com/evennia/evennia/pull/3197
[pull3313]: https://github.com/evennia/evennia/pull/3313
[pull3281]: https://github.com/evennia/evennia/pull/3281
[pull3322]: https://github.com/evennia/evennia/pull/3322
[issue3272]: https://github.com/evennia/evennia/issues/3272
[issue3273]: https://github.com/evennia/evennia/issues/3273

View file

@ -115,6 +115,9 @@ class AIHandler:
Add to typeclass with @lazyproperty:
class NPC(DefaultCharacter):
ai_states = {...}
# ...
@lazyproperty
@ -126,10 +129,10 @@ class AIHandler:
def __init__(self, obj):
self.obj = obj
if hasattr(self, "AI_STATES"):
# load AI dict from typeclass core if it exists - allows for setting it
# on the typeclass directly.
self.add_aidict(self.AI_STATES)
if hasattr(self, "ai_states"):
# since we're not setting `force=True` here, we won't overwrite any existing /
# customized dicts.
self.add_aidict(self.ai_states)
def __str__(self):
return f"AIHandler for {self.obj}. Current state: {self.state}"
@ -282,14 +285,19 @@ class AIHandler:
)
return self.obj.attributes.add("ai_transitions", value, category="ai")
def add_aidict(self, aidict):
def add_aidict(self, aidict, force=False):
"""
Add an AI dictionary to the AI handler.
Add an AI dictionary to the AI handler, if one doesn't already exist.
Args:
aidict (dict): AI dictionary to add.
force (bool, optional): Force adding the AI dictionary, even if one already exists on
this handler.
"""
if not force and self.states and self.transitions:
return
aidict = self._validate_ai_dict(aidict)
self.states = aidict["states"]
self.transitions = aidict["transitions"]