Custom Inventory System inspired by CS:GO for nanos world
Keys 1 - 9 to switch Items, 0 to free hands. Picking up any Item will automatically place them in the inventory.
-- Gives an AK47 Weapon to player (drops any other item which may be holding)
GiveInventoryItem(player, "nanos-world::SK_AK47")
-- Removes an Item from player's inventory at slot 1, will Drop the item if currently holding it
RemoveInventoryItem(player, 1)
If you want to add more Items/Weapons, just modify Shared/Index.lua
and append your new items in the InventoryItems
list, e.g.:
InventoryItems = {
...
["nanos-world::MyCustomAsset"] = { -- Asset Name, used to indentify the Item/Weapon
name = "Awesome Custom", -- Custom name to appear on the screen
image = "good_photo.png", -- Image path (inside UI/images/ folder)
spawn = function(pos) return Weapon(pos or Vector(), Rotator(), ...) end, -- Spawn function to spawn your object
slot = 1, -- Which slot to be placed
type = InventoryTypes.Weapon, -- Kind of the item (Weapons handle ammo_bag and ammo_clip automatically)
default_data = {ammo_bag = 1000, ammo_clip = 30}, -- Custom data attached to this Item
},
...
}