K-vo Posted October 3, 2016 Share Posted October 3, 2016 I'm working on a character that is supposed to be able to eat pretty much anything as their hunger drops VERY fast. I'm wanting to enable all the foodtypes outside of Omni as well but for the life of me I can't get the setdiet and some of the eater settings to work, it either freezes my game when I implement it or doesn't seem to enable. I'm pretty new to Lua, so I'm probably missing something really obvious. Am I correct in thinking that it's supposed to go in the character prefab? This is what I've got right now. Link to comment Share on other sites More sharing options...
whismerhill Posted October 3, 2016 Share Posted October 3, 2016 what's the error message you get ? if you get none, look up documents/klei/log.txt just above & below lua error stack traceback Link to comment Share on other sites More sharing options...
Mobbstar Posted October 3, 2016 Share Posted October 3, 2016 I believe there are important differences between DS and DST. Link to comment Share on other sites More sharing options...
K-vo Posted October 4, 2016 Author Share Posted October 4, 2016 Here's the error log @whismerhill, It just seems to crash straight out, no error message. And @Mobbstar good to know. I've also tried inst.components.eater.foodprefs but perhaps I'm incorrectly doing syntax? I'm not really sure. Thank you for taking the time to look. log.txt Link to comment Share on other sites More sharing options...
Mobbstar Posted October 4, 2016 Share Posted October 4, 2016 This code is DST-specific, but your mod is trying to run in DS. Set the table directly, for example: inst.components.eater.foodprefs = {"GENERIC", "SEEDS", "MEAT", "ETC"} Also, update the API version as set in modinfo.lua, the current one is 6 for DS and 10 for DST Link to comment Share on other sites More sharing options...
K-vo Posted October 5, 2016 Author Share Posted October 5, 2016 I've done as you said, and while it's no longer crashing, it seems to be having no effect at all on what the character can eat. It seems to be defaulting to basic omnivore. I used inst.components.eater.foodprefs = {"GENERIC", "SEEDS", "MEAT", "HORRIBLE", "ELEMENTAL", "INSECT", "VEGGIE", "WOOD"} Link to comment Share on other sites More sharing options...
whismerhill Posted October 6, 2016 Share Posted October 6, 2016 As an information this is what was important in the log file: Spoiler ...data/../mods/wickerman/scripts/prefabs/wickerman.lua:73: variable 'FOODGROUP' is not declared LUA ERROR stack traceback: =[C]:-1 in (global) error (C) <-1--1> E:/SteamLibrary/steamapps/common/dont_starve/data/scripts/strict.lua:23 in () ? (Lua) <21-26> t = table: 117FA738 n = FOODGROUP E:/SteamLibrary/steamapps/common/dont_starve/data/../mods/wickerman/scripts/prefabs/wickerman.lua:73 in (upvalue) customfn (Lua) <41-86> inst = 100030 - (valid:true) E:/SteamLibrary/steamapps/common/dont_starve/data/scripts/prefabs/player_common.lua:573 in (field) fn (Lua) <227-577> Sim = Sim (0E4CD010) inst = 100030 - (valid:true) a few times, some of the content that follows can be important, but mostly the first line is your problem. notice how it's just before "TRACEBACK", always is... Link to comment Share on other sites More sharing options...
whismerhill Posted October 6, 2016 Share Posted October 6, 2016 As for your issue, have you gotten a look at the component eater.lua file to see what can be done with it ? Link to comment Share on other sites More sharing options...
K-vo Posted October 7, 2016 Author Share Posted October 7, 2016 Thank you for that explanation of the log file! Also I've been looking at the eater.lua file and it seems all the diets correspond to things like Eater:SetOmnivore(), Eater:SetBeaver(), Eater:SetBird(), etc. the functions look like: function Eater:SetVegetarian() self.foodprefs = { "VEGGIE" } end Maybe creating a new eater type might work? I apologize for my noobness. Link to comment Share on other sites More sharing options...
whismerhill Posted October 7, 2016 Share Posted October 7, 2016 I am not an expert but indeed that seems like a good idea. maybe something with AddComponentPostInit which would add a new function something like this function Eater:InsertCanEat(data) table.insert(self.foodprefs, data) -- where data is any foodtype (copied from setcaneat horrible) end -- or alternatively function Eater:SetCanEatEverything() self.foodprefs = {"ELEMENTAL", ... } end Link to comment Share on other sites More sharing options...
K-vo Posted October 7, 2016 Author Share Posted October 7, 2016 I tried inputting this into modmain AddComponentPostInit("setcaneateverything", function (eater, inst) Eater:SetCanEatEverything() self.foodprefs = {"ELEMENTAL", "GENERIC", "HORRIBLE", "SEEDS", "INSECT", "VEGGIE", "MEAT", "WOOD" } end ) but when I place inst.components.eater:SetCanEatEverything("ELEMENTAL", "GENERIC", "HORRIBLE", "SEEDS", "INSECT", "VEGGIE", "MEAT", "WOOD" ) in the character file it says I'm calling a nil value. It did that when I placed inst.components.eater:SetCanEatEverything() as well. Link to comment Share on other sites More sharing options...
Mobbstar Posted October 7, 2016 Share Posted October 7, 2016 1 hour ago, K-vo said: I tried putting this into modmain The arguments are wrong, try this: AddComponentPostInit("eater", function (self) self:SetCanEatEverything() self.foodprefs = {"ELEMENTAL", "GENERIC", "HORRIBLE", "SEEDS", "INSECT", "VEGGIE", "MEAT", "WOOD" } end ) Link to comment Share on other sites More sharing options...
K-vo Posted October 7, 2016 Author Share Posted October 7, 2016 @mobbstar Thank you! I put that in. Currently the issue seems to be the line in the character prefab according to this in the log: ...data/../mods/wickerman/scripts/prefabs/wickerman.lua:73: attempt to call method 'SetCanEatEverything' (a nil value) which in that line is:inst.components.eater:SetCanEatEverything() How would I callback to the new eater function in the character prefab otherwise? Thanks again for your patience and assistance! It's much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
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.