Jump to content

Recommended Posts

As the title says, how do I make an item that is right click usable from the inventory and does <something>?

Here is a generic prefab item that does nothing to start with.

local assets =
{
    Asset("ANIM", "anim/test_kit.zip"),
    Asset("ATLAS", "images/inventoryimages/test_kit.xml"),
    Asset("IMAGE", "images/inventoryimages/test_kit.tex"),
}

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("test_kit")
    inst.AnimState:SetBuild("test_kit")
    inst.AnimState:PlayAnimation("idle")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
	
	inst.components.inventoryitem.atlasname = "images/inventoryimages/test_kit.xml"

    MakeHauntableLaunch(inst)

    return inst
end

return Prefab("test_kit", fn, assets)

 

How do I take this and make it a right-click use item that does some arbitrary function?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...