From 54e5e63b8d6f0966b2ca3349d6ad5ca2df3dfe01 Mon Sep 17 00:00:00 2001 From: feyrkh Date: Sun, 29 Sep 2024 12:25:15 -0500 Subject: [PATCH 1/3] 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. --- .../Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md b/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md index cb81de616c..51df4e3bc2 100644 --- a/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md +++ b/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md @@ -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! \ No newline at end of file +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! From d361b5fddb584f2d2a657c144880784f4da59362 Mon Sep 17 00:00:00 2001 From: feyrkh Date: Sun, 29 Sep 2024 13:02:01 -0500 Subject: [PATCH 2/3] Update Beginner-Tutorial-Equipment.md Also fix to_backpack --- .../Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md b/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md index 51df4e3bc2..cdabbd8d18 100644 --- a/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md +++ b/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md @@ -407,7 +407,7 @@ class EquipmentHandler: for to_backpack_obj in to_backpack: # put stuff in backpack - slots[use_slot].append(to_backpack_obj) + slots[WieldLocation.BACKPACK].append(to_backpack_obj) # store new state self._save() From 7f123cb472d12ce2fe2de7b5b8c045167852dda1 Mon Sep 17 00:00:00 2001 From: feyrkh Date: Sun, 29 Sep 2024 13:08:56 -0500 Subject: [PATCH 3/3] Update Beginner-Tutorial-Equipment.md When adding an item to an empty slot, avoid adding `None` objects to the backpack. --- .../Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md b/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md index cdabbd8d18..08dfd144c1 100644 --- a/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md +++ b/docs/source/Howtos/Beginner-Tutorial/Part3/Beginner-Tutorial-Equipment.md @@ -407,13 +407,14 @@ class EquipmentHandler: for to_backpack_obj in to_backpack: # put stuff in backpack - slots[WieldLocation.BACKPACK].append(to_backpack_obj) + if to_backpack_obj: + slots[WieldLocation.BACKPACK].append(to_backpack_obj) # store new state self._save() ``` -Here we remember that every `EvAdventureObject` has an `inventory_use_slot` property that tells us where it goes. So we just need to move the object to that slot, replacing whatever is in that place from before. Anything we replace goes back to the backpack. +Here we remember that every `EvAdventureObject` has an `inventory_use_slot` property that tells us where it goes. So we just need to move the object to that slot, replacing whatever is in that place from before. Anything we replace goes back to the backpack, as long as it's actually an item and not `None`, in the case where we are moving an item into an empty slot. ## Get everything