MadAssau1t Posted December 15, 2016 Share Posted December 15, 2016 (edited) Hello everyone. I'm currently making a mod that i would like to be able to use an item from my inventory without equipping it as its not a weapon and id like to be able to use it without targeting something to spawn a prefab. so far ive got the following code put together which loads in fine but when clicked it simply reads, "this is an item". i believe my problem is that i dont have a "caninteract" function, but im having a tough time finding a good example of what i am trying to do, and as a noobie in lua i cant seem to figure out exactly where or what my interact function should be. Thanks in advance for any help local assets = { Asset("ANIM", "anim/myanim.zip"), Asset("ANIM", "anim/swap_myanim.zip"), Asset("ATLAS", "images/inventoryimages/myimg.xml"), Asset("IMAGE", "images/inventoryimages/myimg.tex"), } local prefabs ={} local function myfnuse(inst) print ("I used the item!") local pos = inst:GetPosition() local fellow = SpawnPrefab("anotherpref") fellow.Transform:SetPosition(pos:Get()) fellow.components.follower:SetLeader(player) end local function commonfn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) inst:AddTag("irreplaceable") inst.AnimState:SetBank("papyrus") inst.AnimState:SetBuild("papyrus") inst.AnimState:PlayAnimation("idle") inst:AddComponent("inventoryitem") inst:AddComponent("inspectable") inst:AddComponent("useableitem") return inst end local function myfn(inst) local inst = commonfn(inst) inst.components.inventoryitem.atlasname = "images/inventoryimages/myimage.xml" inst.components.inventoryitem.imagename = "myimage" inst.components.useableitem:SetOnUseFn(myfnuse) return inst end return Prefab("someprefab", myfn, assets) Edited December 15, 2016 by MadAssau1t Link to comment https://forums.kleientertainment.com/forums/topic/72531-usable-item-without-equip/ Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now