ElMilojita Posted May 1, 2020 Share Posted May 1, 2020 Hello everyone I am trying to make woodie not be able to eat any food with monter meat in it, however it does not seem to be working, I am not sure if the code is deprecated or something, I am using Ultroman's tutorial for woodie with restriction to eating certain food types or tagged, I will post both codes, mine and ultroman's tutorial reference to see what is wrong. if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldCanEat = inst.components.eater.CanEat function inst.components.eater:CanEat(inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("monstermeat") then return false end if oldCanEat ~= nil then return oldCanEat(inst) end return true end end) local oldCanEat = inst.components.eater.CanEat function inst.components.eater:CanEat(inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("mushroom") then return false end -- Check for certain foodtypes. This example makes all VEGGIES inedible. if inst.components.edible then if inst.components.edible.foodtype == "VEGGIES" then return false end end if oldCanEat ~= nil then return oldCanEat(inst) end return true end If I get the food restriction to work, I will set up more conditionals such as it being only applied if woodie is groggy, so that he cannot transform by eating monster meat or idols. if inst.components.grogginess.isgroggy == true then Here is the mod main in case you can find any issues with it, I highly doubt so, just in case. modmain.lua Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/ Share on other sites More sharing options...
Ultroman Posted May 1, 2020 Share Posted May 1, 2020 I believe I may be an idiot. Try this. if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldCanEat = inst.components.eater.CanEat function inst.components.eater:CanEat(inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("monstermeat") then return false end if oldCanEat ~= nil then return oldCanEat(self, inst) end return true end end) Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330228 Share on other sites More sharing options...
ElMilojita Posted May 1, 2020 Author Share Posted May 1, 2020 I tried running your code my woodie mod's main, nothing happened so then I decided to put it in a seperate blank mod main and I just keep on getting this error. local AllRecipes = GLOBAL.AllRecipes local RECIPETABS = GLOBAL.RECIPETABS local STRINGS = GLOBAL.STRINGS local TECH = GLOBAL.TECH TUNING = GLOBAL.TUNING GetPlayer = GLOBAL.GetPlayer if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldCanEat = inst.components.eater.CanEat function inst.components.eater:CanEat(inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("monstermeat") then return false end if oldCanEat ~= nil then return oldCanEat(self, inst) end return true end end end) I added the appropriate end's to see if it eliminated the <oef> but it keeps on doing it so I am not sure what to do else. Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330240 Share on other sites More sharing options...
Ultroman Posted May 1, 2020 Share Posted May 1, 2020 Your indentation is screwing with you. I think you pasted it in after your last "end". Try this: local AllRecipes = GLOBAL.AllRecipes local RECIPETABS = GLOBAL.RECIPETABS local STRINGS = GLOBAL.STRINGS local TECH = GLOBAL.TECH TUNING = GLOBAL.TUNING GetPlayer = GLOBAL.GetPlayer if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldCanEat = inst.components.eater.CanEat function inst.components.eater:CanEat(inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("monstermeat") then return false end if oldCanEat ~= nil then return oldCanEat(self, inst) end return true end end) end And get yourself Notepad++ and set the "Language" to Lua. Then you can easily see which "end" ends what. Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330242 Share on other sites More sharing options...
ElMilojita Posted May 1, 2020 Author Share Posted May 1, 2020 (edited) I already have note pad ++ , I do not understand why it is not working still.... Have you gone in game to see if it works? I am clueless about trying to call functions from components or retrieving them, that is what your code is trying to do I think by using functions in the Eater component. also used the code just provided Edited May 1, 2020 by ColombianCam I goofed Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330245 Share on other sites More sharing options...
Ultroman Posted May 1, 2020 Share Posted May 1, 2020 The code in your latest image is not my latest code. Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330247 Share on other sites More sharing options...
ElMilojita Posted May 1, 2020 Author Share Posted May 1, 2020 (edited) It is not, please refresh the page, I attached another image, sorry, I took another one to check the ending's of what my note pad++ showed. Ok the code no longers crash but woodie keeps on eating monster meat and idols Edited May 1, 2020 by ColombianCam Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330248 Share on other sites More sharing options...
Ultroman Posted May 1, 2020 Share Posted May 1, 2020 That code should work. Are you sure you're editing the file that your game is using, and not another copy of it? If it doesn't work, try this. I have a sneaking suspicion that I messed up something else in that post. local AllRecipes = GLOBAL.AllRecipes local RECIPETABS = GLOBAL.RECIPETABS local STRINGS = GLOBAL.STRINGS local TECH = GLOBAL.TECH TUNING = GLOBAL.TUNING GetPlayer = GLOBAL.GetPlayer if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldCanEat = inst.components.eater.CanEat inst.components.eater.CanEat = function(self, inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("monstermeat") then return false end if oldCanEat ~= nil then return oldCanEat(self, inst) end return true end end) end Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330250 Share on other sites More sharing options...
ElMilojita Posted May 1, 2020 Author Share Posted May 1, 2020 (edited) Yes I am sure, I even made another mod folder dedicated to this post in hopes of making it work. There's the mod main and modinfo inside the folder. What my modmain looks like: local AllRecipes = GLOBAL.AllRecipes local RECIPETABS = GLOBAL.RECIPETABS local STRINGS = GLOBAL.STRINGS local TECH = GLOBAL.TECH TUNING = GLOBAL.TUNING GetPlayer = GLOBAL.GetPlayer if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldCanEat = inst.components.eater.CanEat function inst.components.eater:CanEat(inst) -- Check for certain tags. This example makes all foods with the "mushroom" tag inedible. if inst:HasTag("monstermeat") then return false end if oldCanEat ~= nil then return oldCanEat(self, inst) end return true end end) end What my modinfo looks like name = "Wereformhunger test" description = "The wereforms have a lot of pontential, so I buffed them. Normal woodie still has the same perks before the refresh, made by Klei." author = "Gothy" version = "5.3" forumthread = "" api_version = 10 priority = -8000 server_filter_tags = {"Woodie mod", "wereform buffed"} dst_compatible = true all_clients_require_mod = true client_only_mod = false icon_atlas = "" icon = "" the mods I have enabled: then here I have woodie eating monster meat. my folder: Edited May 1, 2020 by ColombianCam Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330257 Share on other sites More sharing options...
Ultroman Posted May 1, 2020 Share Posted May 1, 2020 Did you try my newest code? I think that works. Sorry, I can't test where I am right now. Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330259 Share on other sites More sharing options...
ElMilojita Posted May 1, 2020 Author Share Posted May 1, 2020 No it does not work, I disabled all my client mods also. I am just by standby, I am gonna try to work on other things on my woodie mod, such as adding a button to deplete idols and transform. Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330265 Share on other sites More sharing options...
Ultroman Posted May 1, 2020 Share Posted May 1, 2020 (edited) Ah. Reading up on the latest game source code, they've changed the way the eater-component works. It is now PrefersToEat which you're supposed to extend. if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("woodie", function(inst) local oldPrefersToEat = inst.components.eater.PrefersToEat inst.components.eater.PrefersToEat = function(self, food) -- Check for certain tags. This example makes all foods with the "monstermeat" tag inedible. if food:HasTag("monstermeat") then return false end if oldPrefersToEat ~= nil then return oldPrefersToEat(self, food) end return true end end) end Edited May 1, 2020 by Ultroman Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330290 Share on other sites More sharing options...
ElMilojita Posted May 1, 2020 Author Share Posted May 1, 2020 Oh it worked out perfectly! Thank you! 1 Link to comment https://forums.kleientertainment.com/forums/topic/117887-no-monster-diet-character/#findComment-1330308 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