Jump to content

How to edit food-related sanity?


Recommended Posts

hey everyone

basically, i wanna know how to change the sanity loss/gain for specific items.
i wanna make it so the character gains sanity from raw meat, but loses it from cooked meat, and loses even more from veggies.

also, unrelated - 
where the heck is wheeler's lua? can't find it anywhere. i have every DLC. i even found wilba. 

Link to comment
Share on other sites

14 hours ago, CarlZalph said:

@ImDaMisterL Looks to be a DS mod question, as wheeler/wilba is not in DST.

I am making a character for DST, i wanted wheeler to check how her dodge action is written to see if i can use it as a base for unique actions with a  timer

13 hours ago, Ultroman said:

You will find wheeler.lua in the folder dont_starve\data\DLC0003\scripts\prefabs

This thread shows one example of giving alternate food values to a specific character. Read the note about caveats, though.

 Thanks for the help! ill try out some of the examples. a few other questions tho:

do food items have "tags" the way characters do? for exmaple, every meat item having the "meat" tag, or something. cuz if they dont, it would mean i will have to add every changed food value one by one, right?

also, what note? i didnt didnt find anything relating to caveats in the thread you linked :p

edit: also! how to make it so that the character cant eat the specific food item? is there a way to mark a food item as inedible for the specific character?

Link to comment
Share on other sites

1 hour ago, Minitay said:

also, what note? i didnt didnt find anything relating to caveats in the thread you linked :p

What? The third line of the post I linked says "NOTE:" in capital letters.

Try searching for it like this and this. There are many, many threads about many food related things. Some of the top ones have to do with something close to what you are looking for. Many with meat. This one may be the easiest, though a bit tedious. BUT it could be combined with this one that I linked earlier.

You can also see exactly which tags each prefab has, by opening the game files. In the scripts\prefabs\ folder you will find a file called "meats.lua". That has the code / data for most of the meat items in the game. But I usually just resort to making a list and iterating it, because I usually have very few affected items. In short, yes, the prefab file code applies many tags.

Link to comment
Share on other sites

14 hours ago, Ultroman said:

A "caveat" is a downside of something.

ooh, alright! i thought it was some coding term, lmfao

anyway, i followed the instructions i saw on the other post, and the game doesnt crash or anything, but it also doesnt apply the changed stats. for example, when i eat the batilisk wing, instead of giving 3 sanity, it takes away 10, like it does for every other character. 

i attached my character's lua since the code is too long for screenshots, i think 

hungry.lua

Link to comment
Share on other sites

Sorry, m8. That's my bad. I have made an error on the code.

Substitute this:

		if food_bonus["health"] then
			inst.components.hunger:DoDelta(food_bonus["health"])
		end
		if food_bonus["sanity"] then
			inst.components.hunger:DoDelta(food_bonus["sanity"])
		end
		if food_bonus["hunger"] then
			inst.components.hunger:DoDelta(food_bonus["hunger"])
		end

with this:

		if food_bonus["health"] then
			inst.components.health:DoDelta(food_bonus["health"])
		end
		if food_bonus["sanity"] then
			inst.components.sanity:DoDelta(food_bonus["sanity"])
		end
		if food_bonus["hunger"] then
			inst.components.hunger:DoDelta(food_bonus["hunger"])
		end

Also, you don't seem to have fully understood what the caveat means. The original food values are applied first, and then your values are applied afterwards. So, if the original food sanity-value is 10, and you want the food to only give your character 3 sanity, then your value should be -7, not 3. Then the 10 sanity will be applied first, and then your values get applied, -7, which results in 10-7 = 3.

Link to comment
Share on other sites

On 5/16/2019 at 10:01 PM, Ultroman said:

Sorry, m8. That's my bad. I have made an error on the code.

Substitute this:


		if food_bonus["health"] then
			inst.components.hunger:DoDelta(food_bonus["health"])
		end
		if food_bonus["sanity"] then
			inst.components.hunger:DoDelta(food_bonus["sanity"])
		end
		if food_bonus["hunger"] then
			inst.components.hunger:DoDelta(food_bonus["hunger"])
		end

with this:


		if food_bonus["health"] then
			inst.components.health:DoDelta(food_bonus["health"])
		end
		if food_bonus["sanity"] then
			inst.components.sanity:DoDelta(food_bonus["sanity"])
		end
		if food_bonus["hunger"] then
			inst.components.hunger:DoDelta(food_bonus["hunger"])
		end

Also, you don't seem to have fully understood what the caveat means. The original food values are applied first, and then your values are applied afterwards. So, if the original food sanity-value is 10, and you want the food to only give your character 3 sanity, then your value should be -7, not 3. Then the 10 sanity will be applied first, and then your values get applied, -7, which results in 10-7 = 3.

now i completely understand what you meant! thank you for the explanation and patience :3

i replaced the code and it works now, except a few items - when i input some specific dishes, the game wont load, claiming that " '(dish)' variable is not declared"

here are the dishes the game doesnt recognize, and the changes i made to them:

Spoiler

    meatballs { sanity = -10 },
    bonestew { sanity = -10 },
    monsterlasagna { sanity = 15 },
    perogies { sanity = -10 },
    powcake { sanity = -5 },
    pumpkincookie { sanity = -20 },
    ratatouille { sanity = -10 },
    stuffedeggplant { sanity = -10 },
    taffy { sanity = -20 },
    turkeydinner { sanity = -10 },
    unagi { sanity = -10 },
    waffles { sanity = -10 },
    wetgoop { health = 3, sanity = 1, hunger = 13 },

 

Link to comment
Share on other sites

7 hours ago, Ultroman said:

Hmm, those are all crockpot recipes. Interesting. Can you share the full code you have (attach a zip file to the post) and a log with the error happening?

i added the file :3

i also added other crockpot recipes, but they did work. its just those specific ones in the list not working

MOD.rar

Link to comment
Share on other sites

10 hours ago, Ultroman said:

This shows pretty clearly what's wrong. You're missing the = sign on those lines.

5ce1c9e494687_2019-05-1923_22_59-C__Users_Jonas_AppData_Local_Temp_7zOC77A717C_hungry.lua-Notepad.thumb.png.8334f33c455fb6dca09ca8ffc74b168a.png

oh! silly me, haha, totally escaped my gaze.

thank you for everything! that will be all for this thread :3

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...