lakhnish Posted July 13, 2022 Share Posted July 13, 2022 (edited) In warly.lua, he has this going for him that makes him eat foods with the tags "preparedfoods" and "pre-preparedfoods": if inst.components.eater ~= nil then inst.components.eater:SetPrefersEatingTag("preparedfood") inst.components.eater:SetPrefersEatingTag("pre-preparedfood") end I've setup my own tags for Warly to eat, but these two present tags are still included in foods he can eat, which I don't want him to. Any advice on how to make it so that these two tags get removed or are ignored? Edit: The only thing I can think of is making a table of all the items with at least the prepared food tag and removing the tag that way, but that will just break more things instead. Edited July 13, 2022 by lakhnish Link to comment Share on other sites More sharing options...
Hornete Posted July 13, 2022 Share Posted July 13, 2022 (edited) 1 hour ago, lakhnish said: In warly.lua, he has this going for him that makes him eat foods with the tags "preparedfoods" and "pre-preparedfoods": if inst.components.eater ~= nil then inst.components.eater:SetPrefersEatingTag("preparedfood") inst.components.eater:SetPrefersEatingTag("pre-preparedfood") end I've setup my own tags for Warly to eat, but these two present tags are still included in foods he can eat, which I don't want him to. Any advice on how to make it so that these two tags get removed or are ignored? Edit: The only thing I can think of is making a table of all the items with at least the prepared food tag and removing the tag that way, but that will just break more things instead. function Eater:SetPrefersEatingTag(tag) if self.preferseatingtags == nil then self.preferseatingtags = { tag } else table.insert(self.preferseatingtags, tag) end end The SetPrefersEatingTag function places the tag into a table in the eater component that goes by 'preferseatingtags', you can loop through this table for Warly and remove any undesired tags in his prefab post init. for k, tag in pairs(inst.components.eater.preferseatingtags or {}) do --loop through this table (the 'or {}' is there just in case for whatever reason preferseatingtag is somehow nil, and thus it'll just default to an empty table to loop through) if tag == "preparedfood" or tag == "pre-preparedfood" then --if the tag is one of our undesired ones.. inst.components.eater.preferseatingtags[k] = nil --clear it from the table end end You could also just re-initalize the preferseatingtags table back to an empty one to completely clear it, but I suppose this way you get support with any other mod that also adds to this table for Warly specifically and whatever unique tags they may have added doesn't get removed. Edited July 13, 2022 by Hornete 1 Link to comment Share on other sites More sharing options...
lakhnish Posted July 13, 2022 Author Share Posted July 13, 2022 (edited) Thank you very much! I couldn't figure out how to remove that tag from that table. Edit: For those looking at this in the future, you also need to check to make sure that the component eater isn't nil before running the code or else you'll crash. AddPrefabPostInit("warly", function(inst) if inst.components.eater ~= nil then for k, tag in pairs(inst.components.eater.preferseatingtags or {}) do if tag == "preparedfood" or tag == "pre-preparedfood" then inst.components.eater.preferseatingtags[k] = nil end end end end) Edited July 13, 2022 by lakhnish Link to comment 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