inventory addmulti

From Arx Libertatis Wiki
Jump to navigation Jump to search

The inventory addmulti script command is used to create a new item stack and place it into the inventory for an entity. The new item stack will be combined into existing stacks in the calling entity's inventory if possible which may result in the original item being destroyed. If the calling inventory did not have an inventory created with inventory create, if the item does not fit into the inventory or if it is not an item that can be put into inventories then it is dropped in front of the player instead.

This command (re)sets the maximum count to 9999 and count (price for gold coins) to the given <count> after the load, init and initend events have executed. While merging into existing stacks respects the maximum stack size of those stacks, the remaining stack created by this command will be created with whatever stack <cound> passed to this command (minus whatever was merged into existing stacks). Otherwise, this command is equivalent to <count> calls to inventory add <script> except for not creating individual items that are then destroyed again when merged into stacks.

To add an existing item instead of creating a new one use inventory addfromscene.

To add an item to the player inventory use inventory playeraddfromscene, inventory playeradd or inventory playeraddmulti instead.

To spawn items in the world instead of inside an inventory use spawn item and to equip them as a weapon use setweapon.

This command only creates item entities - to create entities of other types use spawn npc or replaceme.

This command has no effect while re-loading an area that was already visited before, e.g. in the reload event.


inventory addmulti <script> <count*>

Context: Any Entity


script path Script path (without file extension) of the entity to add, relative to graph/obj3d/interactive/items
count int or variable Number of items in the created stack or price to set for gold coin items

Script path

The entity class script is loaded from graph/obj3d/interactive/items/<script>.asl.

If the filename component of the script path starts with gold_coin gold coin then the item will be treated as a gold coin which means that it will be added to the player's purse when the player interacts with it or when it would be added to the player inventory. Gold coins also somewhat act like stacks but use the price in place of the count and have the icon automatically selected based on the price.

If the script path contains the string movable then the item cannot be added to inventories and is dropped in front of the player instead whenever it would be.

The initial mesh of the item will be graph/obj3d/interactive/items/<script>.teo with the cooked mesh loaded from game/graph/obj3d/interactive/items/<script>.ftl. Either the raw mesh, cooked mesh or entity class script file must exist or the item will not be created.

The initial icon of the item will be graph/obj3d/interactive/items<script>[icon] if it exists or graph/interface/misc/default[icon] otherwise. The icon size determines how many slots the item takes up in inventories except for movable items (which have no icon) and gold coins (where the icon depends on the price).

ℹ️  In version before Arx Libertatis 1.3 the icon file at the default path must also exist or the item will not be created, even for gold coins, movable items or items that change the icon in the load event.

Entity ID

The ID of the created entity can be retrieved via the ^last_spawned system variable. It will be made up of the filename component of the script path (the entity class) followed by _ and a previously unused four-digit instance number - meaning one that does not have an instance directory in the game resources under the script path and does not have an existing entity in the current area or save file.

This also means that it is not possible to create entities with instance scripts using this command (or any other script command).

If the created entity is destroyed before this command returns (because it was fully merged into an exiting stack or because the init events destroyed it) then then ^last_spawned will be none. If the init events spawn additional items then ^last_spawned will contain the ID of the last spawned item.

Entity initialization

The created item will be sent the load, init and initend events (in that order) before being combined into stacks or added to the inventory.