dungdodger Posted January 5, 2015 Share Posted January 5, 2015 Hello and thanks for looking GL local assets={Asset("ANIM", "anim/wouhat.zip"),Asset("ANIM", "anim/swap_wouhat.zip"),Asset("ATLAS", "images/inventoryimages/wouhat.xml"),Asset("IMAGE", "images/inventoryimages/wouhat.tex"),}prefabs = {}local function doeffects(inst, pos)SpawnPrefab("statue_transition").Transform:SetPosition(pos:Get())SpawnPrefab("statue_transition_2").Transform:SetPosition(pos:Get())endlocal function poof (inst, owner)local owner = inst.components.inventoryitem.ownerif not owner.components.inventory:Has("petals", 2) thenif owner.components.talker thenowner.components.talker:Say("You... Oink... YOU ate Our Flowers")return trueendendlocal pt = inst:GetPosition()local theta = math.random() * 2 * PIlocal radius = math.random(3, 6)local offset = FindWalkableOffset(pt, theta, radius, 12, true)if offset thenlocal image = SpawnPrefab("bunnyman")local pos = pt + offsetimage.Transform:SetPosition(pos:Get())doeffects(inst, pos)image.components.follower:SetLeader(owner)inst.SoundEmitter:PlaySound("dontstarve/maxwell/shadowmax_appear")owner.components.sanity:DoDelta(-10)returnendendlocal function OnEquip(inst, owner)owner.AnimState:OverrideSymbol("swap_hat", "swap_wouhat", "swap_wouhat")owner.AnimState:Show("HAT")owner.AnimState:Show("HAT_HAIR")owner.AnimState:Hide("HAIR_NOHAT")owner.AnimState:Hide("HAIR")if owner:HasTag("player") thenowner.AnimState:Hide("HEAD")owner.AnimState:Show("HEAD_HAIR")endendlocal function OnUnequip(inst, owner)owner.AnimState:Hide("HAT")owner.AnimState:Hide("HAT_HAIR")owner.AnimState:Show("HAIR_NOHAT")owner.AnimState:Show("HAIR")if owner:HasTag("player") thenowner.AnimState:Show("HEAD")owner.AnimState:Hide("HEAD_HAIR")endendlocal function fn()local inst = CreateEntity()local trans = inst.entity:AddTransform()local anim = inst.entity:AddAnimState()local sound = inst.entity:AddSoundEmitter()MakeInventoryPhysics(inst)anim:SetBank("wouhat")anim:SetBuild("wouhat")anim:PlayAnimation("idle")local minimap = inst.entity:AddMiniMapEntity()minimap:SetIcon("wouhat.tex")inst:AddComponent("inspectable")inst:AddComponent("inventoryitem")inst.components.inventoryitem.imagename = "wouhat"inst.components.inventoryitem.atlasname = "images/inventoryimages/wouhat.xml"--inst:AddTag("hat")inst:AddComponent("equippable")inst.components.equippable:SetOnEquip( OnEquip )inst.components.equippable:SetOnUnequip( OnUnequip )inst.components.equippable.equipslot = EQUIPSLOTS.HEADinst:AddComponent("useableitem")inst.components.useableitem:SetOnUseFn(poof)return instendreturn Prefab("common/inventory/wouhat", fn, assets) This item only lets me use it once then, i have to log out and back on before the Use command shows back up What am i missing or need to do ??? Any advise would be Helpful ThanksOh and i tired to use stuff like owner.components.useableitem:StopUsingItem() and learn from the components Thread Thanks Mobbstar but i am unable to get it working Link to item: wouhat.lua Link to comment Share on other sites More sharing options...
Mobbstar Posted January 5, 2015 Share Posted January 5, 2015 Since your item is not in use over an undefined time, you could adapt the component to your need by setting caninteractfn to funtion canuse(inst) return inst.components.equippable.isequippedend which removes "inuse" from the conditions. Let me know if it works! Link to comment Share on other sites More sharing options...
dungdodger Posted January 5, 2015 Author Share Posted January 5, 2015 Since your item is not in use over an undefined time, you could adapt the component to your need by setting caninteractfn to funtion canuse(inst) return inst.components.equippable.isequippedend Let me know if it works! It Works Added a local function canuse(inst) return inst.components.equippable.isequippedend and inst.components.useableitem:SetCanInteractFn (canuse) Thanks Much This Char im working on is getting closer,(Thinking about just posting it as a WIP) Now to add when u trade the Hat a rabbit it spawns rabbits a bunnyman tail it spawns bunnyman was looking in to Birdcage for ideas how to do this,, Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.