advanced iii: modifying inventory and using args

  • this page utilizes concepts and functions found on our advanced ii: using user arguments guide.

  • if you haven't visited or don't fully understand that page yet, return to this after you do!

for inventory commands, make sure you have items added to your shop before continuing!

✎ the {modifyinv:} variable

  • the variable itself isn't very complex for basic usage! but, when combined with user arguments, it can get messy really quickly.

  • this variable modifies the inventory of a user by either adding or removing an item from a user's /balance , under the "inventory" field.

  • the command accepts 3 options: {modifyinv: [item name/ID] | [+/- quantity] | <user>}

if using an item name in the variable, the name must be exact. for example, if I have an item named "chocolate chip cookie", the variable must be {modifyinv: chocolate chip cookie | 1}, not {modifyinv: cookie | 1} or any other variants. for this reason, we always recommend using the item's ID option.

  • notice: the user option is optional. you must have an item name/ID and quantity in the variable when using it.

✎ what does this have to do with user arguments?

  • you're probably thinking, "oookay, so why is this more advanced?"

  • the concept in practice can get very tricky for beginners, especially as we introduce user arguments.

  • let's say I want to make a command called .shake tree that requires another user. this command will give an item for both users /autoresponder add trigger:.shake trees reply:{requirearg: 1 | user}{range:2-10}{embed}{modifyinv: coconut | 1}{modifyinv: coconut | 1 | [$1]} you shook a tree . . . [range] coconuts fell out! you each took one and stashed it in your inventory. /autoresponder editmatchmode trigger:.shake trees matchmode:startswith

  • now, check your inventory to see the item added by using /inventory ; or, alternatively, using /balance, then clicking the blue button with a box.

  • the item "coconut" was added to both users - the user who ran the command, and the user that was mentioned in the command.

  • you can even take it a step further, requiring items using {requireitem:} or displaying both users' current amount of the item by adding {user_item_count: coconut} and {user_item_count: coconut | [$1]} to the autoresponder's reply.

we highly recommend requiring items when modifying someone's inventory, specifically if removing items. users cannot have negative amounts of an item in their inventory, so if removing an item, it will remove only what they have.

Last updated