Scrumch Posted August 24, 2019 Share Posted August 24, 2019 Continuing from my last post, I figured out where I went wrong. I need to find a way to change the values of a food item when by a specific character? What would be the best way to do this? Link to comment Share on other sites More sharing options...
Serpens Posted August 24, 2019 Share Posted August 24, 2019 (edited) 10 hours ago, Scrumch said: Continuing from my last post, I figured out where I went wrong. I need to find a way to change the values of a food item when by a specific character? What would be the best way to do this? how about the perk from wortox which only receives half of every food value? It is done within his eater component, so within your masterpostinit after adding the eater component, simply do: if inst.components.eater ~= nil then inst.components.eater:SetAbsorptionModifiers(health, hunger, sanity) end replace health, hunger, sanity with your values. 1 will be normal, 0.5 will be half like wortox and so on. (eater component is most likely automatically added, so put this code just somewhere of masterpostinit) Edited August 24, 2019 by Serpens Link to comment Share on other sites More sharing options...
Scrumch Posted August 24, 2019 Author Share Posted August 24, 2019 I was more so thinking about making a specific food item give different values when this mod character eats it, but I will try that. Link to comment Share on other sites More sharing options...
Serpens Posted August 24, 2019 Share Posted August 24, 2019 So you have both, a custom character and a custom food item and you want that food to be eaten by every player, but only your player should get different values? Hm, no simple solution for this, although it is possible. But maybe you should think about an easy solution, like to make this food only eatable for your character? Or take a look at webbers monster meat code or I think Wormwood can eat manure? Link to comment Share on other sites More sharing options...
Thomas Die Posted August 24, 2019 Share Posted August 24, 2019 (edited) wouldn't be simple if it was a certain character to do this inst.component.edible.oneaten = custom function custom (inst , eater) if eater:HasTag("character tag") then ---------------------- # i think. if eater.prefab = "your character" then .should work too inst.components.edible.hungervalue = new value end end Edited August 24, 2019 by thomas4845 Link to comment Share on other sites More sharing options...
Serpens Posted August 24, 2019 Share Posted August 24, 2019 (edited) 45 minutes ago, thomas4845 said: wouldn't be simple if it was a certain character to do this inst.component.edible.oneaten = custom function custom (inst , eater) if eater:HasTag("character tag") then ---------------------- # i think. if eater.prefab = "your character" then .should work too inst.components.edible.hungervalue = new value end end if you take a look at the eater component, you see that "OnEaten" is called AFTER the hunger/helaht/sanity changes, so that would not solve it. There is a way to do it, but it might be kinda "hacky" (at least I can't imagine another way right now) and you should try to not use hacky ways, if there is an easier solution somehow. edit: Another simple way would be to use the foodmemory of warly. This checks for a specific food prefab and you could manipulate it that way, that it always returns 0.5 for a specific food if it is your character. Edited August 24, 2019 by Serpens Link to comment Share on other sites More sharing options...
Thomas Die Posted August 24, 2019 Share Posted August 24, 2019 idk then maybe go into the character then change it to when he eats it it'll create a increase in health basically stacking it ok i checked it up and it should be as simple as inst.components.eater.oneatfn = (newval) newval (inst, food) if food.prefab = "yourfood" then inst.components.hunger:dodelta("hunger value on top of the old one") # what i mean by this is that this value stacks on the old one end end Link to comment Share on other sites More sharing options...
Scrumch Posted August 24, 2019 Author Share Posted August 24, 2019 Should that go in the master_postint or in it's own function? Link to comment Share on other sites More sharing options...
Maris Posted August 24, 2019 Share Posted August 24, 2019 (edited) Even if you are making a food item, you MAY patch any character (including mod characters). All you need is prefab name of that character. So you can create AddPrefabPostInit initialization in modmain.lua. Are you interested in this method? Edited August 24, 2019 by Maris Link to comment Share on other sites More sharing options...
Serpens Posted August 24, 2019 Share Posted August 24, 2019 As I said, there are many way of achieving this. But I tried to offer some ways that are already existent within the game, so mods like ShowMe might catch the change (after the food absorption was implement :D). Link to comment Share on other sites More sharing options...
Maris Posted August 24, 2019 Share Posted August 24, 2019 In ShowMe there already is a method to catch the change. It was made few years ago. And it's described on API page of the mod. I was going to suggest a such method. I mean function FoodValuesChanger. That's why I'm talking about patching characters. Link to comment Share on other sites More sharing options...
Thomas Die Posted August 25, 2019 Share Posted August 25, 2019 14 hours ago, Scrumch said: Should that go in the master_postint or in it's own function? the function is a function the inst.component.eater.oneatfn = (newval) can go underneath the hunger components 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