Mobbstar Posted June 9, 2014 Share Posted June 9, 2014 I am working on a super secret mod, but I stumbled upon a brain-racking issue. I want to make a inventory item that cannot be equipped but still be used indefinitely to spawn a prefab.For the most part, this is easy, but I need help with the use part. I have tried the components "useable_item", which seems to require equippables, and "book"/"reader", although I don't know how to disable the animation or replace it with another, more fitting one.Should I make a new component to suit my needs or is there a good one already? Am I just not understanding the mentioned components enough to fix the stated problems? Are there any mods with helpful guidance code I can look at? Thank you most sincerely for your time and effort, in advance. Link to comment https://forums.kleientertainment.com/forums/topic/37305-help-special-useable-item/ Share on other sites More sharing options...
DevilXD Posted June 9, 2014 Share Posted June 9, 2014 Hey @Mobbstar, I made a bucket mod, that adds water bucket, and I made it that you can spit water out of it on yourself... You can do this anytime, without equipping the bucket, just right clicking... Look into waterbucket.lua prefab file in my mod, and try doing something similar Link to the mod: http://www.forums.kleientertainment.com/files/file/783-the-mod-about-buckets/Cheers ! Link to comment https://forums.kleientertainment.com/forums/topic/37305-help-special-useable-item/#findComment-497416 Share on other sites More sharing options...
Mobbstar Posted June 10, 2014 Author Share Posted June 10, 2014 Thank you very much, devil. I didn't realise that I needed to set a canuse function. Programming at late night...Also, awesome mod you got there. I'm gonna add you to the long long list of special thanks in the credits. If I had one Link to comment https://forums.kleientertainment.com/forums/topic/37305-help-special-useable-item/#findComment-497555 Share on other sites More sharing options...
Mobbstar Posted June 12, 2014 Author Share Posted June 12, 2014 Sorry if this is considered necroing but I decided to put several similiar prefab into the same file, based on blowdart.luaI cannot use the items anymore, I tried adding the component in the individual function already. There is nothing in log.txtlocal function xuse(inst) print ("spawned x") local pos = inst:GetPosition() local fellow = SpawnPrefab("x") fellow.Transform:SetPosition(pos:Get()) fellow.components.follower:SetLeader(player) player.components.sanity:DoDelta(-TUNING.SANITY_MED)endlocal function yuse() print ("spawned y") local pos = inst:GetPosition() local make = SpawnPrefab("y") make.Transform:SetPosition(pos:Get()) player.components.inventory:ConsumeByName("nightmarefuel", usedprey) player.components.sanity:DoDelta(-TUNING.SANITY_TINY)end local function commonfn(Sim) 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 instendlocal function xfn() local inst = commonfn() inst.components.inventoryitem.atlasname = "images/inventoryimages/xs.xml" inst.components.inventoryitem.imagename = "xs" inst.components.useableitem:SetCanInteractFn(ismaster) inst.components.useableitem:SetOnUseFn(xuse) return instendlocal function yfn() local inst = commonfn() inst.components.inventoryitem.atlasname = "images/inventoryimages/ys.xml" inst.components.inventoryitem.imagename = "ys" local usedprey = 1 inst.components.useableitem:SetCanInteractFn(checkprey) inst.components.useableitem:SetOnUseFn(yuse) return instendreturn Prefab("common/inventory/xs", xfn, Assets), Prefab("common/inventory/ys", yfn, Assets)What am I doing wrong? I don't get it. Link to comment https://forums.kleientertainment.com/forums/topic/37305-help-special-useable-item/#findComment-498737 Share on other sites More sharing options...
DevilXD Posted June 12, 2014 Share Posted June 12, 2014 This should work local function xuse(inst) print ("spawned x") local pos = inst:GetPosition() local fellow = SpawnPrefab("x") fellow.Transform:SetPosition(pos:Get()) fellow.components.follower:SetLeader(player) player.components.sanity:DoDelta(-TUNING.SANITY_MED)endlocal function yuse(inst) print ("spawned y") local pos = inst:GetPosition() local make = SpawnPrefab("y") make.Transform:SetPosition(pos:Get()) player.components.inventory:ConsumeByName("nightmarefuel", usedprey) player.components.sanity:DoDelta(-TUNING.SANITY_TINY)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 instendlocal function xfn(inst) local inst = commonfn(inst) inst.components.inventoryitem.atlasname = "images/inventoryimages/xs.xml" inst.components.inventoryitem.imagename = "xs" inst.components.useableitem:SetCanInteractFn(ismaster) inst.components.useableitem:SetOnUseFn(xuse) return instendlocal function yfn(inst) local inst = commonfn(inst) inst.components.inventoryitem.atlasname = "images/inventoryimages/ys.xml" inst.components.inventoryitem.imagename = "ys" local usedprey = 1 inst.components.useableitem:SetCanInteractFn(checkprey) inst.components.useableitem:SetOnUseFn(yuse) return instendreturn Prefab("common/inventory/xs", xfn, Assets), Prefab("common/inventory/ys", yfn, Assets) Link to comment https://forums.kleientertainment.com/forums/topic/37305-help-special-useable-item/#findComment-498868 Share on other sites More sharing options...
Mobbstar Posted June 12, 2014 Author Share Posted June 12, 2014 (edited) Thank you very much. I am so silly at times... At least not a missplaced comma EDIT: Thank you very much. I am so uber silly at times... the fault was that canuse never turned true it seems Edited June 12, 2014 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/37305-help-special-useable-item/#findComment-498874 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