SugarCube - Removing something from my inventory

Twine Version: 2.3.5
Story Format: Sugarcube

I’ve got something I want to do with an inventory item that when its ‘condition’ is ‘0’ for it to be removed.

<<set $playerInventory.kevlarArmor = {
name: "Heavy Flak Jacket",
quantity: 1,
condition: 250,
weight: 4.0,
description: "''@@.item;Body Armor.''@@" }>>

So something like this?:

<<if $playerInventory.kevlarArmor.condition lt 1 unset <</if>>

I believe it’d be something like this:

<<if $playerInventory.kevlarArmor.condition lt 1>>
    <<run delete $playerInventory.kevlarArmor>>
<</if>>
1 Like

Oh, my mistake. I wasn’t even aware of the unset macro. It’s very possible that unset and run delete do exactly the same thing.

You could try <<unset $playerInventory.kevlarArmor>> and see if it works for you (I don’t have access to twine to check.)

1 Like

I tried the ‘unset’ variable but it did the job too well, it removed all items within the $playerInventory

This method worked a treat!
Thanks for that! Removed the item no problem.

1 Like