Masterfuzzfuzz Posted December 18, 2016 Share Posted December 18, 2016 i have the below code in my mod that stops obedience from being decreased upon certain actions. TUNING.BEEFALO_DOMESTICATION_STARVE_OBEDIENCE = 0 TUNING.BEEFALO_DOMESTICATION_FEED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_FEED_OBEDIENCE*levelbonus TUNING.BEEFALO_DOMESTICATION_OVERFEED_OBEDIENCE = 0 TUNING.BEEFALO_DOMESTICATION_ATTACKED_BY_PLAYER_OBEDIENCE = 0 TUNING.BEEFALO_DOMESTICATION_BRUSHED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_BRUSHED_OBEDIENCE*levelbonus TUNING.BEEFALO_DOMESTICATION_SHAVED_OBEDIENCE = 0 But i can't figure out how to stop the passive decay. In the domesticatable.lua file there's this line: local OBEDIENCE_DECAY_RATE = -1/(TUNING.TOTAL_DAY_TIME * 2) But when I try domesticatable.OBEDIENCE_DECAY_RATE = 0 the game crashes Link to comment Share on other sites More sharing options...
Masterfuzzfuzz Posted December 19, 2016 Author Share Posted December 19, 2016 Any ideas? Link to comment Share on other sites More sharing options...
Serpens Posted December 19, 2016 Share Posted December 19, 2016 how about using an existing mod ?http://steamcommunity.com/sharedfiles/filedetails/?id=810294417 Link to comment Share on other sites More sharing options...
Masterfuzzfuzz Posted December 19, 2016 Author Share Posted December 19, 2016 56 minutes ago, Serpens said: how about using an existing mod ?http://steamcommunity.com/sharedfiles/filedetails/?id=810294417 Funny enough, that's my mod....lol the obedience is still decaying Link to comment Share on other sites More sharing options...
Serpens Posted December 19, 2016 Share Posted December 19, 2016 (edited) oh okay Unfortunately I never domesticated a beefalo, so I have absolutely no clue how this happens, what happens, what is normal and what you want to achieve =/ I guess domestication of an beefalo is similar to giving meat to an pig? It will follow you for a certain amount of time? But it seems you have "domestication" values and "obedience" values.. what is the difference of them? And why the devs wrote in domesticatable.lua "obedience still decays even if domestication decay is paused" ? Anyway: You can't change the "local OBEDIENCE_DECAY_RATE" because it is a local. That does mean it can only be accessed withing that script and nowhere else. It seems the devs are working on changing this, since over it you can see the note: "-- TODO: Make these configurable from the prefab" So I guess the easiest way would be to wait until the devs made this change. Maybe you can ask them directly here in forum if they have an ETA when this change will be released. The other alternative would be to change all functions that make use of the OBEDIENCE_DECAY_RATE and replace this value in those functions. But the problem is, that the function "UpdateDomestication" where it is used, is also a local thing... There is a hack from recezib which allows to also change local functions, but it is a bit complicated and should only be the last solution if nothing else is possible. So maybe you can change other values? How about chaning "minobedience" ? Would this help? Edited December 19, 2016 by Serpens Link to comment Share on other sites More sharing options...
Ryuushu Posted December 19, 2016 Share Posted December 19, 2016 (edited) I guess it crashes because OBEDIENCE_DECAY_RATE is a local value. If you do a quick, easy little search in the file you will be able to find where that value is used, which is a local function which is called by a public one. So, you could do: AddComponentPostInit("domesticatable", function(component) local oldCheckAndStartTask = component.CheckAndStartTask component.CheckAndStartTask = function(component) oldCheckAndStartTask() component:CancelTask() end end) CheckAndStartTask() starts the obedience decay task, so we just call this function for a moment (in case other mod uses it for some reason) and then we cancel the decay task right away. I might be missing some params since I don't really play around with components, but the answer should be more or less like this. Edited December 19, 2016 by Ryuushu Trying to index a local value from outside, missing some params Link to comment Share on other sites More sharing options...
Serpens Posted December 19, 2016 Share Posted December 19, 2016 (edited) Yes, the idea of Ryuushu is good. I guess the code with "component:CancelTask()" won't work, since he did not defined which task. So I guess the following code might be better: AddComponentPostInit("domesticatable", function(self) local oldCheckAndStartTask = self.CheckAndStartTask self.CheckAndStartTask = function(self) oldCheckAndStartTask(self) -- will create the self.decaytask if self.decaytask~=nil and GetModConfigData("nodecay") then -- now we cancel it self.decaytask:Cancel() self.decaytask = nil end end end) (it does not matter if you call it "component" or "self", it is just a name you can choose) The downside is, that the this way not only the obediance is stopped, but the whole stuff that is done in the "UpdateDomestication" function. edit: Ah, I just saw that the domesticatable indeed has a function that is called "CancelTask", which does exactly what I worte in my code :D. That's why component:CancelTask() will work. So code from Ryuushu should work. Sry. Edited December 19, 2016 by Serpens Link to comment 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