Fix incorrect example code in equipment tutorial

The code to replace equipment in a single-item slot references a variable that is never used before or after, and incorrectly sets it to the item that is doing the replacement instead of the item being replaced, which causes the replaced item to not be moved back into the backpack.
This commit is contained in:
feyrkh 2024-09-29 12:25:15 -05:00 committed by GitHub
parent ac06ff735c
commit 54e5e63b8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -402,7 +402,7 @@ class EquipmentHandler:
to_backpack = [obj]
else:
# for others (body, head), just replace whatever's there
replaced = [obj]
to_backpack = [slots[use_slot]]
slots[use_slot] = obj
for to_backpack_obj in to_backpack:
@ -612,4 +612,4 @@ _Handlers_ are useful for grouping functionality together. Now that we spent our
We also learned to use _hooks_ to tie _Knave_'s custom equipment handling into Evennia.
With `Characters`, `Objects` and now `Equipment` in place, we should be able to move on to character generation - where players get to make their own character!
With `Characters`, `Objects` and now `Equipment` in place, we should be able to move on to character generation - where players get to make their own character!