whatsherface Posted September 17, 2016 Share Posted September 17, 2016 (edited) Hi there! Thank's for taking a look at my problem. A little background: I'm fairly new to modding. (I've messed around in some of minecraft's code, so I know the bare minimum of actual coding) Don't starve is a new challenge for me. That being said I've created a new character, modified their stats and whatnot. Now I want to add several perks. One being: runs incredibly fast. I've taken care of that. Now for the second perk: I want to make it so the followers with them have a longer loyalty time. inst.components.follower:AddLoyaltyTime(240) Now with my basic lack of understanding I know this is the basic loyalty time of half a day. I tried just putting this line in the characters prefab file under inst.components.locomotor.walkspeed = (6) inst.components.locomotor.runspeed = (10) But that didn't work and gave me a Warning TLDR: Trying to increase loyalty time of all followers under a specific character. Am I on the right track, or completely wrong? I would be so grateful to get a little (or a lot) of help. Thank you! Edited September 17, 2016 by whatsherface Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/ Share on other sites More sharing options...
Mobbstar Posted September 17, 2016 Share Posted September 17, 2016 The "Follower" component is what the follower has, the player has the "leader" component. Woodie has a small leader boost in DST too, I think, so check data\scripts\prefabs\woodie.lua out! Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814672 Share on other sites More sharing options...
whismerhill Posted September 17, 2016 Share Posted September 17, 2016 9 hours ago, whatsherface said: Hi there! Thank's for taking a look at my problem. A little background: I'm fairly new to modding. (I've messed around in some of minecraft's code, so I know the bare minimum of actual coding) Don't starve is a new challenge for me. That being said I've created a new character, modified their stats and whatnot. Now I want to add several perks. One being: runs incredibly fast. I've taken care of that. Now for the second perk: I want to make it so the followers with them have a longer loyalty time. inst.components.follower:AddLoyaltyTime(240) Now with my basic lack of understanding I know this is the basic loyalty time of half a day. I tried just putting this line in the characters prefab file under inst.components.locomotor.walkspeed = (6) inst.components.locomotor.runspeed = (10) TLDR: Trying to increase loyalty time of all followers under a specific character. That's because "inst" is a generic variable used as a replacement for whatever object you're handling at the time. So in your example in "inst.components.follower" inst refers to the follower object which possess a follower component. Whereas inst in your character sam.lua refers to your character object e.g. "sam". Also if you think it through, it is logical that sam has no follower component since "he is not a follower" I know Mobbstar probably answered your question already in less words that I did but I thought you might be confused by those "inst" everywhere. Anyone knows what "inst" stands for btw ? Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814727 Share on other sites More sharing options...
Mobbstar Posted September 17, 2016 Share Posted September 17, 2016 34 minutes ago, whismerhill said: Anyone knows what "inst" stands for btw ? "instance", it is an instance of a "prefab" - pre-fabricated. "entity" refers to widget entities too, but sometimes the difference between entity and instance are rather obscure, as these words basically mean the same thing. Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814733 Share on other sites More sharing options...
whatsherface Posted September 17, 2016 Author Share Posted September 17, 2016 Quote That's because "inst" is a generic variable used as a replacement for whatever object you're handling at the time. So in your example in "inst.components.follower" inst refers to the follower object which possess a follower component. Whereas inst in your character sam.lua refers to your character object e.g. "sam". Also if you think it through, it is logical that sam has no follower component since "he is not a follower" I know Mobbstar probably answered your question already in less words that I did but I thought you might be confused by those "inst" everywhere. Anyone knows what "inst" stands for btw ? That makes a lot of sense. Thank's for pointing that out. ^^ Quote The "Follower" component is what the follower has, the player has the "leader" component. Woodie has a small leader boost in DST too, I think, so check data\scripts\prefabs\woodie.lua out! I took a look through the woodie.lua where you specified and I'm having trouble finding anything about follower loyalty time. I read through it all and did a few ctrl Fs just for good measure. Am I missing something? I feel like this answer is glaringly obvious, sorry.. ;-; Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814756 Share on other sites More sharing options...
Mobbstar Posted September 17, 2016 Share Posted September 17, 2016 3 hours ago, whatsherface said: I feel like this answer is glaringly obvious, sorry.. ;-; It's not at all, actually. The devs decided to use a rather indescriptive tag: inst:AddTag("polite") Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814844 Share on other sites More sharing options...
whatsherface Posted September 17, 2016 Author Share Posted September 17, 2016 13 minutes ago, Mobbstar said: It's not at all, actually. The devs decided to use a rather indescriptive tag: inst:AddTag("polite") Okay so I found that and put it below my local common_postinit = function(inst) like it was in the woodie.lua. Now to change what I suppose would be the "level of politeness" ie: Loyalty time, Would I do something in the Master_postinit? Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814848 Share on other sites More sharing options...
Mobbstar Posted September 17, 2016 Share Posted September 17, 2016 (edited) 37 minutes ago, whatsherface said: Okay so I found that and put it below my local common_postinit = function(inst) like it was in the woodie.lua. Now to change what I suppose would be the "level of politeness" ie: Loyalty time, Would I do something in the Master_postinit? uhm... that's given by the game. You'd have to edit one or more of the "Follower" components' functions to do that (which is entirely possible, of course, but not always 100% mod compatible) You would have to overwrite the "receive item" function for every befriendable thing. That is difficult. Instead, you could add a bit of custom code to the recruitment function (in modmain.lua): AddComponentPostInit("follower", function(self) local _AddLoyalityTime = self.AddLoyaltyTime function self:AddLoyaltyTime(time, ...) if self.leader and self.leader:HasTag("superpolite") and GetTime() > 0 then time = time * 1.2 -- TUNE HERE ( you can also add absolute values instead of multiplying) end _AddLoyalityTime(self, time, ...) end end Edited September 17, 2016 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814850 Share on other sites More sharing options...
whatsherface Posted September 17, 2016 Author Share Posted September 17, 2016 Alright so I added: inst:AddTag("superpolite" To my Sam.lua and the code your provided to the modmain.lua like this: local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS AddComponentPostInit("follower", function(self) local _AddLoyalityTime = self.AddLoyaltyTime function self:AddLoyaltyTime(time, ...) if self.leader and self.leader:HasTag("superpolite") and GetTime() > 0 then time = time * 2 -- TUNE HERE ( you can also add absolute values instead of multiplying) end _AddLoyalityTime(self, time, ...) end end ) I got What did I do wrong? Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814951 Share on other sites More sharing options...
Mobbstar Posted September 17, 2016 Share Posted September 17, 2016 dang I messed up. Add "GLOBAL." in front of "GetTime" Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814953 Share on other sites More sharing options...
whatsherface Posted September 17, 2016 Author Share Posted September 17, 2016 Thank you so much! Link to comment https://forums.kleientertainment.com/forums/topic/70203-need-help-with-custom-perk-increased-follower-time/#findComment-814972 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