Jump to content

Recommended Posts

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

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 !

Sorry if this is considered necroing but I decided to put several similiar prefab into the same file, based on blowdart.lua

I cannot use the items anymore, I tried adding the component in the individual function already. There is nothing in log.txt

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()	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.

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)

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...