Jump to content

Recommended Posts

I have a few features I'm having troubles with:

1. How to make Item unable to be used by other characters

2. How make item last first 7 days

I tried both perishable and fueled components but was unable to get them to work exactly as expected. Perishable item was fine but I couldn't figure out how to make item disappear on perish. Fuel tag is more desirable since it gives a percentage on the item but I could not figure out what components I needed to burn "fuel" over time. Item will also need to lose "fuel" when unequipped.

Thanks ahead of time

Also is there a list of components and how they work for DST?

Edited by its zea
42 minutes ago, its zea said:

How to make Item unable to be used by other characters

In the onequip function of your tool/item you can put this

Spoiler

if owner.youcanchangethenameofthisvalue == true then
	owner:DoTaskInTime(0, function()
		local item = owner.components.inventory:GetEquippedItem(inst.components.equippable.equipslot)
		if item and item.Physics then
			owner.components.inventory:DropItem(item)
			owner.components.talker:Say("I can't use that.")
		end
	end)
end

 

then in yourchar.lua put the value ( inst.youcanchangethenameofthisvalue = true ) either in master_postinit or common_postinit then they can hold that item.

For a fueled item to use fuel you use this code " inst.components.fueled:StartConsuming() " and for it to stop you use this code " inst.components.fueled:StopConsuming() "

 

hope this helps :D

Edited by Warbucks
20 hours ago, Warbucks said:

In the onequip function of your tool/item you can put this

  Hide contents


if owner.youcanchangethenameofthisvalue == true then
	owner:DoTaskInTime(0, function()
		local item = owner.components.inventory:GetEquippedItem(inst.components.equippable.equipslot)
		if item and item.Physics then
			owner.components.inventory:DropItem(item)
			owner.components.talker:Say("I can't use that.")
		end
	end)
end

 

then in yourchar.lua put the value ( inst.youcanchangethenameofthisvalue = true ) either in master_postinit or common_postinit then they can hold that item.

For a fueled item to use fuel you use this code " inst.components.fueled:StartConsuming() " and for it to stop you use this code " inst.components.fueled:StopConsuming() "

 

hope this helps :D

Thanks for the response ill get to work and find out!

 

Edit: It seems that this code causes a crash on equip or loading of character with supplied value to pickup.

 

I changed the value as suggested from owner.youcanchangethenameofthisvalue to owner.use.walking_stick

and inst.youcanchangethenameofthisvalue to inst.use.walking_stick

 

Error console says "use" value is nil in this instance. Do I perhaps need to create a local variable for use.walking_stick or am I just not understanding this at all?

Edited by its zea

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