BraveChicken Posted July 8, 2018 Share Posted July 8, 2018 (edited) I have seen a lot of people which are still new to modding having troubles with the basic character perks, therefore I decided to create a simple tutorial showing you how to create some basic perks for your character. So if you're having trouble and are working on a mod for DS, RoG, or SW (or... all) then hopefully this could help you out at least a little bit! I know that I'm not the best modder out there, and that there can be few different ways to achieve some of these things in this tutorial, but I'm gonna focus mainly on the ways that I learned how to do them. ----------------------------------------------------------------------------------------------------------------IMPORTANTDST mods differ in their codding from the DS, RoG, and SW. So sadly this tutorial might not help you if you're working on a DST mod. ---------------------------------------------------------------------------------------------------------------- So most of you probably are already using a basic character template, which provides you with a basic modmain.lua file, same as a starter character prefab file which already has the basic list of assets, and character stats for you to manipulate. But just in case you don't have them, then here's where you can get them: Extended Sample Character << Click In this tutorial I'll show you how to: - Set/Change your characters Health, Sanity, and hunger. - Increase/Decrease/Turn off night and dusk sanity drain or reverse it. - Increase/Decrease/Turn off moisture sanity drain or reverse it. - Set a HP/Sanity/Hunger regen/damage over time. - Set a HP/Sanity/Hunger regen/damage during specified time of the day. - Set a HP/Sanity/Hunger regen/damage during specified season. - Set a HP/Sanity/Hunger regen/damage from rain or while being in caves. - Set a health/sanity/hunger regern/damage from temperature. - Set a health/sanity/hunger regern/damage from moisture. - Set a sanity/health/hunger loss/gain from attacking creatures. - Set a sanity/health/hunger loss/gain from killing creatures. - Set a Sanity regern/damage by equipping an item. - Erase/Increase/Decrease an existing sanity regen/damage on an item. - Add a sanity aura heal/damage to an item/creature. -------------------------- - Change your character's basic defense/attack power/speed. - Change defense/power/speed based on the time of the day. - Change defense/power/speed based on season. - Change defense/power/speed based on rain or caves. - Change defense/power/speed based on temperature. - Change defense/power/speed based on moisture. -------------------------- - Set your character's heat and cold resistance. - Increase/Decrease the HP damage when freezing/overheating. - Make your character fragile/resistant/immune to heat/cold. - Make your character immune to fire. - Turn your character into a monster or make it "not scary to prey". - Make the spiders/merm ignore your character (if unbothered). -------------------------- - Set/Change what your character can/can't eat. - Change the amount of sanity/health/hunger that a specified food gives. - Create a custom food type/group for your character. - Make an non-eatable item eatable to your character. --------------------------- - Give your character starting inventory items.- Make your character always start with a certain custom item (even in adventure mode). - Give your character a night vision/glow. - Unlock recipes for your character. - Change existing recipes. - Give your character custom recipes for existing items. - Remove the sanity gain/loss from picking flowers. - Mute your character. - Make your character unable to trigger spiders when walking on their webs. (All of the sections are in the same order as in the list above) BTW, I know that you'll see me repeat the same things many times in this tutorial, but that's just because I made it for people to be able to head right away to the section that they care to learn, without needing to read the whole thing. So I'm sorry if you'll find that annoying.Anyways, let's start! =========================================================================Health / Sanity / Hunger ========================================================================= --=====BASIC=====-- -- Set/Change the character's basic stats -- Spoiler In your character's prefab file you'll see the lines: inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(200) Those are the main stats of your character. By changing the numbers in the parentheses you'll change the main Health, Hunger, and Sanity stats of your character. So simply set them to the amount that you want your character to have. -- Increase/Decrease/Turn off night & dusk sanity drain or reverse it -- Spoiler To do that you'll need to head to your character's prefab file and add this line along with your character's stats. inst.components.sanity.night_drain_mult = 0 This is the line that we will work with. Increase sanity drain To increase the sanity drain during night and dusk simply change the number "0" at the end to a higher number (Example: change it to "3". inst.components.sanity.night_drain_mult = 3) and then test it out in the game. If you still won't be satisfied with the sanity drain, then feel free to increase the number as much as you need until you'll feel satisfied with the effect.(Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) Decrease sanity drain To decrease the sanity drain during night and dusk, simply change the number "0" at the end to any other low number (or "half number" like 0.5, 0.3, etc.) and then test it out in the game. If you still won't be satisfied with the effect, then feel free to lower down the number even more until you'll get the effect that you're looking for. Turn it off If you want the night and dusk sanity drain to be turned off, then simply leave the line the way it is. The number "0" at the end of it means that there will be no night and dusk sanity drain bothering your character. Reverse it to sanity regen This is a very simple thing to do. If you'll change the number "0" at the end to any negative number (Example: -3. inst.components.sanity.night_drain_mult = -3) then your character instead of losing sanity, will start gaining it during the night and dusk. If after testing it in the game you still won't be satisfied with the effect, then feel free to increase the number even more, until you'll get the effect that you want.(Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) -- Increase/Decrease/Turn off moisture sanity drain or reverse it -- Spoiler To do that you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Base code inst:DoTaskInTime( 0.1, function(inst) if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() then TUNING.MOISTURE_SANITY_PENALTY_MAX = 0 end end end) The basic line that we'll be working with is the "TUNING.MOISTURE_SANITY_PENALTY_MAX = 0" The "0" at the end shows how much sanity your character will be losing/gaining per second. If you want your character to have the moisture sanity drain turned off, then simply leave it as "0". If you would like your character to be gaining sanity then use numbers above 0. (like 0.5, 0.9, 1, 1.5, etc.) And if you want to increase the sanity drain then simply use negative numbers. (like -1, -1,5, -1,9, -2, etc.) --=====REGEN/DAMAGE BASED ON TIME OR SEASON=====-- -- Set a HP/Sanity/Hunger regen/damage over time -- Spoiler To make a HP/Sanity/Hunger regen/damage over time you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Health regen To make your character regenerate health over time you'll need to add this line along with your character's stats. inst.components.health:StartRegen(amount, period) This is the line that we will work with. In the parentheses you see the words "amount" and "period". Replace the word "amount" with the amount of HP that you want your character to be regenerating, and replace the word "period" with the time that you want your character to wait before regenerating the set amount of HP again.(Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) Example: inst.components.health:StartRegen(1, 5) This will make your character regenerate 1 HP every 5 seconds. Health drain To make your character lose health over time you'll need to add this line along with your character's stats. inst.components.health:StartRegen(amount, period) This is the line that we will work with. In the parentheses you see the words "amount" and "period". Replace the word "amount" with the amount of HP that you want your character to be losing, (just remember to place a "-" in front of the number. Example: -1) and replace the word "period" with the time that you want your character to wait before losing the set amount of HP again. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) Example: inst.components.health:StartRegen(-1, 5) This will make your character lose 1 HP every 5 seconds. Sanity regen To make your character regenerate sanity over time you'll need to add this line along with your character's stats. inst.components.sanity.dapperness = 1 The number "1" shows how much sanity your character will be regenerating per second. Simply increase/decrease the number until you'll get the effect that you'll looking for.(Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) Sanity drain To make your character lose sanity over time you'll need to add this line along with your character's stats. inst.components.sanity.dapperness = -1 The number "-1" shows how much sanity your character will be losing per second. Simply increase/decrease the number until you'll get the effect that you'll looking for.(Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) Hunger: Increase calorie burn(1st method) To increase how fast you want your character to be getting hungry, you'll need to find (or add, if you don't have it) this line in your character's prefab file: inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE This is the line that we will work with. By increasing the number "1" you will increase the speed in which your character will be getting hungry. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) You can also change the line like this: inst.components.hunger.hungerrate = 1 Then the number "1" show you how much hunger points the character will be losing per second. (So you might want to work with "half numbers" like 0.5, 0.3, over here.) You may use which ever method seems the most comfortable to you. (2nd method) To increase how fast you want your character to be getting hungry, you'll need to add this line in your character's prefab file: inst.components.hunger.burnrate = 3 This is the line that we will work with. By increasing the number "3" you will increase the speed in which your character will be getting hungry. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) Hunger: Lower calorie burn To lower the speed in which your character gets hungry, you'll need to add this line in your character's prefab file: inst.components.hunger.burnrate = 1 This is the line that we will work with. By decreasing the number "1" you will decrease the speed in which your character will be getting hungry. (Remember that you can also use "half numbers" like 0.5, 0.7, 0.1 etc.) Hunger: Reverse(No idea why would you need it but I'm gonna show you how to do it anyways XD)(1st method) To make your character getting less hungry rather than more hungry over time, you'll need to find (or add, if you don't have it) this line in your character's prefab file: inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE This is the line that we will work with. By adding a "-" in front of the number "1" you will reverse the hunger effect. By increasing the number you'll increase the speed in which your character will be getting less hungry. (Example: inst.components.hunger.hungerrate = -1 * TUNING.WILSON_HUNGER_RATE)(Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) You can also change the line like this: inst.components.hunger.hungerrate = -1 Then the number "1" show you how much hunger points the character will be gaining per second. (So you might want to work with "half numbers" like 0.5, 0.3, over here.) You may use which ever method seems the most comfortable to you. (2nd method) To make your character getting less hungry rather than more hungry over time, you'll need to add this line in your character's prefab file: inst.components.hunger.burnrate = -1 This is the line that we will work with. By adding a "-" in front of the number "1" you will reverse how hunger works. By increasing the number you'll increase the speed in which your character will be getting less hungry. Hunger: Stop(1st method) To stop your character from getting hungry you'll need to find (or add, if you don't have it) this line in your character's prefab file: inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE And then simply change it to: inst.components.hunger.hungerrate = 0 This will stop your character from getting hungry. (2nd method) To stop your character from getting hungry you'll need to add this line in your character's prefab file: inst.components.hunger.burnrate = 0 The "0" at the end shows that your character won't be burning any calories, and therefore won't be getting hungry. -- Set a HP/Sanity/Hunger regen/damage during specified time of the day -- Spoiler If you want your character to gain/lose HP/Sanity/Hunger during a specified time of the day, then you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 1 (Active)Example: inst.components.sanity.dapperness = 0.5 inst.components.health:StartRegen(1, 2) inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 2 Depending what you wish to be drained/regenerated during the specified time of day (Day, Dusk, or Night) you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the Health, Sanity, and Hunger drain/regen in the "Set a HP/Sanity/Hunger regen/damage over time" section above, as this will work the same way. Base code (During only 1 specified time of the day) inst:AddTag("notactive") local function CheckTime(inst) if GetClock() and GetWorld() then if not GetClock():IsDay() and inst:HasTag("active") and not GetWorld():IsCave() then PLACE HERE THE INACTIVE PERK inst:AddTag("notactive") inst:RemoveTag("active") end if GetClock():IsDay() and inst:HasTag("notactive") and not GetWorld():IsCave() then PLACE HERE THE ACTIVE PERK inst:AddTag("active") inst:RemoveTag("notactive") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTime(inst) end) Now, depending on which time of the day you want your character's perks to activate (Day, Dusk, or Night) simply change the "GetClock():IsDay()" which I marked, to "GetClock():IsDusk()" or "GetClock():IsNight()". And don't forget to place the lines of your character's active/inactive perks in the marked spot. Base code (Different during all parts of the day) inst:AddTag("notactive") local function CheckTime(inst) if GetClock() and GetWorld() then if GetClock():IsDay() and (inst:HasTag("notactive") or inst:HasTag("activedusk") or inst:HasTag("activenight")) and not GetWorld():IsCave() then PLACE HERE THE ACTIVE / INACTIVE PERK inst:AddTag("activeday") inst:RemoveTag("notactive") inst:RemoveTag("activedusk") inst:RemoveTag("activenight") end if GetClock():IsDusk() and (inst:HasTag("notactive") or inst:HasTag("activeday") or inst:HasTag("activenight")) and not GetWorld():IsCave() then PLACE HERE THE ACTIVE / INACTIVE PERK inst:AddTag("activedusk") inst:RemoveTag("notactive") inst:RemoveTag("activeday") inst:RemoveTag("activenight") end if GetClock():IsNight() and (inst:HasTag("notactive") or inst:HasTag("activedusk") or inst:HasTag("activeday")) and not GetWorld():IsCave() then PLACE HERE THE ACTIVE / INACTIVE PERK inst:AddTag("activenight") inst:RemoveTag("notactive") inst:RemoveTag("activedusk") inst:RemoveTag("activeday") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTime(inst) end) Use this base code instead, if you wish to make your perk to be different in each part of the day.Side note: If you are working on a custom sanity perk, then remember that unless you have the night/dusk sanity drain turned off, your sanity perk will be affected by it if it'll be activated during dusk or night. -- Set a HP/Sanity/Hunger regen/damage during specified season -- Spoiler If you want your character to gain/lose HP/Sanity/Hunger during a specified season, then you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 1 (Active)Example: inst.components.sanity.dapperness = 0.5 inst.components.health:StartRegen(1, 2) inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 2 Depending what you wish to be drained/regenerated during the specified season, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the Health, Sanity, and Hunger drain/regen in the "Set a HP/Sanity/Hunger regen/damage over time" section above, as this will work the same way. Base code (RoG) inst:ListenForEvent("seasonChange", function(it, data) if data.season == SEASONS.WINTER then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SPRING then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.AUTUMN then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SUMMER then PLACE HERE THE ACTIVE/INACTIVE PERKS end end, GetWorld()) Depending on the season that you want your character's perks to activate, place the active perks there, while placing the inactive ones to the section of the other seasons. Side note: If you are working on a custom sanity perk, then remember that unless you have the night/dusk sanity drain turned off, your sanity perk will be affected by it during dusk and night. Base code (DS) & (RoG) The normal DS works a bit differently than the DLCs. The game won't notice what season it is unless it just got changed. Therefore we'll need trigger it ourselves. inst:ListenForEvent("seasonChange", function(it, data) if data.season == SEASONS.WINTER then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SPRING then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.AUTUMN then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SUMMER then PLACE HERE THE ACTIVE/INACTIVE PERKS end end, GetWorld()) inst:PushEvent("seasonChange") (The last line is literally all we added for it to work!) Depending on the season that you want your character's perks to activate, place the active perks there, while placing the inactive ones to the section of the other season(s). If you don't intend for your mod to be compatible with RoG then you can erase the grayed out lines, as they won't be necessary. Side note: If you are working on a custom sanity perk, then remember that unless you have the night/dusk sanity drain turned off, your sanity perk will be affected by it during dusk and night. I would try and give also a base code for the SW version, but... I sadly don't have SW to be aware of what is, and what isn't in the game there. Sorry about that. --=====REGEN/DAMAGE BASED ON LOCATION OR RAIN=====-- -- Set a HP/Sanity/Hunger regen/damage from rain or while being in caves -- Spoiler If you want your character to gain/lose HP/Sanity/Hunger during rain/while being in caves, then you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 1 (Active)Example: inst.components.sanity.dapperness = 0.5 inst.components.health:StartRegen(1, 2) inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 2 Depending what you wish to be drained/regenerated during rain/while being in caves, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the Health, Sanity, and Hunger drain/regen in the "Set a HP/Sanity/Hunger regen/damage over time" section above, as this will work the same way. Base code (rain) inst:AddTag("notactiverain") local function CheckForRain(inst) if GetSeasonManager() then if not GetSeasonManager():IsRaining() and inst:HasTag("activerain") then PLACE HERE THE INACTIVE PERK inst:AddTag("notactiverain") inst:RemoveTag("activerain") end if GetSeasonManager():IsRaining() and inst:HasTag("notactiverain") then PLACE HERE THE ACTIVE PERK inst:AddTag("activerain") inst:RemoveTag("notactiverain") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckForRain(inst) end) Base code (caves) inst:AddTag("notactivecave") local function CheckArea(inst) if GetWorld() then if inst:HasTag("activecave") and not GetWorld():IsCave() then PLACE HERE THE INACTIVE PERK inst:AddTag("notactivecave") inst:RemoveTag("activecave") end if inst:HasTag("notactivecave") and GetWorld():IsCave() then PLACE HERE THE ACTIVE PERK inst:AddTag("activecave") inst:RemoveTag("notactivecave") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckArea(inst) end) Side note: If you are working on a custom sanity perk, then remember that unless you have the night/dusk sanity drain turned off, your sanity perk will be affected by it while you're in caves/in the dark. --=====REGEN/DAMAGE BASED ON TEMPERATURE OR MOISTURE=====-- -- Set a health/sanity/hunger regern/damage from temperature -- Spoiler To make your character lose/gain sanity/health/hunger when reaching a certain temperature, you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 1 (Active)Example: inst.components.sanity.dapperness = 0.5 inst.components.health:StartRegen(1, 2) inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 2 Depending what you wish to be drained/regenerated when your character will reach the set temperature, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the Health, Sanity, and Hunger drain/regen in the "Set a HP/Sanity/Hunger regen/damage over time" section above, as this will work the same way. Base code local function CheckTemperature(inst) if inst.components.temperature then local t = inst.components.temperature if t:GetCurrent() > 30 and not inst:HasTag("tempy") then inst:AddTag("tempy") inst:RemoveTag("tempx") PLACE HERE THE ACTIVE/INACTIVE PERKS end if t:GetCurrent() < 30 and not inst:HasTag("tempx") then inst:AddTag("tempx") inst:RemoveTag("tempy") PLACE HERE THE ACTIVE/INACTIVE PERKS end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTemperature(inst) end) Depending on the temperature that you want your character's perks to react to, you'll need to change the number "30" to higher or lower. The " > " means that the perk will get triggered once your character surpasses the set temperature. The " < " means that the perk will get triggered once your character will go below the set temperature. Depending on when you want your character's perk to get active/inactive, place the active/inactive perks in the right spots. Temperature info: Any temperature below 15 is cold. Any temperature above 60 is hot. Characters start to freeze when they reach temperature 0. Characters start to overheat when they reach temperature 70. -- Set a health/sanity/hunger regern/damage from moisture -- Spoiler To make your character lose/gain sanity/health/hunger when reaching a certain moisture, you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. When reaching set moisture Basic lines that you'll be working with(Inactive) inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 1 (Active)Example: inst.components.sanity.dapperness = 0.5 inst.components.health:StartRegen(1, 2) inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 2 Depending what you wish to be drained/regenerated when your character will reach the set moisture, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the Health, Sanity, and Hunger drain/regen in the "Set a HP/Sanity/Hunger regen/damage over time" section above, as this will work the same way. Base code local function CheckMoisture(inst) if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() > 20 and not inst:HasTag("moisty") then inst:AddTag("moisty") PLACE HERE THE ACTIVE/INACTIVE PERKS end if m:GetMoisture() < 20 and inst:HasTag("moisty") then inst:RemoveTag("moisty") PLACE HERE THE ACTIVE/INACTIVE PERKS end end end inst:DoPeriodicTask( 0.0, function(inst) CheckMoisture(inst) end) Depending on the moisture that you want your character's perks to react to, you'll need to change the number "20" to higher or lower. The " > " means that the perk will get triggered once your character surpasses the set moisture. The " < " means that the perk will get triggered once your character will go below the set moisture. Depending on when you want your character's perk to get active/inactive, place the active/inactive perks in the right spots. Side note: If you are working on a custom sanity perk, then remember that unless you have the night/dusk sanity drain turned off, your sanity perk will be affected by it, same as it still will be affected by the games preset sanity drain from moisture. Increase/Decrease along with moisture Basic lines that you'll be working with(Inactive) inst.components.sanity.dapperness = 0 inst.components.health:StartRegen(0, 0) inst.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = 1 (Active)Example: inst.components.sanity.dapperness = m / 40 inst.components.health:StartRegen(cm, 2) inst.components.hunger.hungerrate = (cm / 10) * TUNING.WILSON_HUNGER_RATE or inst.components.hunger.burnrate = cm / 2 (By increasing the numbers marked with green you will decrease their effect on your character. While by decreasing them you will increase their effect on your character) Depending what you wish to be drained/regenerated along with the moisture, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the Health, Sanity, and Hunger drain/regen in the "Set a HP/Sanity/Hunger regen/damage over time" section above. Base code local function CheckMoisture(inst) if inst.components.moisture then local m = inst.components.moisture:GetMoisture() local cm = inst.components.moisture:GetMoisture() / 10 if m > 0 and not inst:HasTag("moist") then inst:AddTag("moist") PLACE HERE THE ACTIVE PERKS end if m == 0 and inst:HasTag("moist") then inst:RemoveTag("moist") PLACE HERE THE INACTIVE PERKS end end end inst:DoPeriodicTask( 0.0, function(inst) CheckMoisture(inst) end) This one will make your character's perk to increase/decrease it's effectivity along with the increasing/decreasing moisture. The number "10" in the line "local cm = inst.components.moisture:GetMoisture() / 10" shows how much the current moisture value will be divided and set as your current HP/Sanity/Hunger regen/damage. (As higher the number as lower the effect that your character will gain per moisture level. And the other way around. As lower the number as higher the effect that your character will gain per moisture level.) You may increase/decrease it until you'll reach the effect that you're looking for. Side note: If you are working on a custom sanity perk, then remember that unless you have the night/dusk sanity drain turned off, your sanity perk will be affected by it, same as it still will be affected by the games preset sanity drain from moisture. --=====REGEN/DAMAGE BASED ON KILL OR ATTACK=====-- -- Set a sanity/health/hunger loss/gain from attacking creatures -- Spoiler To make your character lose/gain sanity from attacking creatures, you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Sanity/Health/Hunger gain/loss from any creature local function OnHit(inst) inst.components.sanity:DoDelta(2) end inst:ListenForEvent("onhitother",OnHit) Depending on what you wish your character to gain/lose (health, sanity, or hunger) simply change the "components.sanity:DoDelta" to "components.health:DoDelta" or "components.hunger:DoDelta". This will make your character gain sanity/health/huger when attacking any creature. The number "2" is the amount of sanity/health/hunger that your character will be regaining per attack. To increase/decrease the amount of sanity/health/hunger gain, simply increase/decrease the number in the parentheses. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) To make your character lose sanity/health/hunger when attacking creatures, simply add a " - " in front of the number. That will cause your character to lose the set amount of sanity/health/hunger. (Example: -2. inst.components.sanity:DoDelta(-2) ) Sanity/Health/Hunger gain/loss from specified creature(s) First, you need to know the prefab name of the creature that you want your character's perk to react to, then you'll be simply placing it into the "base code" that you'll find below. (If you are not sure, or don't know what is the prefab name of the creature that you want, then you can head to the Don't starve Wiki and look for that creature there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code local function OnHit(target,inst) if target and target.prefab then if target.prefab == "CreatureHere" then inst.components.sanity:DoDelta(2) end end end inst:ListenForEvent( "onhitother", function(inst,data) OnHit(data.target,inst) end ) Depending on what you wish your character to gain/lose (health, sanity, or hunger) simply change the "components.sanity:DoDelta" to "components.health:DoDelta" or "components.hunger:DoDelta". The number "2" that you see in the parentheses is the amount of sanity/health/hunger that your character will be regaining per hit. You can of course increase/decrease that number to your liking. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) If you want your character to be losing sanity/health/hunger instead of gaining it, then simply place a " - " in front of the number (Example: -2. inst.components.sanity:DoDelta(-2)). This will make your character lose the set amount of sanity/health/hunger. Adding more creatures to the list Let's say for the sake of the example that you wish to make your character lose sanity each time it'll attack a rabbit, and gain sanity when it'll attack a spider. The thing that you'll need to do in order to add more creatures to your list, is to simply copy-paste the lines that I marked with blue, then place the creature's prefab name and set the amount of sanity/health/hunger that your character will be gaining/losing. Example: local function OnHit(target,inst) if target and target.prefab then if target.prefab == "rabbit" then inst.components.sanity:DoDelta(-2) end if target.prefab == "spider" then inst.components.sanity:DoDelta(2) end end end inst:ListenForEvent( "onhitother", function(inst,data) OnHit(data.target,inst) end ) Just like that, you can add as many creatures to the list as you want. -- Set a sanity/health/hunger loss/gain from killing creatures -- Spoiler To make your character lose/gain sanity/health/hunger from killing creatures, you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Sanity gain/loss from any creature local function OnKill(inst) inst.components.sanity:DoDelta(2) end inst:ListenForEvent("killed",OnKill) Depending on what you wish your character to gain/lose (health, sanity, or hunger) simply change the "components.sanity:DoDelta" to "components.health:DoDelta" or "components.hunger:DoDelta". The number "2" that you see in the parentheses is the amount of sanity/health/hunger that your character will be regaining per kill. You can of course increase/decrease that number to your liking. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) If you want your character to be losing sanity/health/hunger instead of gaining it, then simply place a " - " in front of the number (Example: -2. inst.components.sanity:DoDelta(-2)). This will make your character lose the set amount of sanity/health/hunger. Sanity/Health/Hunger gain/loss from specified creature(s) First, you need to know the prefab name of the creature that you want your character's perk to react to, then you'll be simply placing it into the "base code" that you'll find below. (If you are not sure, or don't know what is the prefab name of the creature that you want, then you can head to the Don't starve Wiki and look for that creature there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code local function OnKill(victim,inst) if victim and victim.prefab then if victim.prefab == "CreatureHere" then inst.components.sanity:DoDelta(2) end end end inst:ListenForEvent( "killed", function(inst,data) OnKill(data.victim,inst) end ) Depending on what you wish your character to gain/lose (health, sanity, or hunger) simply change the "components.sanity:DoDelta" to "components.health:DoDelta" or "components.hunger:DoDelta". The number "2" that you see in the parentheses is the amount of sanity/health/hunger that your character will be regaining per kill. You can of course increase/decrease that number to your liking. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) If you want your character to be losing sanity/health/hunger instead of gaining it, then simply place a " - " in front of the number (Example: -2. inst.components.sanity:DoDelta(-2)). This will make your character lose the set amount of sanity/health/hunger. Adding more creatures to the list Let's say for the sake of the example that you wish to make your character lose sanity each time it'll kill a rabbit, and gain sanity when it'll kill a spider. The thing that you'll need to do in order to add more creatures to your list, is to simply copy-paste the lines that I marked with blue, then place the creature's prefab name and set the amount of sanity/health/hunger that your character will be gaining/losing. Example: local function OnKill(victim,inst) if victim and victim.prefab then if victim.prefab == "rabbit" then inst.components.sanity:DoDelta(-2) end if victim.prefab == "spider" then inst.components.sanity:DoDelta(2) end end end inst:ListenForEvent( "killed", function(inst,data) OnKill(data.victim,inst) end ) Just like that, you can add as many creatures to the list as you want. --=====REGEN/DAMAGE BASED ON ITEMS OR CREATURES=====-- -- Set a sanity regern/damage by equipping an item -- Spoiler To make a certain item recover/damage your character's Sanity, you'll need to add that perk on the item. So for that you'll need to head to your modmain.lua, and for starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. First, you need to know the prefab name of the item that you want to manipulate, then you'll be simply placing it into the "base code" that you'll find below. (If you are not sure, or don't know what is the prefab name of the item that you want to manipulate, then you can head to the Don't starve Wiki and look for that item there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst:AddComponent("dapperness") inst.components.dapperness.dapperness = TUNING.DAPPERNESS_MED inst.components.equippable.dapperness = TUNING.DAPPERNESS_MED end end) Place the prefab name of the item and the prefab name of your character in the marked spots. The first line of the code makes the item's perk compatible with DS, while the second line of the code makes it compatible with RoG. If you don't intend on making your mod compatible with both, then you can erase one of the lines keeping only the needed one. Increase/Decrease the sanity loss/gain To increase or decrease the amount of sanity that your character will be gaining/losing from the equipped item, all you need to do is change the end of the line ("DAPPERNESS_MED") to the ones available below: DAPPERNESS_TINY DAPPERNESS_SMALL DAPPERNESS_MED DAPPERNESS_LARGE DAPPERNESS_HUGE To make your character lose sanity instead of gaining it, all you need to do is add a " - " in front of the "TUNING". That will reverse the way it works. Example: -TUNING.DAPPERNESS_MED (inst.components.dapperness.dapperness = -TUNING.DAPPERNESS_MED) -- Erase/Increase/Decrease an existing sanity regen/damage on an item -- Spoiler To remove the sanity ragen/damage from a certain item, you'll need to remove that perk from the item. So for that you'll need to head to your modmain.lua, and for starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. First, you need to know the prefab name of the item that you want to manipulate, then you'll be simply placing it into the "base code" that you'll find below. (If you are not sure, or don't know what is the prefab name of the item that you want to manipulate, then you can head to the Don't starve Wiki and look for that item there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code for equippable items (remove) AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then if inst.components.dapperness then inst.components.dapperness.dapperness = 0 else inst.components.equippable.dapperness = 0 end end end) Place the prefab name of the item and the prefab name of your character in the marked spots. The blue line of the code makes it compatible with DS, while the purple line of the code makes it compatible with RoG. If you don't intend on making your mod compatible with both, then you can erase one of the lines keeping only the needed one. Which would result in you having only this: AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.dapperness.dapperness = 0 end end) Base code for equippable items (increase/decrease) AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then if inst.components.dapperness then inst.components.dapperness.dapperness = TUNING.DAPPERNESS_MED else inst.components.equippable.dapperness = TUNING.DAPPERNESS_MED end end end) Place the prefab name of the item and the prefab name of your character in the marked spots. The blue line of the code makes it compatible with DS, while the purple line of the code makes it compatible with RoG. If you don't intend on making your mod compatible with both, then you can erase one of the lines keeping only the needed one. Which would result in you having only this: AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.dapperness.dapperness = TUNING.DAPPERNESS_MED end end) To increase or decrease the amount of sanity that your character will be gaining/losing from the equipped item, all you need to do is change the end of the line ("DAPPERNESS_MED") to the ones available below: DAPPERNESS_TINY DAPPERNESS_SMALL DAPPERNESS_MED DAPPERNESS_LARGE DAPPERNESS_HUGE To make your character lose sanity instead of gaining it, all you need to do is add a " - " in front of the "TUNING". That will reverse the way it works. Example: -TUNING.DAPPERNESS_MED (inst.components.dapperness.dapperness = -TUNING.DAPPERNESS_MED) Base code for non-equippable items (remove) AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst:RemoveComponent("sanityaura") end end) Place the prefab name of the item and the prefab name of your character in the marked spots. Base code for non-equippable items (increase/decrease) AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.sanityaura.aura = TUNING.SANITYAURA_MED end end) Place the prefab name of the item and the prefab name of your character in the marked spots. To increase or decrease the amount of sanity that your character will be gaining/losing from the item's aura, all you need to do is change the end of the line ("SANITYAURA_MED") to the ones available below: SANITYAURA_TINY SANITYAURA_SMALL SANITYAURA_MED SANITYAURA_LARGE SANITYAURA_HUGE To make your character lose sanity instead of gaining it, all you need to do is add a " - " in front of the "TUNING". That will reverse the way it works. Example: -TUNING.DAPPERNESS_MED (inst.components.dapperness.dapperness = -TUNING.DAPPERNESS_MED) -- Add a sanity aura heal/damage to an item/creature -- Spoiler (If an item/creature has a "Sanity Aura" on it, that means that your character will be getting sanity ragen/damage by just standing near it) To make a certain item/creature recover/damage your character's Sanity, you'll need to add that perk on the item/creature. So for that you'll need to head to your modmain.lua, and for starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. First, you need to know the prefab name of the item that you want to manipulate, then you'll be simply placing it into the "base code" that you'll find below. (If you are not sure, or don't know what is the prefab name of the item that you want to manipulate, then you can head to the Don't starve Wiki and look for that item there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst:AddComponent("sanityaura") inst.components.sanityaura.aura = TUNING.SANITYAURA_MED end end) Place the prefab name of the item and the prefab name of your character in the marked spots. To increase or decrease the amount of sanity that your character will be gaining/losing from the item's aura, all you need to do is change the end of the line ("SANITYAURA_MED") to the ones available below: SANITYAURA_TINY SANITYAURA_SMALL SANITYAURA_MED SANITYAURA_LARGE SANITYAURA_HUGE To make your character lose sanity instead of gaining it, all you need to do is add a " - " in front of the "TUNING". That will reverse the way it works. Example: -TUNING.DAPPERNESS_MED (inst.components.dapperness.dapperness = -TUNING.DAPPERNESS_MED) =========================================================================Defense / Attack power / Speed ========================================================================= --=====BASIC=====-- -- Change your character's basic defense/attack power/speed -- Spoiler In your character's prefab file you'll see the lines: inst.components.health.absorb = 0.10 inst.components.combat.damagemultiplier = 1 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 If you don't have them then simply add them along with the rest of your character's stats. The first line is your character's defense. You can change your character's defense to higher or lower by increasing/decreasing the number "0.10". The number represents the percentage that will be absorbed from the inflicted damage. (Example: 0.10 = 10% less damage, 100 = 100% less damage, 0.25 = 25% less damage... and so on). The second line is your character's attack power. You can increase your character's attack power by simply increasing the number "1" at the end. As higher the number, as higher attack power your character will have. The last two lines are your character's movement speed. "walkspeed" is your character normal moving speed, while the "runspeed" is your character's speed when walking with a walking cane or on the roads. To increase/decrease it, simply increase/decrease the numbers at the end. (Remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc.) --=====INCREASE/DECREASE BASED ON TIME OR SEASON=====-- -- Change defense/power/speed based on the time of the day -- Spoiler To make your character change it's defense/power/speed you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.health.absorb = 0 inst.components.combat.damagemultiplier = 0 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 (Active)Example: inst.components.health.absorb = 0.10 inst.components.combat.damagemultiplier = 10 inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 7 Depending what you wish to be increased/decreased during the specified time of day (Day, Dusk, or Night) you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the basics in the "Change your character's basic defense/attack power/speed" section above. Base code inst:AddTag("off") local function CheckDay(inst) if GetClock() and GetWorld() then if not GetClock():IsDay() and inst:HasTag("on") and not GetWorld():IsCave() then PLACE HERE THE INACTIVE PERK inst:AddTag("off") inst:RemoveTag("on") end if GetClock():IsDay() and inst:HasTag("off") and not GetWorld():IsCave() then PLACE HERE THE ACTIVE PERK inst:AddTag("on") inst:RemoveTag("off") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckDay(inst) end) Now, depending on which time of the day you want your character's perks to activate (Day, Dusk, or Night) simply change the "GetClock():IsDay()" which I marked, to "GetClock():IsDusk()" or "GetClock():IsNight()". And don't forget to place the lines of your character's active/inactive perks in the marked spot. -- Change defense/power/speed based on season -- Spoiler To make your character change it's defense/power/speed you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.health.absorb = 0 inst.components.combat.damagemultiplier = 0 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 (Active)Example: inst.components.health.absorb = 0.10 inst.components.combat.damagemultiplier = 10 inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 7 Depending what you wish to be increased/decreased during the specified season, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the basics in the "Change your character's basic defense/attack power/speed" section above. Base code (RoG) inst:ListenForEvent("seasonChange", function(it, data) if data.season == SEASONS.WINTER then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SPRING then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.AUTUMN then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SUMMER then PLACE HERE THE ACTIVE/INACTIVE PERKS end end, GetWorld()) Depending on the season that you want your character's perks to activate, place the active perks there, while placing the inactive ones to the section of the other seasons. Base code (DS) & (RoG) The normal DS works a bit differently than the DLCs. The game won't notice what season it is unless it just got changed. Therefore we'll need trigger it ourselves. inst:ListenForEvent("seasonChange", function(it, data) if data.season == SEASONS.WINTER then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SPRING then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.AUTUMN then PLACE HERE THE ACTIVE/INACTIVE PERKS end if data.season == SEASONS.SUMMER then PLACE HERE THE ACTIVE/INACTIVE PERKS end end, GetWorld()) inst:PushEvent("seasonChange") (The last line is literally all we added for it to work!) Depending on the season that you want your character's perks to activate, place the active perks there, while placing the inactive ones to the section of the other season(s). If you don't intend for your mod to be compatible with RoG then you can erase the grayed out lines, as they won't be necessary. I would try and give also a base code for the SW version, but... I sadly don't have SW to be aware of what is, and what isn't in the game there. Sorry about that. --=====INCREASE/DECREASE BASED ON LOCATION OR RAIN=====-- -- Change defense/power/speed based on rain or caves -- Spoiler To make your character change it's defense/power/speed you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.health.absorb = 0 inst.components.combat.damagemultiplier = 0 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 (Active)Example: inst.components.health.absorb = 0.10 inst.components.combat.damagemultiplier = 10 inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 7 Depending what you wish to be increased/decreased during rain/while being in caves, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the basics in the "Change your character's basic defense/attack power/speed" section above. Base code (rain) inst:AddTag("offrain") local function CheckRain(inst) if GetSeasonManager() then if not GetSeasonManager():IsRaining() and inst:HasTag("onrain") then PLACE HERE THE INACTIVE PERK inst:AddTag("offrain") inst:RemoveTag("onrain") end if GetSeasonManager():IsRaining() and inst:HasTag("offrain") then PLACE HERE THE ACTIVE PERK inst:AddTag("onrain") inst:RemoveTag("offrain") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckRain(inst) end) Base code (caves) inst:AddTag("offcave") local function CheckArea(inst) if GetWorld() then if inst:HasTag("oncave") and not GetWorld():IsCave() then PLACE HERE THE INACTIVE PERK inst:AddTag("offcave") inst:RemoveTag("oncave") end if inst:HasTag("offcave") and GetWorld():IsCave() then PLACE HERE THE ACTIVE PERK inst:AddTag("oncave") inst:RemoveTag("offcave") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckArea(inst) end) --=====INCREASE/DECREASE BASED ON TEMPERATURE OR MOISTURE=====-- -- Change defense/power/speed based on temperature -- Spoiler To make your character change it's defense/power/speed you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Basic lines that you'll be working with(Inactive) inst.components.health.absorb = 0 inst.components.combat.damagemultiplier = 0 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 (Active)Example: inst.components.health.absorb = 0.10 inst.components.combat.damagemultiplier = 10 inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 7 Depending what you wish to be increased/decreased when your character reaches a certain temperature, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the basics in the "Change your character's basic defense/attack power/speed" section above. Base code local function CheckTemperature(inst) if inst.components.temperature then local t = inst.components.temperature if t:GetCurrent() > 30 and not inst:HasTag("tempy") then inst:AddTag("tempy") inst:RemoveTag("tempx") PLACE HERE THE ACTIVE/INACTIVE PERKS end if t:GetCurrent() < 30 and not inst:HasTag("tempx") then inst:AddTag("tempx") inst:RemoveTag("tempy") PLACE HERE THE ACTIVE/INACTIVE PERKS end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTemperature(inst) end) Depending on the temperature that you want your character's perks to react to, you'll need to change the number "30" to higher or lower. The " > " means that the perk will get triggered once your character surpasses the set temperature. The " < " means that the perk will get triggered once your character will go below the set temperature. Depending on when you want your character's perk to get active/inactive, place the active/inactive perks in the right spots. Temperature info: Any temperature below 15 is cold. Any temperature above 60 is hot. Characters start to freeze when they reach temperature 0. Characters start to overheat when they reach temperature 70. -- Change defense/power/speed based on moisture -- Spoiler To make your character lose/gain defense/power/speed when reaching a certain moisture, you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. When reaching set moisture Basic lines that you'll be working with (Inactive) inst.components.health.absorb = 0 inst.components.combat.damagemultiplier = 0 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 (Active)Example: inst.components.health.absorb = 0.10 inst.components.combat.damagemultiplier = 10 inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 7 Depending what you wish to be drained/regenerated when your character will reach the set moisture, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the basics in the "Change your character's basic defense/attack power/speed" section above. Base code local function CheckMoisture(inst) if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() > 20 and not inst:HasTag("moist") then inst:AddTag("moist") PLACE HERE THE ACTIVE/INACTIVE PERKS end if m:GetMoisture() < 20 and inst:HasTag("moist") then inst:RemoveTag("moist") PLACE HERE THE ACTIVE/INACTIVE PERKS end end end inst:DoPeriodicTask( 0.0, function(inst) CheckMoisture(inst) end) Depending on the moisture that you want your character's perks to react to, you'll need to change the number "20" to higher or lower. The " > " means that the perk will get triggered once your character surpasses the set moisture. The " < " means that the perk will get triggered once your character will go below the set moisture. Depending on when you want your character's perk to get active/inactive, place the active/inactive perks in the right spots. Increase/Decrease along with moisture Basic lines that you'll be working with(Inactive) inst.components.health.absorb = 0 inst.components.combat.damagemultiplier = 0 inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 6 (Active)Example: inst.components.health.absorb = m / 200 inst.components.combat.damagemultiplier = cm / 2 inst.components.locomotor.walkspeed = 4 + (cm / 5) inst.components.locomotor.runspeed = 6 + (cm / 5) (By increasing the numbers marked with blue you will decrease their effect on your character. While by decreasing them you will increase their effect on your character) Depending what you wish to be drained/regenerated along with the moisture, you may pick the lines that you need, to later place them into the "base code" that you'll find below. If you don't know how the given lines work, then please check the basics in the "Change your character's basic defense/attack power/speed" section above. Base code local function CheckMoisture(inst) if inst.components.moisture then local m = inst.components.moisture:GetMoisture() local cm = inst.components.moisture:GetMoisture() / 10 if m > 0 and not inst:HasTag("moist") then inst:AddTag("moist") PLACE HERE THE ACTIVE PERKS end if m == 0 and inst:HasTag("moist") then inst:RemoveTag("moist") PLACE HERE THE INACTIVE PERKS end end end inst:DoPeriodicTask( 0.0, function(inst) CheckMoisture(inst) end) This one will make your character's perk to increase/decrease it's effectivity along with the increasing/decreasing moisture. The number "10" in the line "local cm = inst.components.moisture:GetMoisture() / 10" shows how much the current moisture value will be divided and set as your current defense/power/speed. (As higher the number as lower the effect that your character will gain per moisture level. And the other way around. As lower the number as higher the effect that your character will gain per moisture level.) You may increase/decrease it until you'll reach the effect that you're looking for. =========================================================================Sensibility / Numbness / Characteristics ========================================================================= --=====BASIC=====-- -- Set your character's heat and cold resistance -- Spoiler To set your character temperature resistance, head to your character's prefab file and add the line(s): inst.components.temperature.inherentinsulation = 0 inst.components.temperature.inherentsummerinsulation = 0 The first line shows your character's cold resistance, while the second line shows your character's heat resistance. To increase your character's resistance to heat/cold, simply increase the number at the end. As higher the number, as longer it'll take for your character to start freezing/overheating. However, don't bother trying to put a negative number (-10, -20, etc.) in an attempt to make your character fragile to heat/cold, as the game is programmed to automatically correct any negative numbers to "0". If you want your character to be fragile to heat/cold, then check the "Make your character fragile/immune to cold/heat" section below. -- Increase/Decrease the HP damage when freezing/overheating -- Spoiler To increase/decrease the amount of damage that your character will be taking while freezing or overheating, head to your character's prefab file and add this line along with the rest of your character's stats. inst.components.temperature.hurtrate = 1 The number at the end shows the amount of HP that your character will be losing per second. Simply increase/decrease the number to your liking, and remember that you can also use "half numbers" like 0.5, 2.7, 3.1 etc. (This line works for both, freezing and overheating damage.) --=====FRAGILE / IMMUNE=====-- -- Make your character fragile/resistant/immune to heat/cold -- Spoiler To play with how sensitive your character is to cold/heat, head to your character's prefab file and add this line(s) along with the rest of your character's stats. (Note: You don't need to add both if you intend on making your character fragile/immune only to high or only to low temperature.) inst.components.temperature.maxtemp = ( 50 ) inst.components.temperature.mintemp = ( 10 ) This shows the max and the min temperature that your character can reach. Knowing when the characters start to freeze/overheat, helps you be able to set your character to be immune or very fragile to cold/heat. Temperature info: Any temperature below 15 is cold. Any temperature above 60 is hot. Characters start to freeze when they reach temperature 0. Characters start to overheat when they reach temperature 70. The min temperature characters can reach is -25. The max temperature that characters can reach is 95. Fragile to cold Making your character fragile to cold is very simple. By setting your character's max temperature to a low number, (anything below 20) will make your character drop to "0" much faster, than if it would be able to reach max temperature of "70" and higher. However, remember that if you'll set your character's max temperature to be too low, then you'll make your character unable to ever get warm. Example: inst.components.temperature.maxtemp = ( 20 ) (Also: This makes your character unable to ever overheat) (If you want your character to be fragile to cold but still be able to overheat then check the "Max/Min temperatures based on seasons" below.) Immune to cold Making your character immune to cold is very simple. By setting your character's min temperature to be anything above 0, means that your character will be unable to ever reach the "freezing temperature" and therefore, won't freeze. Example: inst.components.temperature.mintemp = ( 5 ) Fragile to heat Making your character fragile to heat is very simple. By setting your character's min temperature to any number above 60 (But below 70) will make your character reach the temperature of "70" much faster, than if it would be able to reach min temperature of "0" and below. However, remember that if you'll set your character's min temperature to be too high, then you'll make your character unable to ever cool-down. Example: inst.components.temperature.mintemp = ( 60 ) (Also: This makes your character unable to ever freeze.) (If you want your character to be fragile to heat but still be able to freeze then check the "Max/Min temperatures based on seasons" below.) Immune to heat Making your character immune to heat is very simple. By setting your character's max temperature to be anything below 70, means that your character will be unable to ever reach the "overheating temperature" and therefore, won't overheat. Example: inst.components.temperature.maxtemp = ( 60 ) Max/Min temperature based on seasons If you want your character to be fragile to one temperature but still be able to overheat/freeze, then my advice is to base your character's max and min temperature settings on seasons. Head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Base code inst:ListenForEvent("seasonChange", function(it, data) if data.season == SEASONS.WINTER then PLACE HERE THE MIN/MAX TEMPERATURE PERK end if data.season == SEASONS.SPRING then PLACE HERE THE MIN/MAX TEMPERATURE PERK end if data.season == SEASONS.AUTUMN then PLACE HERE THE MIN/MAX TEMPERATURE PERK end if data.season == SEASONS.SUMMER then PLACE HERE THE MIN/MAX TEMPERATURE PERK end end, GetWorld()) inst:PushEvent("seasonChange") Now, if you don't know how the min and max temperature works, then please check the fragile/immune to heat/cold explanations above, so you would know how to set your character's temperature perk right. How it works: Obviously if you want your character to be fragile to heat, then you would set your character's min temperature to be high during summer but normal during the other seasons. Or if you want your character to be fragile to cold, then you would set your character's max temp to low during winter but normal during the other seasons. -- Make your character immune to fire -- Spoiler To make your character immune to fire, simply head to your character's prefab file and add this line along with the rest of your character's stats. inst.components.health.fire_damage_scale = 0 This will make any kind of flame harmless to your character. -- Turn your character into a monster or make it "not scary to prey" -- Spoiler This is one of the easiest things you could set on your character. First, head to your character's prefab file, then add one of the lines below. If you want your character to be considered a monster then simply add this line along with the rest of your character's stats. inst:AddTag("monster") However, remember that this will also cause the Pigmen and Bunnymen to attack your character on sight. And in RoG it will also make spiders ignore you. If you want little creatures like rabbits, butterflies and the goofy gobblers to not run away from your character, then simply add this line along with the rest of your character's stats. inst:RemoveTag("scarytoprey") Make sure that your character keeps the right tags! Some of the items in the game could remove from your character the tags that you want it to have. To make sure that your character will always be able to reset the needed tags, simply add into your character's prefab file, in the "local fn = function(inst)" this: local function CheckTags(inst) if inst:HasTag("scarytoprey") then inst:RemoveTag("scarytoprey") end if not inst:HasTag("monster") then inst:AddTag("monster") end end inst:DoPeriodicTask( 0.0, function(inst) CheckTags(inst) end) This little base code right here will keep an eye on your character's current tags and reset them if changed. I marked with 2 different colors the lines responsible for the "scarytoprey" and the "monster" tag so you can easily erase the one that you don't need. -- Make the spiders/merm ignore your character (if unbothered) -- Spoiler To make merm and spiders ignore you in both, RoG and DS, you'll need to head to your character's prefab file and add this line along with the rest of your character's stats. inst:RemoveTag("character") This will make both, spiders, and merm simply ignore your character if unbothered.(It will also make ghosts ignore your character, even if attacked.) Make only spiders ignore you In RoG you can make only spiders ignore you by adding the tag "monster" to your character: inst:AddTag("monster") Make only merm ignore you To make merm ignore you simply add the tag "merm" to your character: inst:AddTag("merm") Make sure that your character keeps the right tags! Some of the items in the game could remove from your character the tags that you want it to have. To make sure that your character will always be able to reset the needed tags, simply add into your character's prefab file, in the "local fn = function(inst)" this: local function CheckTags(inst) if not inst:HasTag("merm") then inst:AddTag("merm") end if not inst:HasTag("monster") then inst:AddTag("monster") end if inst:HasTag("character") then inst:RemoveTag("character") end end inst:DoPeriodicTask( 0.0, function(inst) CheckTags(inst) end) This little base code right here will keep an eye on your character's current tags and reset them if changed. I marked each with a different color so you could easily erase the ones you don't need. =========================================================================Food ========================================================================= --=====BASIC=====-- -- Set/Change what your character can/can't eat -- Spoiler To set what your character's food preferences are, simply add this line into your character's prefab file along with the rest of your character's stats. inst.components.eater.foodprefs = { "TYPE" } The food types are:MEAT VEGGIE INSECT SEEDSGENERIC - (milk, honey, butter, etc. You can check the Don't Starve Wiki for the full list)ELEMENTAL - (Stones, gems, gold, etc.)WOOD - (logs) You can add as many food types to your character's preferences as you want. To add another one, simply place a " , " after the previous type and continue. Example: inst.components.eater.foodprefs = { "MEAT", "INSECT", "WOOD" } -- Change the amount of sanity/health/hunger that a specified food gives -- Spoiler To change the amount of sanity/health/hunger that your character receives from certain food(s), you need to change that "food perk" on the specified food. To do that, you'll need to head to your modmain.lua, and for starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. First, you need to know the prefab name of the food that you want to manipulate, then you'll be simply placing it into the "base code" that you'll find below. (If you are not sure, or don't know what is the prefab name of the food that you want to manipulate, then you can head to the Don't starve Wiki and look for that food there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Basic lines that you'll be working with(Inactive) inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 (Active)Example: inst.components.edible.healthvalue = 5 inst.components.edible.hungervalue = 10 inst.components.edible.sanityvalue = 1 Note: Keep in mind that if you won't add one of these lines, then the game will simply use the preset value of the missing category (sanity, health, hunger) for that specified food. Each line shows how much sanity, health, or hunger your character will receive for the food. You can also use negative numbers if you want the food to deal sanity/health/hunger damage. (Example: inst.components.edible.healthvalue = -5) Base code AddPrefabPostInit("FoodHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then PLACE THE CHANGED FOOD PERKS HERE end end) Example: AddPrefabPostInit("carrot", function(inst) if GetPlayer().prefab == "character" then inst.components.edible.healthvalue = 2 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = -3 end end) --=====CUSTOM=====-- -- Create a custom food type/group for your character -- Spoiler To create a custom food type/group for your character you'll need to do a bit of work in both, modmain.lua and your character's prefab file. Let's start with modmain.lua. For starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. So, for the sake of the example let's say that you want your character to only eat Watermelons and Eggplants. Instead of making all of the other foods uneatable, the fastest way would be to simply create a new custom food group for your selected foods and add them to your character. First, you need to know the prefab name of the food that you want to manipulate, (that would be "watermelon" and "eggplant" for our example) then you'll be simply placing it into the "base code" that you'll find below. I'll provide you with a clean base code, same as an example one for you to see. (If you are not sure, or don't know what is the prefab name of the food that you want to manipulate, then you can head to the Don't starve Wiki and look for that food there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code (clean) AddPrefabPostInit("FoodHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.edible.foodtype = "CUSTOM_TYPE" (You can add more food perks here if you want. Like sanity/health/hunger values) end end) Base code (example) AddPrefabPostInit("watermelon", function(inst) if GetPlayer().prefab == "character" then inst.components.edible.foodtype = "NOM" end end) AddPrefabPostInit("eggplant", function(inst) if GetPlayer().prefab == "character" then inst.components.edible.foodtype = "NOM" end end) In our example the "NOM" is the name of your new custom food group. You can of course name your food group however you want, it doesn't really matter. Just keep in mind that any food that had it's TYPE change, will become uneatable to all of the creatures in the game. You can of course add that custom food group to the needed creatures as well, and I'll show you how to do that at the end of this section. Now, after sorting your selected foods to your custom food group, we will head into your character's prefab file, and add your new group into your character's food preferences. To do that, you'll simply need to add these lines along with the rest of your character's stats. (Clean) inst.components.eater.ablefoods = { "CUSTOM_TYPE" } inst.components.eater.foodprefs = { "CUSTOM_TYPE" } (Example) inst.components.eater.ablefoods = { "NOM" } inst.components.eater.foodprefs = { "NOM" } You can of course also add other existing types along with your custom one. Example: inst.components.eater.ablefoods = { "NOM", "MEAT", "INSECT" } inst.components.eater.foodprefs = { "NOM", "MEAT", "INSECT" } (For a list of all existing food types, check the "Set/Change what your character can/can't eat" section above.) And that's it! You have your very own custom food group/type! Adding your custom food group/type to other creatures Now, if you are bothered that some creatures won't be able to eat the foods which you manipulated, then you can very easily add your custom food group/type into their food preferences. All you need to do is head to your modmain.lua and add this in there: Base code (clean) AddPrefabPostInit("CreatureHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.eater.ablefoods = { "CUSTOM_TYPE", "TYPE" } inst.components.eater.foodprefs = { "CUSTOM_TYPE", "TYPE" } end end) Base code (example) AddPrefabPostInit("spider", function(inst) if GetPlayer().prefab == "character" then inst.components.eater.ablefoods = { "NOM", "MEAT" } inst.components.eater.foodprefs = { "NOM", "MEAT" } end end) When adding your custom food group/type to other creatures, remember that they all already have a set "vore-type" (they are either omnivore, carnivore, herbivore, etc.) . So you'll need to also re-add the preferences that they already had. (Like in the example) -- Make an non-eatable item eatable to your character -- Spoiler To make a non-eatable item eatable to your character, you need to add the "edible" component to the item, along with it's sanity, health, and hunger values. To do that, you'll need to head to your modmain.lua, and for starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. So, for the sake of the example let's say that you want your character to be able eat Poop. (Yea, I know. Splendid example!) First, you need to know the prefab name of the item that you want to manipulate, (That would be "poop" for our example) then you'll be simply placing it into the "base code" that you'll find below. I'll provide you with a clean base code, same as an example one for you to see. (If you are not sure, or don't know what is the prefab name of the item that you want to manipulate, then you can head to the Don't starve Wiki and look for that food there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Base code (clean) AddPrefabPostInit("ItemHere", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst:AddComponent("edible") inst.components.edible.foodtype = "TYPE" inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 end end) Base code (example) AddPrefabPostInit("poop", function(inst) if GetPlayer().prefab == "character" then inst:AddComponent("edible") inst.components.edible.foodtype = "VEGGIE" inst.components.edible.healthvalue = -2 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 3 end end) By making an item edible, you also will need to add a food type/group to it. You can use one of the already existing groups (which are listed in the "Set/Change what your character can/can't eat" section above.) or you can create a new custom group/type for it. (You can check the "Create a custom food type/group for your character" section above for more info.) However, remember that if you'll use an already existing food type/group for your selected item, then other creatures in the game, which also have that food type/group in their preferences will be able to eat it. But if you'll make a custom group, then only your character will be able to eat it. The 3 lines that follow, show how much sanity, health, and hunger your character will receive from the food. You can also use negative numbers if you want the food to deal sanity/health/hunger damage. (Example: inst.components.edible.healthvalue = -5) =========================================================================Starter inventory / Night vision / Recipes / Other ========================================================================= --=====ITEMS=====-- -- Give your character starting inventory items -- Spoiler To give your character starter inventory items, you'll need to head to your character's prefab file and in there you'll see the line: local start_inv = { } First, you need to know the prefab name of the item that you want to add, then simply place it between then "{ }". (If you are not sure, or don't know what is the prefab name of the item that you want to add, then you can head to the Don't starve Wiki and look for that item there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Example: local start_inv = { "corn", "carrot", "carrot" } -- Make your character always start with a certain custom item (even in adventure mode) -- Spoiler If you want your character to always have certain custom item that you made, then you'll need to head to your character's prefab file and in there you'll see the lines: local prefabs = { } local start_inv = { } First, of course your character needs to have a starter inventory item(s). (You can check the "Give your character starting inventory items" section above for more info.) Then what you need to do is copy-paste the list of custom items that you want your character to always have, into the local prefabs = { }. Example: local prefabs = { "custom_item_here" } local start_inv = { "custom_item_here", "carrot", "carrot" } After you set that, head to the very bottom of the "local fn = function(inst)" and add this in it. (In the function, not below it) Base code inst:DoTaskInTime(0, function() local found = false for k,v in pairs(Ents) do if v.prefab == "CustomItemHere" then found = true break end end if not found then inst.components.inventory:GuaranteeItems(prefabs) end end) This will keep an eye on your character's custom item(s) each time you'll start/load the game. Remember that this function will ALWAYS give your character the set item(s), if it/they will be missing from the game not just your character's inventory. So this function is mainly meant to be used for irreplaceable items/items which cannot be crafted nor found. --=====CHARACTER=====-- -- Give your character a night vision/glow -- Spoiler To give your character a night vision/glow, you'll need to head to your character's prefab file, and in there you'll see the "local fn = function(inst)". We will work mainly IN this function. Base code (Night glow) local light = inst.entity:AddLight() light:SetFalloff(1) light:SetIntensity(0.5) light:SetRadius(4.0) light:SetColour(RRR/255, GGG/255, BBB/255) light:Enable(false) inst:AddTag("sight_off") local function NightGlow(inst) if GetClock() and GetWorld() then if GetClock():IsDay() and inst:HasTag("sight_on") and not GetWorld():IsCave() or GetClock():IsDusk() and inst:HasTag("sight_on") and not GetWorld():IsCave() then light:Enable(false) inst:AddTag("sight_off") inst:RemoveTag("sight_on") end if GetClock():IsNight() and inst:HasTag("sight_off") or GetWorld():IsCave() and inst:HasTag("sight_off") then light:Enable(true) inst:AddTag("sight_on") inst:RemoveTag("sight_off") end end end inst:DoPeriodicTask( 0.0, function(inst) NightGlow(inst) end) Base code (Night vision) local light = inst.entity:AddLight() light:SetFalloff(0.2) light:SetIntensity(0.9) light:SetRadius(6.0) light:SetColour(RRR/255, GGG/255, BBB/255) light:Enable(false) inst:AddTag("sight_off") local function NightVision(inst) if GetClock() and GetWorld() then if GetClock():IsDay() and inst:HasTag("sight_on") and not GetWorld():IsCave() or GetClock():IsDusk() and inst:HasTag("sight_on") and not GetWorld():IsCave() then light:Enable(false) inst:AddTag("sight_off") inst:RemoveTag("sight_on") end if GetClock():IsNight() and inst:HasTag("sight_off") or GetWorld():IsCave() and inst:HasTag("sight_off") then light:Enable(true) inst:AddTag("sight_on") inst:RemoveTag("sight_off") end end end inst:DoPeriodicTask( 0.0, function(inst) NightVision(inst) end) Night glow and Night vision are basically the same code with changed light stats. (You can of course play around with the numbers yourself, but just in case you don't, I made those 2 bases for you to pick whichever you need) Setting the color of your glow/vision In the first few lines of the base code you can see the line: light:SetColour(RRR/255, GGG/255, BBB/255) This is your color setting. Those 3 sections represent the Red, Green, and Blue amount. By increasing the numbers you are increasing the amount of color that you are adding. Simply mix the colors until you'll reach the one that you're looking for. Example: light:SetColour(019/255, 200/255, 255/255) Small advice: Try always having at least 001 point in each color, as from my own experience, the game sometimes tends to not recognize only 1 pure corol, which will make your character act as if in complete darkness even though it's not. --=====RECIPES=====-- -- Unlock recipes for your character -- Spoiler If you want your character to already have some recipes unlocked from the start, then head to your character's prefab file and add this line in the "local fn = function(inst)". inst.components.builder:UnlockRecipe("ItemHere") First, you need to know the prefab name of the item that you want to unlock, then you'll be simply placing it into the line above. Remember that in order to unlock a recipe, such needs to first exist. So if you'll be trying to unlock recipes which don't exist, then that won't work. (If you are not sure, or don't know what is the prefab name of the item that you want to unlock, then you can head to the Don't starve Wiki and look for it there. Once you find it check it's "DebugSpawn" code, as this is also it's name.) Example: inst.components.builder:UnlockRecipe("spear") If you want to unlock many different recipes then simply copy-paste that line as many times as you need, and place the item that you want to be unlocked in the marked spot. Example: inst.components.builder:UnlockRecipe("spear") inst.components.builder:UnlockRecipe("rope") -- Change existing recipes -- Spoiler If you want your character to be able to craft some items by using different ingredients, then there are 2 different ways of doing it. One is in modmain.lua and the second one is in your character's prefab file. You may use whichever method seems better to you. --==Let's start with the modmain.lua method==-- For starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. So, for the sake of the example let's say that you want your character to be able to craft a Spear by using 3 twigs, 1 rope, and 2 rocks. First, you need to know the prefab names of the items that you want to use, (That would be "spear", "twigs", "rope" and "rocks" for our example) then you'll be simply placing them into the "base code" that you'll find below. I'll provide you with a clean base code, same as an example one for you to see. (If you are not sure, or don't know what is the prefab name of the items that you want to manipulate, then you can head to the Don't starve Wiki and look for them there. Once you find them check their "DebugSpawn" code, as this is also their name.) Base code (clean) AddSimPostInit(function(inst) if GetPlayer().prefab == "YourCharacterHere" then local FunctionName = GLOBAL.Recipe("RecipeItemHere", {Ingredient("IngredientHere", 1), Ingredient("IngredientHere", 1)}, RECIPETABS.TAB, {TIER =0} ) end end) Base code (example) AddSimPostInit(function(inst) if GetPlayer().prefab == "character" then local newspear = GLOBAL.Recipe("spear", {Ingredient("twigs", 3), Ingredient("rope", 1), Ingredient("rocks", 2)}, RECIPETABS.FIGHT, {SCIENCE =1} ) end end) Place the prefab name of the recipe-item, ingredient-item(s), and the name of your character in the marked spots. The number next to the "IngredientHere" is the amount of that certain item that the recipe needs.The "FunctionName " is just (as the text says) a name of the function. You can name it however you like. If you want to add more ingredients or erase some to make the recipe need less, then add/erase the line: Ingredient("IngredientHere", 1) (You can compare the clean base code and the example one to see the difference.) The next line: RECIPETABS.TAB, {TIER =0} ) Shows in which TAB the recipe will appear, and if you need to use a TIER for it or not. The existing tabs are:TOOLS LIGHT SURVIVAL FARM -- (Food)SCIENCE WAR -- (Fight)TOWN -- (Structures)REFINE MAGIC DRESS ANCIENT BOOKS -- (only if you have that tab unlocked and work in your character's prefab file) NAUTICAL -- (I do not have SW, so please correct me if I'm wrong here)OBSIDIAN -- (Volcanic) Tier requirementSCIENCE =0 -- (Nothing except the recipe items is needed.)SCIENCE =1 -- (Requires the Science Machine or Alchemy Engine for the prototype.)SCIENCE =2 -- (Requires the Alchemy Engine for the prototype.)MAGIC =1 or (2) -- (Requires the Prestihatitator or Shadow Manipulator for the prototype.)MAGIC =3 -- (Requires the Shadow Manipulator for the prototype.)ANCIENT =1 or (2) -- (Requires the Ancient Pseudoscience Station to be made.)ANCIENT =3 or (4) -- (Requires the Ancient Pseudoscience Station (fixed) to be made.) --==Now here is the other method that works in your character's prefab file==-- So, for the sake of the example let's say that you want your character to be able to craft a Spear by using 3 twigs, 1 rope, and 2 rocks. First, you need to know the prefab names of the items that you want to use, (That would be "spear", "twigs", "rope" and "rocks" for our example) then you'll be simply placing them into the "base code" that you'll find below. I'll provide you with a clean base code, same as an example one for you to see. (If you are not sure, or don't know what is the prefab name of the items that you want to manipulate, then you can head to the Don't starve Wiki and look for them there. Once you find them check their "DebugSpawn" code, as this is also their name.) Base code (clean) Recipe("RecipeItemHere", {Ingredient("IngredientHere", 1), Ingredient("IngredientHere", 1)}, RECIPETABS.TAB, {TIER = 0}) Base code (example) Recipe("spear", {Ingredient("twigs", 2), Ingredient("rope", 1), Ingredient("rocks",3)}, RECIPETABS.WAR, {SCIENCE = 1}) Place the prefab name of the recipe-item, ingredient-item(s), and the name of your character in the marked spots. The number next to the "IngredientHere" is the amount of that certain item that the recipe needs. If you want to add more ingredients or erase some to make the recipe need less, then add more/erase one of the parts: Ingredient("IngredientHere", 1) (You can compare the clean base code and the example one to see the difference.) The next part: RECIPETABS.TAB, {TIER = 0} ) Shows in which TAB the recipe will appear, and if you need to use a TIER for it or not.(List of TABS and TIERS is above) --=====CUSTOM=====-- -- Give your character custom recipes for existing items -- Spoiler To give your character a custom recipe for an existing item, you can either do it in your modmain.lua or your character's prefab file. You may use whichever method seems better to you. --==Let's start with the modmain.lua method==-- For starters add this line somewhere at the very top. GetPlayer = GLOBAL.GetPlayer We will be using the "GetPlayer()" in this section, so this line will make sure that your mod will know what to do with it instead of crashing. So, for the sake of the example let's say that you want your character to be able to craft twigs from a log and a razor. First, you need to know the prefab names of the items that you want to use, (That would be "twigs", "log" and "razor" for our example) then you'll be simply placing them into the "base code" that you'll find below. I'll provide you with a clean base code, same as an example one for you to see. (If you are not sure, or don't know what is the prefab name of the items that you want to use, then you can head to the Don't starve Wiki and look for them there. Once you find them check their "DebugSpawn" code, as this is also their name.) Base code (clean) AddSimPostInit(function(inst) if GetPlayer().prefab == "YourCharacterHere" then local FunctionName = GLOBAL.Recipe("RecipeItemHere", {Ingredient("IngredientHere", 1), Ingredient("IngredientHere", 1), Ingredient("IngredientHere", 1)}, RECIPETABS.TAB, {TIER =0} ) end end) GLOBAL.STRINGS.RECIPE_DESC.RECIPE_ITEM_HERE = "Your description here." Base code (example) AddSimPostInit(function(inst) if GetPlayer().prefab == "character" then local twigscraft = GLOBAL.Recipe("twigs", {Ingredient("log", 1), Ingredient("razor", 1)}, RECIPETABS.REFINE, {SCIENCE =0} ) end end) GLOBAL.STRINGS.RECIPE_DESC.TWIGS = "Nicely shaped!" Place the prefab name of the recipe-item, ingredient-item(s), and the name of your character in the marked spots. The number next to the "IngredientHere" is the amount of that certain item that the recipe needs. The "FunctionName " is just (as the text says) a name of the function. You can name it however you like. The last line of the base code is responsible for the description text that will appear in the recipe window of the item. You can give it whatever description you like. If you want to add more ingredients or erase some to make the recipe need less, then add more/erase one of the parts: Ingredient("IngredientHere", 1) (You can compare the clean base code and the example one to see the difference.) The next line: RECIPETABS.TAB, {TIER =0} ) Shows in which TAB the recipe will appear, and if you need to use a TIER for it or not. The existing tabs are:TOOLS LIGHT SURVIVAL FARM -- (Food)SCIENCE WAR -- (Fight)TOWN -- (Structures)REFINE MAGIC DRESS ANCIENT BOOKS -- (only if you have that tab unlocked and work in your character's prefab file) NAUTICAL -- (I do not have SW, so please correct me if I'm wrong here)OBSIDIAN -- (Volcanic) Tier requirementSCIENCE =0 -- (Nothing except the recipe items is needed.)SCIENCE =1 -- (Requires the Science Machine or Alchemy Engine for the prototype.)SCIENCE =2 -- (Requires the Alchemy Engine for the prototype.)MAGIC =1 or (2) -- (Requires the Prestihatitator or Shadow Manipulator for the prototype.)MAGIC =3 -- (Requires the Shadow Manipulator for the prototype.)ANCIENT =1 or (2) -- (Requires the Ancient Pseudoscience Station to be made.)ANCIENT =3 or (4) -- (Requires the Ancient Pseudoscience Station (fixed) to be made.) --==Now here is the other method that works in your character's prefab file==-- So, for the sake of the example let's say that you want your character to be able to craft twigs from a log and a razor. First, you need to know the prefab names of the items that you want to use, (That would be "twigs", "log" and "razor" for our example) then you'll be simply placing them into the "base code" that you'll find below. I'll provide you with a clean base code, same as an example one for you to see. (If you are not sure, or don't know what is the prefab name of the items that you want to use, then you can head to the Don't starve Wiki and look for them there. Once you find them check their "DebugSpawn" code, as this is also their name.) Base code (clean) Recipe("RecipeItemHere", {Ingredient("IngredientHere", 1), Ingredient("IngredientHere", 1), Ingredient("IngredientHere", 1)}, RECIPETABS.TAB, {TIER = 0}) STRINGS.RECIPE_DESC.RECIPE_ITEM_HERE= "Your description here." Base code (example) Recipe("twigs", {Ingredient("log", 1), Ingredient("razor", 1)}, RECIPETABS.REFINE, {SCIENCE = 0}) STRINGS.RECIPE_DESC.TWIGS = "Nicely shaped!" Place the prefab name of the recipe-item, ingredient-item(s), and the name of your character in the marked spots. The number next to the "IngredientHere" is the amount of that certain item that the recipe needs. The last line of the base code is responsible for the description text that will appear in the recipe window of the item. You can give it whatever description you like. If you want to add more ingredients or erase some to make the recipe need less, then add more/erase one of the parts: Ingredient("IngredientHere", 1) (You can compare the clean base code and the example one to see the difference.) The next part: RECIPETABS.TAB, {TIER = 0} ) Shows in which TAB the recipe will appear, and if you need to use a TIER for it or not. (List of TABS and TIERS is above) --=====OTHER=====-- -- Remove the sanity gain/loss from picking flowers -- Spoiler I actually saw people asking that quite often, so I decided to add that little code right here for you to use if you need it. Place it/them in your modmain.lua. Normal flowers AddPrefabPostInit("flower", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.pickable.onpickedfn = function(inst, picker) if picker and picker.components.sanity then end inst:Remove() end end end) Evil flowers AddPrefabPostInit("flower_evil", function(inst) if GetPlayer().prefab == "YourCharacterHere" then inst.components.pickable.onpickedfn = function(inst, picker) if picker and picker.components.sanity then end inst:Remove() end inst:RemoveComponent("sanityaura") end end) Keep the blue line if you also want to remove the negative sanity aura from the evil flowers. And remember to place your character's prefab name in the marked spot. -- Mute your character -- Spoiler If you want to fully remove from your character the ability to speak and comment over any examined item/entity, then head to your character's prefab file and add this line IN the "local fn = function(inst)". inst.components.talker.special_speech = true This however won't get rid of the "Examine" text/option appearing once you hover your mouse over objects. (But your character still won't react to that option even if clicked.) -- Make your character unable to trigger spiders when walking on their webs -- Spoiler If you want your character to be able to freely walk on spiderwebs without triggering the spiders, then head to your character's prefab file and add this line IN the "local fn = function(inst)". inst.components.locomotor.triggerscreep = false Now you can walk, stand, and run around the spiderwebs without having spiders care to come out to investigate. ========================================================================= And that would be the end of this tutorial. It took me 5 days to compose all this, so I really hope that at least some of you might find it helpful. However, if any of this parts/sections confused you, then please feel free to ask me whatever it is that you didn't understand, and I'll try to explain it differently to hopefully help you out. Also:Please, do not ask any questions that have nothing to do with this tutorial (nor anything it shows) in here. (Just trying to avoid unnecessary mess) ^^; Edited February 13, 2019 by BraveChicken 6 8 1 1 Link to comment Share on other sites More sharing options...
Siletrea Posted July 12, 2018 Share Posted July 12, 2018 you my friend are a gem! this is absolutely fantastic! I wish this was made a few years back honestly! but I'm just so happy its here now! I'm positive this will get oodles of views once hamlet comes out for all the new mods! fantastic work! 2 Link to comment Share on other sites More sharing options...
axxel Posted July 13, 2018 Share Posted July 13, 2018 Thanks . But could you tidy up a bit? I mean you can use spoiler or create a table of contents for Ctrl-F navigation. Link to comment Share on other sites More sharing options...
BraveChicken Posted July 13, 2018 Author Share Posted July 13, 2018 8 hours ago, axxel said: you can use spoiler or create a table of contents for Ctrl-F navigation I actually did try to do that due to the fact that this tutorial is soooo looong. ^-^; (I actually am new to klei forums .... and... forums in general, so I'm still kinda learning how these things work XD) But I'm guessing that maybe I did something wrong, because it didn't want to work the way it should o,o; I guess I can give it another try XD And there is a table of contents at the very top. (I guess I can try to simple it down a bit more o,o) Hopefully I'll manage to make it better. Thanks for the input though! ^-^ 1 Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted July 15, 2018 Share Posted July 15, 2018 Nice work, a lot of code in the forums become lost overtime (I mean 226 pages? and the search engine is limited to 30+ second penalty per search!) and heck some of the code I post is lost even when I look at my profile for previous posts. 1 Link to comment Share on other sites More sharing options...
RudyAmericanHero Posted July 18, 2018 Share Posted July 18, 2018 (edited) May i ask is there a way to use certain items like lucy or wes's balloons or abigail's flower? Edited July 18, 2018 by RudyAmericanHero Link to comment Share on other sites More sharing options...
BraveChicken Posted July 18, 2018 Author Share Posted July 18, 2018 (edited) 13 hours ago, RudyAmericanHero said: is there a way to use certain items like lucy or wes's balloons or abigail's flower? Yes, there is. But if you want to give your character the ability to start/use those items then you would need to modify them in your mod, and remove from them the "characterspecific" component. (This component is used to make an item bounded only to 1 specified character) If you want to do that, then you will need to look into the game's prefab files (in the main don't starve folder, go to data >> scripts >> prefabs) Then you will need to look for the prefab file that you want to modify and copy-paste it into your mod's folder. after you do that simply open the copy of the file that you just made and remove from it the lines: inst:AddComponent("characterspecific") inst.components.characterspecific:SetOwner("woodie") or turn them off by simply placing a " -- " in front of them like that: --inst:AddComponent("characterspecific") --inst.components.characterspecific:SetOwner("woodie") In Abigail's flower file you also will need to look for the line: if not GetPlayer() or GetPlayer().prefab ~= "wendy" then inst:Remove() end and for Wes's ballons the line: inst:DoTaskInTime(0, function() if not GetPlayer() or GetPlayer().prefab ~= "wes" then inst:Remove() end end) and remove it/turn it off as this keeps an eye on the character's prefab file and removes the item if it isn't wendy/wes. Then head to your modmain.lua and add your modified file to the PrefabFiles = { } section along with the prefab file of your character. So it should look something like that: PrefabFiles = { "YourCharacterHere", "lucy" } Then of course you can either create a custom recipe to craft those items or simply make your character start with that item (You can find in the tutorial how to do both of those so you can pick whichever you like) Edited July 18, 2018 by BraveChicken Link to comment Share on other sites More sharing options...
ricky_loves_cat Posted September 11, 2018 Share Posted September 11, 2018 sorry, I realized maybe this thread is for dont starve only, I found out in of the sections, where I wanna increase my character's ability at night, there's a GetClock() function that is not been recognized by the system. I figured it might have to do with the DS and DST. I wonder if I am right, if yes what is the correct function name to use in this example? Thanks!! Link to comment Share on other sites More sharing options...
BraveChicken Posted September 12, 2018 Author Share Posted September 12, 2018 (edited) 10 hours ago, ricky_loves_cat said: there's a GetClock() function that is not been recognized by the system. I figured it might have to do with the DS and DST. I wonder if I am right, if yes what is the correct function name to use in this example? Thanks! If you are working on a DST mod, then yes, there are differences in coding between the "normal" DS and the DST. I would gladly help you if I could, but sadly I do not have DST to even be aware of the coding differences that would need to be made there. However, you may want to ask for help in the DST mods and tools forum section, as I'm sure you'll manage to find someone to help you there. I'm sorry that I can't be of more help. Edited September 12, 2018 by BraveChicken Link to comment Share on other sites More sharing options...
690739_1452792444 Posted November 25, 2018 Share Posted November 25, 2018 how can i make nightvision use with button for example press F open nightvision Link to comment Share on other sites More sharing options...
690739_1452792444 Posted November 25, 2018 Share Posted November 25, 2018 On 18.07.2018 at 5:55 PM, BraveChicken said: Yes, there is. But if you want to give your character the ability to start/use those items then you would need to modify them in your mod, and remove from them the "characterspecific" component. (This component is used to make an item bounded only to 1 specified character) If you want to do that, then you will need to look into the game's prefab files (in the main don't starve folder, go to data >> scripts >> prefabs) Then you will need to look for the prefab file that you want to modify and copy-paste it into your mod's folder. after you do that simply open the copy of the file that you just made and remove from it the lines: inst:AddComponent("characterspecific") inst.components.characterspecific:SetOwner("woodie") or turn them off by simply placing a " -- " in front of them like that: --inst:AddComponent("characterspecific") --inst.components.characterspecific:SetOwner("woodie") In Abigail's flower file you also will need to look for the line: if not GetPlayer() or GetPlayer().prefab ~= "wendy" then inst:Remove() end and for Wes's ballons the line: inst:DoTaskInTime(0, function() if not GetPlayer() or GetPlayer().prefab ~= "wes" then inst:Remove() end end) and remove it/turn it off as this keeps an eye on the character's prefab file and removes the item if it isn't wendy/wes. Then head to your modmain.lua and add your modified file to the PrefabFiles = { } section along with the prefab file of your character. So it should look something like that: PrefabFiles = { "YourCharacterHere", "lucy" } Then of course you can either create a custom recipe to craft those items or simply make your character start with that item (You can find in the tutorial how to do both of those so you can pick whichever you like) how can i make nightvision use with button for example open nightvision press F To Open Nightvision Link to comment Share on other sites More sharing options...
BraveChicken Posted November 26, 2018 Author Share Posted November 26, 2018 (edited) On 11/25/2018 at 11:22 PM, 690739_1452792444 said: how can i make nightvision use with button for example open nightvision press F To Open Nightvision I never played around with adding such to a button, so I won't be able to help you out too much with this right now, but I know a mod that did create and use different button commands. Puppy princess Musha You could look around in the files of this mod to see how the buttons there are scripted.(I would have checked it out myself but I do not have that much free time lately. Sorry about that) Edit: Nevermind! I couldn't resist checking it out! Here's what you'll need: Head to your character's prefab file and add in the local fn = function(inst) these lines: local light = inst.entity:AddLight() light:SetFalloff(0.2) light:SetIntensity(0.9) light:SetRadius(6.0) light:SetColour(001/255, 255/255, 050/255) light:Enable(false) inst:AddTag("nvoff") Then head to your modmain.lua and add in there this: GetPlayer = GLOBAL.GetPlayer GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F, function() local light = GetPlayer().entity:AddLight() if GetPlayer():HasTag("nvon") then light:Enable(false) GetPlayer():AddTag("nvoff") GetPlayer():RemoveTag("nvon") print("Night vision is OFF.") elseif GetPlayer():HasTag("nvoff") then light:Enable(true) GetPlayer():AddTag("nvon") GetPlayer():RemoveTag("nvoff") print("Night vision is ON.") end end) You can of course change the colors of your night vision (The tutorial explains how to do that) and the button from "F" to another by just changing the "F" in the "GLOBAL.KEY_F" which I marked, to the one which you would like to use. This should be enough to make it work. Edited November 26, 2018 by BraveChicken Link to comment Share on other sites More sharing options...
VictorG2Ah Posted December 27, 2018 Share Posted December 27, 2018 when I put the custom sanity gain / loss commands, I did as it was in the tutorial, but it did not work, the sanity icon was blinking on the gain and loss arrows at the same time, where did I go wrong? I'll leave as I put the command inst:AddTag("notactive") local function CheckTime(inst) if GetClock() and GetWorld() then if not GetClock():IsDay() and inst:HasTag("active") and not GetWorld():IsCave() then inst.components.sanity.dapperness = 0 inst:AddTag("notactive") inst:RemoveTag("active") end if GetClock():IsDay() and inst:HasTag("notactive") and not GetWorld():IsCave() then inst.components.sanity.dapperness = 0.3 inst:AddTag("active") inst:RemoveTag("notactive") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTime(inst) end) inst:AddTag("notactive") local function CheckTime(inst) if GetClock() and GetWorld() then if not GetClock():IsDusk() and inst:HasTag("active") and not GetWorld():IsCave() then inst.components.sanity.dapperness = 0 inst:AddTag("notactive") inst:RemoveTag("active") end if GetClock():IsDusk() and inst:HasTag("notactive") and not GetWorld():IsCave() then inst.components.sanity.dapperness = -0.15 inst:AddTag("active") inst:RemoveTag("notactive") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTime(inst) end) inst:AddTag("notactive") local function CheckTime(inst) if GetClock() and GetWorld() then if not GetClock():IsNight() and inst:HasTag("active") and not GetWorld():IsCave() then inst.components.sanity.dapperness = 0 inst:AddTag("notactive") inst:RemoveTag("active") end if GetClock():IsNight() and inst:HasTag("notactive") and not GetWorld():IsCave() then inst.components.sanity.dapperness = -0.4 inst:AddTag("active") inst:RemoveTag("notactive") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTime(inst) end) Please help me Link to comment Share on other sites More sharing options...
BraveChicken Posted December 28, 2018 Author Share Posted December 28, 2018 11 hours ago, VictorG2Ah said: when I put the custom sanity gain / loss commands, I did as it was in the tutorial, but it did not work, the sanity icon was blinking on the gain and loss arrows at the same time, where did I go wrong? The problem is that you putted the same sanity function 3 times in a row. And all of them work with the same tags, which makes the game flicker between all of them all the time. But reading your script I can see what you were trying to do. So here's how to fix that: inst:AddTag("notactive") local function CheckTime(inst) if GetClock() and GetWorld() then if GetClock():IsDay() and (inst:HasTag("notactive") or inst:HasTag("activedusk") or inst:HasTag("activenight")) and not GetWorld():IsCave() then inst.components.sanity.dapperness = 0.3 inst:AddTag("activeday") inst:RemoveTag("notactive") inst:RemoveTag("activedusk") inst:RemoveTag("activenight") end if GetClock():IsDusk() and (inst:HasTag("notactive") or inst:HasTag("activeday") or inst:HasTag("activenight")) and not GetWorld():IsCave() then inst.components.sanity.dapperness = -0.15 inst:AddTag("activedusk") inst:RemoveTag("notactive") inst:RemoveTag("activeday") inst:RemoveTag("activenight") end if GetClock():IsNight() and (inst:HasTag("notactive") or inst:HasTag("activedusk") or inst:HasTag("activeday")) and not GetWorld():IsCave() then inst.components.sanity.dapperness = -0.4 inst:AddTag("activenight") inst:RemoveTag("notactive") inst:RemoveTag("activedusk") inst:RemoveTag("activeday") end end end inst:DoPeriodicTask( 0.0, function(inst) CheckTime(inst) end) Try using this instead. I simply combined everything into 1. I marked you the Day, Dusk, and Night parts along with your custom sanity perk so you could easily change it if you'd like Link to comment Share on other sites More sharing options...
bloopers Posted January 19, 2019 Share Posted January 19, 2019 where exactly do i put the code in the file? Link to comment Share on other sites More sharing options...
BraveChicken Posted January 22, 2019 Author Share Posted January 22, 2019 On 1/19/2019 at 3:53 AM, bloopers said: where exactly do i put the code in the file? Everything is literally explained in the tutorial o.o All lines go either in the modmain.lua or in your character's prefab file in the "local fn = function(inst)" Every section tells you exactly where to place the Base code which you are given. If you feel confused about one of the sections then let me know which one it is so I could give you more directions/help. Link to comment Share on other sites More sharing options...
Scrumch Posted May 18, 2019 Share Posted May 18, 2019 I don't know if you can still help, but is there a way to completely negate the sanity penalty from equipping wet items? The sanity drain for moisture seems to only work for the wetness of the character. Also the sanity regain in the rain doesn't stay for the entire period of rain, is that supposed to happen? 1 Link to comment Share on other sites More sharing options...
Wongus72 Posted May 19, 2019 Share Posted May 19, 2019 I did the custom Food Type thing and i tried adding multiple food items, and this is the code GetPlayer = GLOBAL.GetPlayer -- Food Pref AddPrefabPostInit("log", function(inst) if GetPlayer().prefab == "fbot" then inst:AddComponent("edible") inst.components.edible.foodtype = "FLAMABLE" inst.components.edible.healthvalue = -55 inst.components.edible.hungervalue = -55 inst.components.edible.sanityvalue = -30 end end) AddPrefabPostInit("petals", function(inst) if GetPlayer().prefab == "fbot" then inst:AddComponent("edible") inst.components.edible.foodtype = "FLAMABLE" inst.components.edible.healthvalue = -55 inst.components.edible.hungervalue = -55 inst.components.edible.sanityvalue = -30 end end) (the negative stats are just for testing) When I add two or more Items this happens Can someone help me with this please Link to comment Share on other sites More sharing options...
Wongus72 Posted May 19, 2019 Share Posted May 19, 2019 20 hours ago, EscapeMan4 said: I did the custom Food Type thing and i tried adding multiple food items, and this is the code GetPlayer = GLOBAL.GetPlayer -- Food Pref AddPrefabPostInit("log", function(inst) if GetPlayer().prefab == "fbot" then inst:AddComponent("edible") inst.components.edible.foodtype = "FLAMABLE" inst.components.edible.healthvalue = -55 inst.components.edible.hungervalue = -55 inst.components.edible.sanityvalue = -30 end end) AddPrefabPostInit("petals", function(inst) if GetPlayer().prefab == "fbot" then inst:AddComponent("edible") inst.components.edible.foodtype = "FLAMABLE" inst.components.edible.healthvalue = -55 inst.components.edible.hungervalue = -55 inst.components.edible.sanityvalue = -30 end end) (the negative stats are just for testing) When I add two or more Items this happens Can someone help me with this please Edit: I Figured out that it only crashes for certain items like Logs and Cut Grass Link to comment Share on other sites More sharing options...
dezgasting Posted September 14, 2019 Share Posted September 14, 2019 (edited) Can't turn off the moisture sanity penalty (SW). I put the code under the local(fn) = function(inst), and copypasted the code there. So the code's Quote inst:DoTaskInTime( 0.1, function(inst) if inst.components.moisture then local m = inst.components.moisture if m:GetMoisture() then TUNING.MOISTURE_SANITY_PENALTY_MAX = 0 end end end) But the game ignores it completely. No crash, nothing - I just get the sanity drain. I'm figuring I need a different code for SW? EDIT: Items. Ok, I need a code to remove the sanity penalty from wet items. can't figure it out. Edited September 14, 2019 by htv1lla1n ^^ Link to comment Share on other sites More sharing options...
ShadowGamer3 Posted February 26, 2020 Share Posted February 26, 2020 How do you adjust melee damage based on defending creature? Also, how can you check which item is equipped? Lastly, how can you get/change Max Health, Sanity, and Hunger after game starts? Link to comment Share on other sites More sharing options...
Caedis16 Posted May 14, 2020 Share Posted May 14, 2020 is there a way to allow a character to spend parts of their sanity or health? Not like maxwell, where it is the maximum, but rather making an item deal damage when you craft it? Link to comment Share on other sites More sharing options...
Raddior Posted June 17, 2020 Share Posted June 17, 2020 Can I increase my character's inventory? Link to comment Share on other sites More sharing options...
lunapanshiel Posted June 18, 2020 Share Posted June 18, 2020 (edited) this guide is useful except that all the parts about changing character damage ONLY work in reign of giants, in shipwrecked/hamlet the DamageMultiplier no longer works Edited June 18, 2020 by lunapanshiel Link to comment Share on other sites More sharing options...
fixerhere Posted October 23, 2020 Share Posted October 23, 2020 Ok so i can't figure out why it doesn't work for me I wanted to make gears and frazzled wires eatable but i don't know why it doesn't work here's the code GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("gears", function(inst) if GetPlayer().prefab == "fixer" then inst.components.edible.foodtype = "ELE" end end) AddPrefabPostInit("trinket_6", function(inst) if GetPlayer().prefab == "fixer" then inst.components.edible.foodtype = "ELE" end end) AddPrefabPostInit("gears", function(inst) if GetPlayer().prefab == "fixer" then inst:AddComponent("edible") inst.components.edible.foodtype = "ELE" inst.components.edible.healthvalue = 80 inst.components.edible.hungervalue = 70 inst.components.edible.sanityvalue = 120 end end) AddPrefabPostInit("trinket_6", function(inst) if GetPlayer().prefab == "fixer" then inst:AddComponent("edible") inst.components.edible.foodtype = "ELE" inst.components.edible.healthvalue = 40 inst.components.edible.hungervalue = 35 inst.components.edible.sanityvalue = 60 end end) 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