KeyItemPD -> ExpendableItemPD: replace/change discard_after_use behavior to be more modular #268
Replies: 2 comments 2 replies
-
This makes total sense. Are you cool if I just make this change? Or do you want to put in a PR? Also a little bit related: I've just pushed an update with a new object: The examples in the Laboratory should show clearly what this object can be used for (snapping carryables into a specific |
Beta Was this translation helpful? Give feedback.
-
Sweet, I've implemented these changes now in 8f6cbd4 If you run into any problems, please open an Issue. |
Beta Was this translation helpful? Give feedback.
-
As it stands, KeyItemPD works well, but with just one line of code I was able to make it more modular and useful.
It has a single var 'discard_after_use', which tells whatever it's used on (doors, switches, buttons) to completely remove the key's slot data from inventory. I don't think that is necessarily the best way to go about this.
Instead of just KeyItemPD it behaves more like a 'UsableItemPD', 'ResourceItemPD' or 'ExpendableItemPD'.
Here's my change:
With this change I was able to utilize a stackable inventory item (battery) to power on multiple switches (spending them like keys, but more as a resource than as a puzzle piece). This change still works within the spirit of the original KeyItemPD, because you can still have a single, unstackable key in the game world and then have the 1 door it unlocks and would still work as a one-time, single-purpose item (as the player can gather no more than one)
This approach allows you to use it both for unique keys as well as generic resources that can be used on various objects and still be removed one-by-one from inventory on each use.
Flashback.-.Sep.13.2024.20_39_12.mp4
KeyItemPD's 'discard_after_use' is currently evaluated in CogitoDoor, CogitoSwitch, and CogitoButton.
BTW, I've only tested this using CogitoSwitch.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions