Jump to content

Issues with swap_item not working/showing


Recommended Posts

Hello, I've been trying to create a custom item for my character, and all the animations (ground, inventory) seem to be working except my swap_[item] one.

The character just stands there empty-handed.

I've been following this tutorial: 

 

Here's my maxglove.lua

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

prefabs = {
	}
	local function fn()    

local function OnEquip(inst, owner)        
owner.AnimState:OverrideSymbol("swap_object", "swap_maxglove", "swap_maxglove")        
owner.AnimState:Show("ARM_carry")        
owner.AnimState:Hide("ARM_normal") 
end    

local function OnUnequip(inst, owner)        
owner.AnimState:Hide("ARM_carry")        
owner.AnimState:Show("ARM_normal")   
end    

local inst = CreateEntity()    

local trans = inst.entity:AddTransform()    

local anim = inst.entity:AddAnimState()    
local sound = inst.entity:AddSoundEmitter()    
MakeInventoryPhysics(inst)        
anim:SetBank("maxglove")    
anim:SetBuild("maxglove")    
anim:PlayAnimation("idle")    
inst:AddComponent("inspectable")        
inst:AddComponent("inventoryitem")    
inst.components.inventoryitem.imagename = "maxglove"    
inst.components.inventoryitem.atlasname = "images/inventoryimages/maxglove.xml"        
inst:AddComponent("equippable")    
inst.components.equippable:SetOnEquip( OnEquip )    
inst.components.equippable:SetOnUnequip( OnUnequip )    
return inst 
end 
return  
Prefab("common/inventory/maxglove", fn, assets, prefabs)

swap_maxglove.scml

swap_maxglove.zip

swap_maxglove.png.df77bb421c19d6d64ce4f1d3cfd61213.png

 

Edited by Armadyllo
Link to comment
Share on other sites

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
 Share

×
  • Create New...