Jump to content

Recommended Posts

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.

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.

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.

  • Thanks 1
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?

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 by JennaBelle
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.

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)

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 by JennaBelle
update

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 by decduck3
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.

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 by decduck3
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.

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.

@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 by penguin0616
  • Like 1
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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...