Jump to content

Recommended Posts

Hello!

So, I'm making a little character mod, and for one of the perks, I just wanted to make them run faster if they were wearing a hat. However, I've never really properly coded in a DST mod before, I've just messed about with the templates. So, I was wondering where I would put the code, and how I could basically make it check to see if there was something in the headslot, and if so, increase speed.

Thanks for any help!

You'll want to listen for the events:

Assuming you are using the esctemplate, add these listenforevents to your onload function and make a local function checkhat defined before it.

Spoiler

local function checkhat(inst)
	local head = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
	if head then
		inst.components.locomotor:SetExternalSpeedMultiplier(inst, "hatboost", 1.1)
		--change the number to the % boost you want, e.g. this is a 10% boost
  	else
		inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "hatboost")
	end
end
local function onload(inst)
    .... --these ... represent w.e. other code you have in this function
	inst:ListenForEvent("equip", checkhat)
	inst:ListenForEvent("unequip", checkhat)
    ....
end

 

Cheers,

Iron_Hunter

Edited by IronHunter
2 hours ago, IronHunter said:

You'll want to listen for the events:

Assuming you are using the esctemplate, add these listenforevents to your onload function and make a local function checkhat defined before it.

  Hide contents


local function checkhat(inst)
	local head = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
	if head then
		inst.components.locomotor:SetExternalSpeedMultiplier(eater, "hatboost", 1.1)
		--change the number to the % boost you want, e.g. this is a 10% boost
  	else
		inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "hatboost")
	end
end
local function onload(inst)
    .... --these ... represent w.e. other code you have in this function
	inst:ListenForEvent("equip", checkhat)
	inst:ListenForEvent("unequip", checkhat)
    ....
end

 

Cheers,

Iron_Hunter

This looks like exactly what I need, thank you! But what is that "eater" variable in the first SpeedMultiplier bit?

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