Mad Alchemist Posted February 20, 2018 Share Posted February 20, 2018 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! Link to comment https://forums.kleientertainment.com/forums/topic/87828-character-moves-faster-if-wearing-a-hat-help/ Share on other sites More sharing options...
IronHunter Posted February 20, 2018 Share Posted February 20, 2018 (edited) 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 February 20, 2018 by IronHunter Link to comment https://forums.kleientertainment.com/forums/topic/87828-character-moves-faster-if-wearing-a-hat-help/#findComment-1006574 Share on other sites More sharing options...
Mad Alchemist Posted February 20, 2018 Author Share Posted February 20, 2018 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? Link to comment https://forums.kleientertainment.com/forums/topic/87828-character-moves-faster-if-wearing-a-hat-help/#findComment-1006629 Share on other sites More sharing options...
IronHunter Posted February 20, 2018 Share Posted February 20, 2018 oops that is an accident XD from some coffee code I made, just change that to inst and you should be good. Cheers, Iron_Hunter Link to comment https://forums.kleientertainment.com/forums/topic/87828-character-moves-faster-if-wearing-a-hat-help/#findComment-1006630 Share on other sites More sharing options...
Mad Alchemist Posted February 20, 2018 Author Share Posted February 20, 2018 2 minutes ago, IronHunter said: oops that is an accident XD from some coffee code I made, just change that to inst and you should be good. Cheers, Iron_Hunter Ah, perfect! Thanks a ton! Link to comment https://forums.kleientertainment.com/forums/topic/87828-character-moves-faster-if-wearing-a-hat-help/#findComment-1006631 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