Fireandthethud Posted February 14, 2015 Share Posted February 14, 2015 So basically my character will have the ability to eat "bad foods" as regular food, but at a cost to sanity.The oneat() function so far is below:local function oneat(inst, food) Bad = {"monstermeat","cookedmonstermeat","green_cap","red_cap","blue_cap"} for k, v in pairs(Bad) do if food and food.components.edible and food.components.name == v then inst.components.sanity:DoDelta(TUNING.SANITY_TINY * 2) else end endendMy issue is that when I do eat monster meats, the sanity bonus (its a positive number now as a test) won't register, and I'm curious why that is. Is it the way I have it searching the list? or is the 3rd condition offood.components.name == v that is causing the problem? I haven't used Lua in a few years and I think those might be it. Link to comment https://forums.kleientertainment.com/forums/topic/50962-new-to-dont-starve-modding-need-help-with-gaining-sanity-from-some-foods/ Share on other sites More sharing options...
Mobbstar Posted February 14, 2015 Share Posted February 14, 2015 make sure you use local Bad = {...}, and you can also try the print(...) function to read in the log whether the code fired and the values. Link to comment https://forums.kleientertainment.com/forums/topic/50962-new-to-dont-starve-modding-need-help-with-gaining-sanity-from-some-foods/#findComment-613094 Share on other sites More sharing options...
Corrosive Posted February 15, 2015 Share Posted February 15, 2015 You're looking to match v against food.prefab, rather than food.components.name. Prefabs have the property prefab, which is a string containing the name of the prefab, as well as the property name, which is a string containing the display name of the prefab(which is not necessarily unique). The food component has neither of these properties. Link to comment https://forums.kleientertainment.com/forums/topic/50962-new-to-dont-starve-modding-need-help-with-gaining-sanity-from-some-foods/#findComment-613164 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