Cosmetic lua library
I wrote a library for myself to use in my projects since I think it's quite useful so I would share it.
CosmeticLib will help swapping cosmetic become easier including
- Equipping item based on its item_id to specified slot name for unit
- Equipping item based on its item_id to replace currently equipped item based on its item_id for unit
- Equipping specific set to the unit
- Equipping default cosmetic items to the unit
- Remove cosmetic from specific slot of the unit
- Remove all cosmetics from the unit
- Getting the list of slots available for the unit based on hero name
- Getting the list of items available for the unit based on hero name
- Getting the list of set items available for the unit based on hero name
- Getting item id based on item name.
- Getting item id based on model name.
- Auto-swapping ward
- Auto-swapping courier
- Particle placing, due to hidden placing by valve, this may have to wait til later patch
- Removing cosmetic will result in deattach all existing particles. It will remain there in the game forever unless attachable cosmetic is attached to the slot again. The best way to avoid this is to have a place to dump all particles in the map if you plan to override any equipped cosmetic with the ones from different slot or from other heroes.
- In order for cosmetic for specified hero to show up, you need to precache model_folder accordingly in the precache block in addon_game_mode.lua such as
PrecacheResource( "model_folder", "models/heroes/drow", context ) PrecacheResource( "model_folder", "models/items/drow", context )
Test console commands are also available by enable cheat in the lobby and set sv_cheats 1 in console. The following is the link to the library:
The library contains 2 files
- CosmeticLib.lua, this file contains the lua library
- CosmeticLib.txt, this file is a README where you can find all available functions
To use in your addon, simple write the following line to the top of your addon_game_mode.lua
require( 'CosmeticLib' )
If there is anything I can do to improve the existing library or include any other feature, feel free to leave a comment or send me a message.