JohnWatson Posted March 26, 2017 Share Posted March 26, 2017 I'm trying to make a pig character have the ability to eat Pig Skin. Lets say his name is Wheathghthoughougue. AddPrefabPostInit ("pigskin", function (inst) inst.components.edible.foodtype = GLOBAL.FOODTYPE.MEAT inst.components.edible.healthvalue = 2 inst.components.edible.sanityvalue = 4 inst.components.edible.hungervalue = 4 end) However, now all characters can eat Pig Skin. If I assign the Pig Skin its own food type, then it no longer uses the long eating animation. The reason for this is because only FOODTYPE.MEAT items use the long eating animation while all other food use the quick eating animation. I want only one character, Wheathghthoughougue, to have the ability to eat Pig Skin. But at the same time, I want Pig Skin to have the long eating animation. Link to comment Share on other sites More sharing options...
Serpens Posted March 26, 2017 Share Posted March 26, 2017 3 hours ago, JohnWatson said: I'm trying to make a pig character have the ability to eat Pig Skin. Lets say his name is Wheathghthoughougue. AddPrefabPostInit ("pigskin", function (inst) inst.components.edible.foodtype = GLOBAL.FOODTYPE.MEAT inst.components.edible.healthvalue = 2 inst.components.edible.sanityvalue = 4 inst.components.edible.hungervalue = 4 end) However, now all characters can eat Pig Skin. If I assign the Pig Skin its own food type, then it no longer uses the long eating animation. The reason for this is because only FOODTYPE.MEAT items use the long eating animation while all other food use the quick eating animation. I want only one character, Wheathghthoughougue, to have the ability to eat Pig Skin. But at the same time, I want Pig Skin to have the long eating animation. don't know it right out of the box, but maybe just take a look at other mods that sets diet ? They will modify the eat function for a specific player with maybe "not HasTag("meat")" or similar. And instead of forbidding meat, you can just allow/forbid pigskin this way. Link to comment Share on other sites More sharing options...
JohnWatson Posted March 26, 2017 Author Share Posted March 26, 2017 Just now, Serpens said: don't know it right out of the box, but maybe just take a look at other mods that sets diet ? They will modify the eat function for a specific player with maybe "not HasTag("meat")" or similar. And instead of forbidding meat, you can just allow/forbid pigskin this way. Most other mods that changes a character's diet use the FOODTYPE/FOODGROUP method. What I'm looking is preventing other characters from eating Pig Skin or only allowing one character to eat Pig Skin while retaining Pig Skin as FOODTYPE.MEAT. Link to comment Share on other sites More sharing options...
Serpens Posted March 26, 2017 Share Posted March 26, 2017 (edited) I did a quick search and I meant sth like this in your modmain: AddComponentPostInit("eater", function(self) local _TestFood = self.TestFood self.TestFood = function(self, food, testvalues) if self.inst:HasTag("player") and food and food.prefab=="pigksin" then -- fordbid every player to eat pigksin return false else return _TestFood(self, food, testvalues) -- if it is not pigskin, return the old function end end end) This will forbid every player character to eat pigskin. Edited March 26, 2017 by Serpens Link to comment Share on other sites More sharing options...
JohnWatson Posted March 26, 2017 Author Share Posted March 26, 2017 (edited) 3 minutes ago, Serpens said: I did a quick search and I meant sth like this in your modmain: AddComponentPostInit("eater", function(self) local _TestFood = self.TestFood self.TestFood = function(self, food, testvalues) if self.inst:HasTag("player") and food.prefab=="pigksin" then -- fordbid every player to eat pigksin return false else return _TestFood(self, food, testvalues) -- if it is not pigskin, return the old function end end end) This will forbid every player character to eat pigskin. Ah, so I just have to check if it's my character, Wheathghthoughougue, who is trying to eat the Pig Skin. Like 'if self.prefab = "wheathghthoughougue" then'. I'll try this. Edited March 26, 2017 by JohnWatson Link to comment Share on other sites More sharing options...
Serpens Posted March 26, 2017 Share Posted March 26, 2017 4 minutes ago, JohnWatson said: Ah, so I just have to check if it's my character, Wheathghthoughougue, who is trying to eat the Pig Skin. Like 'if self.prefab = "wheathghthoughougue" then'. I'll try this. yes. "self.inst" is the instance that is eating. So the line could be: if self.inst:HasTag("player") and food.prefab=="pigksin" and not self.inst.prefab=="wheathghthoughougue" then Link to comment Share on other sites More sharing options...
JohnWatson Posted March 26, 2017 Author Share Posted March 26, 2017 2 minutes ago, Serpens said: yes. "self.inst" is the instance that is eating. So the line could be: if self.inst:HasTag("player") and food.prefab=="pigksin" and not self.inst.prefab=="wheathghthoughougue" then Exactly what I used, and it worked perfectly. Thanks a lot, mate! I appreciate the help. Link to comment Share on other sites More sharing options...
JohnWatson Posted March 26, 2017 Author Share Posted March 26, 2017 (edited) Alright, now my problem is that other characters get an option to Eat the Pig Skin. They would perform the disgusted animation, though. However, I want other characters to not have an option to Eat the Pig Skin. I want them to be only able to inspect it. EDIT: Nevermind, I found a workaround and got what I wanted. Edited March 26, 2017 by JohnWatson Nevermind, I found a workaround and got what I wanted. Link to comment Share on other sites More sharing options...
Serpens Posted March 26, 2017 Share Posted March 26, 2017 2 hours ago, JohnWatson said: Alright, now my problem is that other characters get an option to Eat the Pig Skin. They would perform the disgusted animation, though. However, I want other characters to not have an option to Eat the Pig Skin. I want them to be only able to inspect it. EDIT: Nevermind, I found a workaround and got what I wanted. Can you tell us your workaround ? 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