Birdskull Posted June 14, 2019 Share Posted June 14, 2019 (edited) I'm working on creating a character based on a robin. Ideally she would be able to eat live insects, but I've hit a snag. When hovering over the insects, "murder" still comes up as the option rather than "eat." Does anyone know a workaround for this? Here's what I have in my modmain right now: GLOBAL.FOODTYPE.AVIAN = "AVIAN" local avian_food = {"butterfly",} local function AddAvian(inst) inst:AddTag("edible_"..GLOBAL.FOODTYPE.AVIAN) end for k,v in pairs(avian_food) do AddPrefabPostInit(v, AddAvian) end AddPrefabPostInit("butterfly", function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.AVIAN inst.components.edible.healthvalue = 5 inst.components.edible.sanityvalue = 5 inst.components.edible.hungervalue = 5 end) Edited June 15, 2019 by Birdskull Link to comment Share on other sites More sharing options...
Joy Machs Posted June 14, 2019 Share Posted June 14, 2019 I don't know much about LUA and MODs, but I think you need to write a "local function" in your mod script to make it edible. Like your code is now, maybe the game will not understant that your mod are saying: Now every butterflies and bees are edible. There is a mod who make Hambats edible. You could look the files of this mod and see its codes. https://steamcommunity.com/sharedfiles/filedetails/?id=1766419951 Link to comment Share on other sites More sharing options...
Birdskull Posted June 14, 2019 Author Share Posted June 14, 2019 18 minutes ago, Joy Machs said: I don't know much about LUA and MODs, but I think you need to write a "local function" in your mod script to make it edible. Like your code is now, maybe the game will not understant that your mod are saying: Now every butterflies and bees are edible. There is a mod who make Hambats edible. You could look the files of this mod and see its codes. https://steamcommunity.com/sharedfiles/filedetails/?id=1766419951 Thank you! Alas, it appears that edible hambat only lets you put the bat in the crockpot, not eat it outright. My code above does work for making things edible, say if I substitute a crow feather instead of butterflies/bees/mosquitoes. It just gets hung up on the "murder" when I use it with living inventory items and I don't know how to remove that. :c Link to comment Share on other sites More sharing options...
Joy Machs Posted June 14, 2019 Share Posted June 14, 2019 45 minutes ago, Birdskull said: Thank you! Alas, it appears that edible hambat only lets you put the bat in the crockpot, not eat it outright. I tested the MOD now and I could check that to eat the Ham Bat, you need burn it with a flame source. So it will become a "fried_ham_bat". So... thinking about it, the same way the autor of this mod was able to turn the hambat burnable, you could make this insects edible... Inside modmain and item scripts, the only code I think could be helpful is this: AddPrefabPostInit("hambat", function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end GLOBAL.MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME) inst.components.burnable:SetOnBurntFn(onburnt) It's the only time he mention the item "ham_bat" inside the files. Said that, couldn't you make a component who turn the insect edible in "modmain.lua"? I think I can't help more than that. Link to comment Share on other sites More sharing options...
Birdskull Posted June 15, 2019 Author Share Posted June 15, 2019 (edited) Alright, for anyone else who might be looking for a way for their character to eat insects, I solved this by creating a "dead" food prefab of each of the insects that they drop upon being murdered. *shrug* Here's the code for adding to their loot tables: AddPrefabPostInit("bee", function(inst) inst:AddComponent("lootdropper") inst.components.lootdropper:AddRandomLoot("YOURITEM1", 1) inst.components.lootdropper:AddRandomLoot("honey", 1) inst.components.lootdropper:AddRandomLoot("stinger", 5) inst.components.lootdropper.numrandomloot = 1 inst:AddComponent("cookable") inst.components.cookable.product = "YOURITEM1_COOKED" end) AddPrefabPostInit("killerbee", function(inst) inst:AddComponent("lootdropper") inst.components.lootdropper:AddRandomLoot("YOURITEM2", 1) inst.components.lootdropper:AddRandomLoot("honey", 1) inst.components.lootdropper:AddRandomLoot("stinger", 5) inst.components.lootdropper.numrandomloot = 1 inst:AddComponent("cookable") inst.components.cookable.product = "YOURITEM2_COOKED" end) AddPrefabPostInit("mosquito", function(inst) GLOBAL.SetSharedLootTable('mosquito', { {'mosquitosack', .5}, {'YOURITEM3', .5}, }) inst:AddComponent("cookable") inst.components.cookable.product = "YOURITEM3_COOKED" end) Edited June 16, 2019 by Birdskull 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