Could we get Surface/SocketComponent:removeItem()?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Could we get Surface/SocketComponent:removeItem()?

Post by minmay »

As far as I can tell, currently the only way for the scripting interface to remove an item from a SurfaceComponent or SocketComponent is to destroy either the ItemComponent or the SurfaceComponent/SocketComponent containing it. Adding the item to a different surface/container/inventory does not remove it from the original surface, it just results in the item being contained in two surfaces/inventories at once (which in turn causes havoc if the game is saved/loaded).

Since it is not possible to duplicate an ItemComponent (no way to set its onEquipItem etc. hooks), this makes it very hard to work with items on surfaces or in sockets:
- there is no way to move an item from one surface to another, except for convincing the player to pick the item up themselves and do it
- there is no way to expel an item from a surface without destroying either the item or the surface

It would be really nice to be able to cleanly remove an item like the player can.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply