Augustusc Posted February 5, 2016 Share Posted February 5, 2016 Im trying to get my character to eat grass. but i cant seem to work it out. i have followed this guides with no sucsess If i do solely Pyrobolser post, and the games doesn't crash, but it also doesn't let me eat grass. if i add rezecib post, the game crashes telling me there is a "(" in a weird place or something even though i am copy and pasting the code (and moving the words so it works, otherwise it's a straight line mess thing). From the guide i put there, the code is making a new foodtype, and then adding the non edibles to said group to make them edible, then its either adding the the items (grass and cutgrass) prefabs which does not cause a crash, but i cant seem to get my character to eat it. Or i don't touch the prefabs and add code to my modmain and get a crash. incase the guide is outdated or i'm just doing it wrong, i'm going to say that all i want to do is make cutgrass and the grass tuff (the one you get from using a shovel) to be edible on a single character. Thanks for taking the time to read this! Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/ Share on other sites More sharing options...
SenL Posted February 5, 2016 Share Posted February 5, 2016 Please post your code and we can help :). Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718068 Share on other sites More sharing options...
Augustusc Posted February 5, 2016 Author Share Posted February 5, 2016 (edited) -- Create foodtype 'Beefalo' GLOBAL.FOODTYPE.BEEFALO = "BEEFALO" local beefalo_food = {"grass", "cutgrass", } local function AddBeefaloFood(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.BEEFALO) end for k,v in pairs(beefalo_food) do AddPrefabPostInit(v, AddBeefaloFood) end In modmain. right after the whole thing here local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS local Eater = require "components/eater" local Text = require "widgets/text" local Image = require "widgets/image" The code that for some reason crashes my game is put in modmain too (right now it isnt in there) the code is AddPrefabPostInit ("grass", function (inst) inst:AddComponent ("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BEEFALO inst.components.edible.healthvalue = 20 inst.components.edible.sanityvalue = 10 inst.components.edible.hungervalue = 100 end Then i copy and paste that to also edit the "cutgrass" doing this crashes the game. the code that doesn't crash the game is put into the respective prefabs (which i hear causes mod incompatibility) --------------------- Mod edition : inst:AddComponent("edible") inst.components.edible.foodtype = FOODTYPE.HORRIBLE inst.components.edible.oneaten = function(inst, eater) if eater.prefab == "jeremiah" then eater.components.health:DoDelta(50) eater.components.hunger:DoDelta(50) eater.components.sanity:DoDelta(100) end end --------------------- End of mod edition The part of this code that says FOODTYPE.HORRIBLE isn't the problem, i can change it to FOODTYPE.BEEFALO and it doesn't change anything (though, i could be wrong) Edited February 5, 2016 by Augustusc I didn't give enough information/ i could have caused confusion Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718085 Share on other sites More sharing options...
zUsername Posted February 5, 2016 Share Posted February 5, 2016 AddPrefabPostInit ("grass", function (inst) inst:AddComponent ("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BEEFALO inst.components.edible.healthvalue = 20 inst.components.edible.sanityvalue = 10 inst.components.edible.hungervalue = 100 end) You are missing ")' at the end. Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718121 Share on other sites More sharing options...
Augustusc Posted February 5, 2016 Author Share Posted February 5, 2016 I put one in so that it looks like this AddPrefabPostInit ("grass",) function (inst) inst:AddComponent ("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BEEFALO inst.components.edible.healthvalue = 50 inst.components.edible.sanityvalue = 50 inst.components.edible.hungervalue = 100 end Gives me the same error. here is the error in detail (or at least how it say in game) Quote The following mod(s) have caused a failure: Jeremiah The Herder (TEST) [string "../mods/Jeremiah the herder/modmain.lua"]:62: unexpected symbol near ')' I tried removing the "," after "grass" but it gave another error, so it's not that. Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718147 Share on other sites More sharing options...
SenL Posted February 5, 2016 Share Posted February 5, 2016 (edited) You put ) in the wrong place. AddPrefabPostInit ("grass", function (inst) inst:AddComponent ("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.BEEFALO inst.components.edible.healthvalue = 20 inst.components.edible.sanityvalue = 10 inst.components.edible.hungervalue = 100 end ) --missing ) here Edited February 5, 2016 by SenL Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718196 Share on other sites More sharing options...
Augustusc Posted February 5, 2016 Author Share Posted February 5, 2016 well. it didn't crash this time, but i still cant seem to eat the grass. Atleast its a step in the right direction seeing as I can load the mod without it crashing Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718225 Share on other sites More sharing options...
SenL Posted February 6, 2016 Share Posted February 6, 2016 I don't think that's the way to go. It may make grass edible to all. Here's how I did with my mod (Groot): char lua: inst.components.eater:SetDiet({FOODGROUP.GROOT_FOODGROUP}) modmain lua: GLOBAL.FOODTYPE.GROOTFOOD = "GROOTFOOD" local groot_food = {"twigs", "log", "boards", "petals", "petals_evil", "pinecone", "cutgrass", "foliage", "cutlichen", "livinglog"} local function AddGrootFood(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.GROOTFOOD) end for k,v in pairs(groot_food) do AddPrefabPostInit(v, AddGrootFood) end GLOBAL.FOODGROUP.GROOT_FOODGROUP = { name = "GROOT_FOODGROUP" ,types = { GLOBAL.FOODTYPE.GROOTFOOD, } } Experts: please feel free to correct me. Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718307 Share on other sites More sharing options...
Augustusc Posted February 6, 2016 Author Share Posted February 6, 2016 It half worked. i now can eat grass.. but i cant eat anything else. Is the problem related to the set diet part? if so... how do i add more than just that the grass. and how do i add the grass tuff to the diet? (i tried putting grass as a thing, but it didn't work) Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718349 Share on other sites More sharing options...
zUsername Posted February 6, 2016 Share Posted February 6, 2016 (edited) inst.components.eater:SetDiet({FOODGROUP.BEEFALO, FOODGROUP.OMNI}) GLOBAL.FOODTYPE.BEEFALOFOOD = "BEEFALOFOOD" local beefalo_food = {"cutgrass", "dug_grass"} local function AddBeefaloFood(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.BEEFALOFOOD) end for k,v in pairs(beefalo_food) do AddPrefabPostInit(v, AddBeefaloFood) end GLOBAL.FOODGROUP.BEEFALO = { name = "BEEFALO", types = { GLOBAL.FOODTYPE.BEEFALOFOOD, } } Edited February 6, 2016 by zUsername Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718363 Share on other sites More sharing options...
Augustusc Posted February 6, 2016 Author Share Posted February 6, 2016 (edited) Everything works other than the dug_grass. that one is being so stubborn. I wonder what is wrong with it. I figured out what is wrong with the grass tuff. looking in the prefab of cutgrass, there is actually code for it being edible, but grass stuff doesn't have it. I really appreciate everyone helping me out, it seems to be problem after problem after problem. so i'm glad you guys are sticking around to help Edited February 6, 2016 by Augustusc I figured out something Link to comment https://forums.kleientertainment.com/forums/topic/63806-i-cant-seem-to-get-my-character-to-eat-grass/#findComment-718408 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