JennaBelle Posted September 2, 2020 Share Posted September 2, 2020 How do I make it so a character will only consume a single specific item, say, nightmare fuel or monster meat? And also allow this item to be safe for consumption for the specific character? I've tried a few things so far and all they did was return an error. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/ Share on other sites More sharing options...
DecDuck Posted September 2, 2020 Share Posted September 2, 2020 Look in Wigrid's character file. She only eats meat, so you could see how to do it there. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1368470 Share on other sites More sharing options...
JennaBelle Posted September 2, 2020 Author Share Posted September 2, 2020 12 hours ago, decduck3 said: Look in Wigrid's character file. She only eats meat, so you could see how to do it there. I did look at Wigfrid's file, along with several other characters with restricted diets. However, they seem to be restricted to a specific type of item, not a singular specific item alone. One I found had a few specific items rather that specific types of items but adjusting it so it was just 1 item returned an error. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1368644 Share on other sites More sharing options...
DecDuck Posted September 2, 2020 Share Posted September 2, 2020 Just make a type of food with just your food in it. That's probably what they did and that's why it returning an error. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1368645 Share on other sites More sharing options...
JennaBelle Posted September 3, 2020 Author Share Posted September 3, 2020 3 hours ago, decduck3 said: Just make a type of food with just your food in it. That's probably what they did and that's why it returning an error. can you explain that in more detail? Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1368692 Share on other sites More sharing options...
DecDuck Posted September 3, 2020 Share Posted September 3, 2020 Your food should have: inst:AddComponent("edible") And then you add the stats, right? Under that add: inst.components.edible.foodtype = "(name of food)_foodtype" Then you should be able to: inst.components.eater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT, FOODTYPE.GOODIES, "(name of food)_foodtype" }) The second parameter (after the first comma) is what they can eat. So right now this person can eat meat, goodies, and your food. 1 Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1368953 Share on other sites More sharing options...
JennaBelle Posted September 4, 2020 Author Share Posted September 4, 2020 On 9/3/2020 at 5:01 PM, decduck3 said: Your food should have: inst:AddComponent("edible") And then you add the stats, right? Under that add: inst.components.edible.foodtype = "(name of food)_foodtype" Then you should be able to: inst.components.eater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT, FOODTYPE.GOODIES, "(name of food)_foodtype" }) The second parameter (after the first comma) is what they can eat. So right now this person can eat meat, goodies, and your food. and this all goes in the character's prefab? Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369194 Share on other sites More sharing options...
DecDuck Posted September 5, 2020 Share Posted September 5, 2020 No. The first one should already be in your food. The second you need to put in your food. And the third goes in your player's master postinit Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369272 Share on other sites More sharing options...
JennaBelle Posted September 5, 2020 Author Share Posted September 5, 2020 (edited) 1 hour ago, decduck3 said: No. The first one should already be in your food. The second you need to put in your food. And the third goes in your player's master postinit So, only the third one goes in the character's prefab under master postinit. Then what folder/files do the other ones go in? You're talking to somebody that's extremely new at this. Edited September 5, 2020 by JennaBelle Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369279 Share on other sites More sharing options...
DecDuck Posted September 6, 2020 Share Posted September 6, 2020 Ok, can you post your food file and character file please? Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369458 Share on other sites More sharing options...
JennaBelle Posted September 6, 2020 Author Share Posted September 6, 2020 4 hours ago, decduck3 said: Ok, can you post your food file and character file please? I have the character's prefab file stuff pretty much down already. I'm just getting tripped up will this whole "food file" business that's you're mentioning. I don't even know where it's supposed to go or what to label it. I don't need you to do it for me. I just need some more detailed instructions so I can do it myself. I'm never going to learn if I just hand the work off to other people. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369482 Share on other sites More sharing options...
DecDuck Posted September 7, 2020 Share Posted September 7, 2020 Sorry about that. I just wanted to see how you defined your food. What I’m imagining is you have a prefab file with your food in it, right? Or do you have one file that had everything in it. What I meant be the “food file” is the prefab where you defined your food. (Also I’m assuming that you are using a modded food. Please tell me if this is not the case) Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369642 Share on other sites More sharing options...
JennaBelle Posted September 7, 2020 Author Share Posted September 7, 2020 (edited) 19 hours ago, decduck3 said: Sorry about that. I just wanted to see how you defined your food. What I’m imagining is you have a prefab file with your food in it, right? Or do you have one file that had everything in it. What I meant be the “food file” is the prefab where you defined your food. (Also I’m assuming that you are using a modded food. Please tell me if this is not the case) Currently I'm just really confused by the whole food file thing. I know that the third line of code goes in the character's prefab file under master postinit, but it sounded like you want me to make a separate file altogether for the first two and I can't even begin to figure out what folder that file should go in or what to even name it. That's kind of something I need to know before I can create it. Or can it go in the character's prefab file along with the third line of code? If so, what part would it need to be under? I've already found out that certain tags have to go in certain areas of the prefab or the thing just returns an error, so I assume this would do the same if I put it in the wrong place. Edit: I tried making a seperate file in the prefab folder for the first two lines of code you gave and used nightmare fuel for the test but it just kept crashing no matter what I did. Edited September 8, 2020 by JennaBelle update Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369812 Share on other sites More sharing options...
DecDuck Posted September 8, 2020 Share Posted September 8, 2020 (edited) What food do you want your character only to eat? Because that's where the lines go. If it's a modded food, you will have to create a new file. If, for example, you wanted them to only eat carrots, you would put it in the veggies.lua, underneath were carrot is defined. Edited September 8, 2020 by decduck3 Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1369928 Share on other sites More sharing options...
JennaBelle Posted September 8, 2020 Author Share Posted September 8, 2020 15 hours ago, decduck3 said: What food do you want your character only to eat? Because that's where the lines go. If it's a modded food, you will have to create a new file. If, for example, you wanted them to only eat carrots, you would put it in the veggies.lua, underneath were carrot is defined. It's different for different characters. I have a few to add this feature to. I'm testing it out with nightmare fuel though. The file needs to be somewhere in the custom character mod though since it has to be included with the character no matter who has the file. If I just edit the game files without including them in the mod then it won't work for anybody that downloads it because their files aren't modified. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370035 Share on other sites More sharing options...
DecDuck Posted September 9, 2020 Share Posted September 9, 2020 (edited) Just a heads up: If you create a file, with the same name, and in the same folder, but in your mod, you can override Klei's code. This isn't advised by you can do it. Using nightmare fuel: inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 inst.components.edible.foodtype = "nightmarefuel_foodtype" If you use an identical file to nightmarefuel.lua, but put that in the init function underneath this: if not TheWorld.ismastersim then return inst end Make sure it's indented! Then in whoever's character you want to eat, put in there file: inst.components.eater:SetDiet({ FOODGROUP.OMNI }, { "nightmarefuel_foodtype" }) Inside the master_postinit function. Edited September 12, 2020 by decduck3 Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370129 Share on other sites More sharing options...
JennaBelle Posted September 10, 2020 Author Share Posted September 10, 2020 19 hours ago, decduck3 said: Just a heads up: If you create a file, with the same name, and in the same folder, but in your mod, you can override Klei's code. This isn't advised by you can do it. Using nightmare fuel: inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 inst.components.edible.foodtype = "nightmarefuel_foodtype" If you use an identical file to nightmarefuel.lua, but put that in the init function underneath this: if not TheWorld.ismastersim then return inst end Make sure it's indented! Then in whoever's character you want to eat, put in there file: inst.components.eater:SetDiet({ FOODGROUP.OMNI }, { "nightmarefuel_foodtype" }) Inside the master_postinit function. (FYI, I still need to test this, so I will probably edit this post in a few hours) It didn't work. The game returned an error. It seemed to take issue with the whole "TheWorld" part. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370305 Share on other sites More sharing options...
DecDuck Posted September 10, 2020 Share Posted September 10, 2020 (edited) The could is meant to go underneath the TheWorld part. It should already be there. Edited September 12, 2020 by decduck3 Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370360 Share on other sites More sharing options...
JennaBelle Posted September 11, 2020 Author Share Posted September 11, 2020 19 hours ago, decduck3 said: The could is meant to go underneath the TheWorld part. It should already be there. It is underneath. I did it exactly like you said to. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370558 Share on other sites More sharing options...
DecDuck Posted September 11, 2020 Share Posted September 11, 2020 Could you post the entire file please? It worked for me. I have no idea what you have done. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370572 Share on other sites More sharing options...
JennaBelle Posted September 12, 2020 Author Share Posted September 12, 2020 18 hours ago, decduck3 said: Could you post the entire file please? It worked for me. I have no idea what you have done. I figured it out this afternoon. Apparently I needed to copy the nightmarefuel lua file from the game data to my mod instead of having a file with the same name. It's weird because none of the mods I looked at had to do that. I'm running into a new problem though. Testing with nightmare fuel, no "eat" option is given to the item in game. The character successfully refuses to eat anything else but without the eat option they can't eat the one thing they're allowed to. Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370727 Share on other sites More sharing options...
penguin0616 Posted September 13, 2020 Share Posted September 13, 2020 @JennaBelleYou need to add the edible component to it during the prefab creation. 1 Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1370979 Share on other sites More sharing options...
JennaBelle Posted September 13, 2020 Author Share Posted September 13, 2020 19 hours ago, penguin0616 said: @JennaBelleYou need to add the edible component to it during the prefab creation. can you explain? Will that add an "eat" option to the item? Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1371120 Share on other sites More sharing options...
penguin0616 Posted September 13, 2020 Share Posted September 13, 2020 (edited) @JennaBelleAdding the edible component makes it edible, which means you can eat it. So it will add the eat option. You can use :AddComponent("edible") to add the edible component. Edited September 14, 2020 by penguin0616 1 Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1371132 Share on other sites More sharing options...
JennaBelle Posted September 15, 2020 Author Share Posted September 15, 2020 On 9/13/2020 at 6:59 PM, penguin0616 said: @JennaBelleAdding the edible component makes it edible, which means you can eat it. So it will add the eat option. You can use :AddComponent("edible") to add the edible component. I'm assuming I should put this in the foodtype's file not the character prefab. Where in the file should it go? Link to comment https://forums.kleientertainment.com/forums/topic/121450-how-to-make-it-so-a-character-can-only-eat-a-specific-item/#findComment-1371385 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