Goregonzola Posted November 20, 2020 Share Posted November 20, 2020 Hey-hey! I'm making a character that would be only able to eat minerals (and hopefully some turfs). I have some questions about the execution: 1. I've found out that there are pre-existing food groups in the game - programming-vise (like FOODTYPE.SEEDS, FOODTYPE.ELEMENTAL, etc.). Is there a complete list that I could find about what items/foods are actually in these categories? 2. I was able to achieve to make my character able to eat minerals, and to add some of these minerals custom food values, using the coding in this thread: The question is: How can I achieve that the item-info-mods show the food stats I give to the minerals instead of the regular ones? 3. Are turfs fit into any of the food groups? If not, how could I make them eatable? Thanks in advance for the replies! Link to comment Share on other sites More sharing options...
penguin0616 Posted November 20, 2020 Share Posted November 20, 2020 (edited) @BillTheCipher 1) You'd have to use a "find in all files" feature to see which items use what food type, unfortunately, since they're set in the prefab constructors. 2) Nice. 2.5) It depends on two things: how you set up the food stats & eater, and how the item info mod processes it. Assuming you did the former normally, mods like Insight should show you the information (considering it works for WX78). 3) No, you'll have to make them eatable and give them a food group, a bit similar to how you did your mineral-eating. Edited November 20, 2020 by penguin0616 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 20, 2020 Author Share Posted November 20, 2020 @penguin0616 Thanks for the reply! Back to 2.5) a tiny bit: I've added extra stat bonuses on top of the already existing ones in the minerals, not completely changing them from the core (most of them had 1 Hunger and 10 Health stats by default). That's why it only shows the normal stats, isn't it? If so, is there a way to trick the system to take the extra stat boosts into calculation while showing the stats? Or should I find a way to change the stats from the core? Link to comment Share on other sites More sharing options...
penguin0616 Posted November 20, 2020 Share Posted November 20, 2020 @BillTheCipher What did you do to add the additional stat bonuses? 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 20, 2020 Author Share Posted November 20, 2020 @penguin0616 I've added the following to my prefab.lua: Spoiler inst.components.eater:SetDiet({FOODGROUP.OMNI, FOODTYPE.ELEMENTAL}, {FOODTYPE.ELEMENTAL}) inst.extrafoodstats = { bluegem = { health = 190, hunger = 195, sanity = 200 }, greengem = { health = 190, hunger = 195, sanity = 200 }, orangegem = { health = 190, hunger = 195, sanity = 200 }, purplegem = { health = 190, hunger = 195, sanity = 200 }, redgem = { health = 190, hunger = 195, sanity = 200 }, yellowgem = { health = 190, hunger = 195, sanity = 200 }, flint = {health = -10, hunger = 19, sanity = 10 }, goldnugget = { health = -5, hunger = 13, sanity = 15 }, nitre = { health = -10, hunger = 1, sanity = 35 }, rocks = { health = -7, hunger = 29, sanity = 0 }, moonrocknugget = { health = -25, hunger = 69, sanity = 5 }, } Link to comment Share on other sites More sharing options...
penguin0616 Posted November 20, 2020 Share Posted November 20, 2020 (edited) @BillTheCipher That wouldn't do anything to give you extra stats without additional code. I recommend you modify the edible's :GetSanity(eater), :GetHunger(eater), and :GetHealth(eater) to get the benefits. Here's an example. local oldGetSanity = edible.GetSanity edible.GetSanity = function(self, eater) if (eater and eater.prefab == "your_character_prefab" and eater.extrafoodstats and eater.extrafoodstats[self.inst.prefab]) then return eater.extrafoodstats[self.inst.prefab].sanity end return oldGetSanity(self, eater) end Edited November 20, 2020 by penguin0616 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 21, 2020 Author Share Posted November 21, 2020 @penguin0616 I'm afraid, I don't get this one fully. I'm still fairly amateur in this profession. Where should the food stats go in this coding? Let's say I would like Nitre to give 3 Hunger and 35 Sanity when eaten. How's that coding would look like (with character prefab: moleperson)? Link to comment Share on other sites More sharing options...
penguin0616 Posted November 21, 2020 Share Posted November 21, 2020 (edited) @BillTheCipher You can keep them where you have them right now. in AddComponentPostInit, you can add the edible overrides (you can use that sanity one as an example for health and hunger). Though you can also do something like this. Spoiler -- top of your player file local food_list = { bluegem = { health = 190, hunger = 195, sanity = 200 }, greengem = { health = 190, hunger = 195, sanity = 200 }, orangegem = { health = 190, hunger = 195, sanity = 200 }, purplegem = { health = 190, hunger = 195, sanity = 200 }, redgem = { health = 190, hunger = 195, sanity = 200 }, yellowgem = { health = 190, hunger = 195, sanity = 200 }, flint = {health = -10, hunger = 19, sanity = 10 }, goldnugget = { health = -5, hunger = 13, sanity = 15 }, nitre = { health = -10, hunger = 1, sanity = 35 }, rocks = { health = -7, hunger = 29, sanity = 0 }, moonrocknugget = { health = -25, hunger = 69, sanity = 5 }, } -- this goes in your post init player_thing_whatever:ListenForEvent("oneat", function(inst, data) -- data.food = what they eat -- data.feeder = who caused the player to eat (can be themselves or someone else) local food_bonus = food_list[data.food.prefab] if not food_bonus then return end local stack_mult = 1 -- additional logic from eater that you'll probably never have to use/deal with since its only used by bosses inst.components.health:DoDelta(food_bonus.health * stack_mult, nil, data.food.prefab) inst.components.hunger:DoDelta(food_bonus.hunger * stack_mult) inst.components.sanity:DoDelta(food_bonus.sanity * stack_mult) end) Each has its pros/cons. Former method means information mods will pick it up, but other mods that deal with custom foods may conflict with yours. Latter method means information mods will pretty much not pick it up, but has very little chance of clashing with other mods. Up to you which you prefer. ¯\_(ツ)_/¯ Edited November 21, 2020 by penguin0616 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 21, 2020 Author Share Posted November 21, 2020 @penguin0616 I start to feel really silly Is this how it should look like? Link to comment Share on other sites More sharing options...
penguin0616 Posted November 21, 2020 Share Posted November 21, 2020 (edited) @BillTheCipher Well, you need to replace "player_thing_whatever", as that's not a valid variable and was a placeholder. Beyond that, seems to be fine, assuming your postinit and mastersim checks are in place. Edited November 21, 2020 by penguin0616 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 21, 2020 Author Share Posted November 21, 2020 @penguin0616 Your patience is god-like, friend. Is the "player_thing_whatever" supposed to be "inst", my character's prefab name or something else? Link to comment Share on other sites More sharing options...
penguin0616 Posted November 22, 2020 Share Posted November 22, 2020 (edited) @BillTheCipher Since "inst" refers to your player entity, it is the correct one. Edited November 22, 2020 by penguin0616 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 22, 2020 Author Share Posted November 22, 2020 @penguin0616 Flawless. Thank you for your pateince 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