ItemTypes - MSUTeam/MSU GitHub Wiki
MSU provides functions to safely add a new ItemType to the game, and to modify the ItemType of items. It also allows adding names to ItemTypes to display in tooltips. For example, you could add a new Cultist item type and have it show "Cultist Item" in the tooltips of relevant items to help the user identify such items.
::Const.Items.addNewItemType( _itemType, _name = "" )
// _itemType and _name are stringsitemType will become a key in the ::Const.Items.ItemType table.
_name if not empty will be used in the expanded tooltips of items
with this item type to identify their types.
::Const.Items.addNewItemType( "Cultist", _name = "Cultist Item" )The above code will create a new ItemType called Cultist which can
then be added to items via <item>.addItemType(::Const.Items.ItemType.Cultist)
and will show up as "Cultist Item" under the name of the item in its tooltip.
::Const.Items.getItemTypeName( _itemType )
// _itemType is an ItemType in the ::Const.Items.ItemType tableReturns the name of the given _itemType.
Throws an exception if _itemType is not a valid ItemType.
There are two methods of doing this.
The recommended method is to use the create() function of the item
to set its this.m.ItemType. For example:
this.m.ItemType = ::Const.Items.ItemType.OneHanded | ::Const.Items.ItemType.Cultist;Alternatively, the following function can be used after the item has been created:
<item>.addItemType( _t )
// _t is a key in ::Const.Items.ItemTypeThe above function adds the given ItemType to the item.
<item>.setItemType( _t )
// _t is an ItemType in the ::Const.Items.ItemType tableSets the this.m.ItemType of the item to _t.
<item>.isItemType( _t, _any = true, _only = false )
// _t is a key in ::Const.Items.ItemType
// _any and _only are booleansMSU hooks the vanilla isItemType function to expand its functionality.
_t can be a list of | separated keys as well.
If _any and not _only returns true if _t is any
of the types in this.m.ItemType.
If _any and _only, returns true if this.m.ItemType has no types
that aren't in _t.
If not _any and not _only,
returns true if all of the types in _t are in this.m.ItemType.
If not _any and _only,
return true if _t == this.m.ItemType
<item>.removeItemType( _t )
// _t is an ItemType in the ::Const.Items.ItemType tableRemoves _t from the ItemType of this item.
Throws ::MSU.Exception.KeyNotFound if any of the item types in _t
are not present in the item.