#1 - Basic structure + example
Item templates are the code that'll run for your custom entity.
Templates allows you to create complex logic for items stored in the inventory, and for how the inventory should treat an item before it's stored inside the inventory.
To start you'll need to make a file in /configuration/items/. You should call it your entities name, or if there's multiple entities, call it whatever makes sense.
Lets call ours money_printer.lua
At the top of your file you need to have this
local ITEM = Inventory:CreateItemV2()
This creates a copy of the default item template, now you just need to overwrite functions or set variables to do your own things.
Basic example to just save data + add the ability to drop the entity
local ITEM = Inventory:CreateItemV2()
ITEM:SetDescription("A simple printer!")
ITEM:AddDrop(function(self, ply, ent, tbl, tr)
ent:SetMoney(tbl.data.Money)
end)
function ITEM:GetData(ent)
return {
money = ent:GetMoney()
}
end
ITEM:Register("money_printer")