Jump to content

New to Modding, Need Help Figuring Out Something


Recommended Posts

 So me and my friend are making some characters for Don't Starve. Both of our characters have something in common, we both don't lose sanity because what our characters are.

So I ask you, how do I edit my character so he doesn't lose sanity? I know it might be a script thing but I am not sure where I'd put the script (sorry I don't know scripting very well either). If I had to guess, maybe you would tell me to put it in the scripts folder? If that is wrong or right, please tell me.

The other thing I need to figure out is how to make a character's hunger decrease slower. I'd say maybe 25% slower then the normal amount.

Lastly my friend wants to do something I couldn't even begin to guess how to do. He wants it to where when he kills something, he gains health.

If you could help me figure out how to do these, much would be appreciated. If you could also point me in the right direction of learning how to do these things myself, I'd love to learn. But for now, I have no idea how to do anything but make a character so I need all the help I can get.

Thanks for reading and take it easy! ^_^

Link to comment
Share on other sites

@Sauleviticus

 

Simplest way to remove sanity would be to remove the sanity component altogether.

inst:RemoveComponent("sanity")

But this may arise problems when another component tries to access it without checking. So another way would be to add a lot of dapperness.

inst.components.sanity.dapperness = 1000

To change the hunger rate:

local hunger_multiplier = 0.75 -- 25% slower than normalinst.components.hunger:SetRate(hunger_multiplier*TUNING.WILSON_HUNGER_RATE)

And to gain health when killing things:

local function health_onkill(cause)	local heal_amount = 10    inst.components.health:DoDelta(heal_amount,false,cause)endinst:ListenForEvent( "killed", function(inst,data) health_onkill(data.victim) end )

All of these would go in your character's create fn.

local fn = function(inst)	-- dapperness increases sanity automatically over time	inst.components.sanity.dapperness = 1000	-- Sets the hunger rate lower by multiplying it by 0.75, just simple math	local hunger_multiplier = 0.75 -- 25% slower than normal	inst.components.hunger:SetRate(hunger_multiplier*TUNING.WILSON_HUNGER_RATE)	-- A function that will run whenever something is killed	local function health_onkill(cause)		local heal_amount = 10		-- Adds the heal_amount to your health, giving the name of the victim as the cause		inst.components.health:DoDelta(heal_amount,false,cause)	end	-- Add a listener that checks when something is killed by you, then runs the function above.	-- data.victim contins the name of the thing you killed.	inst:ListenForEvent( "killed", function(inst,data) health_onkill(data.victim) end )end

See if it works.

 

Edit: Added comments for explanation.

Link to comment
Share on other sites

So wait, I don't understand where I would put this. I am guessing I make a new file with notepad++. Inside it would be:
 

local fn = function(inst)    -- dapperness increases sanity automatically over time    inst.components.sanity.dapperness = 1000    -- Sets the hunger rate lower by multiplying it by 0.75, just simple math    local hunger_multiplier = 0.75 -- 25% slower than normal    inst.components.hunger:SetRate(hunger_multiplier*TUNING.WILSON_HUNGER_RATE)    -- A function that will run whenever something is killed    local function health_onkill(cause)        local heal_amount = 10        -- Adds the heal_amount to your health, giving the name of the victim as the cause        inst.components.health:DoDelta(heal_amount,false,cause)    end    -- Add a listener that checks when something is killed by you, then runs the function above.    -- data.victim contins the name of the thing you killed.    inst:ListenForEvent( "killed", function(inst,data) health_onkill(data.victim) end )end

But where would that file go? Into the scripts folder? I don't get what you mean by:
 

All of these would go in your character's create fn.

 

I haven't seen anything like that in my character's files. Could you give a step by step instruction if possible? Please and thank you. :)

Link to comment
Share on other sites

@Sauleviticus

 

Do you have a prefab file for your character?

"..\Your_Mod_Root_Folder\scripts\prefabs\your_character.lua"

Inside there, do you see the "fn" function?

local fn = function(inst)

The code I provided would go inside that function.

 

 

If your answer for any of the questions above isn't yes, I recommend you see this sample character mod and read at least one of these tutorials.

 

 

Most people learn how to mod Dont Starve by looking through the original game files or other mods.

 

Default locations of original code if you haven't changed them yourself:

 

Steam/Windows: C:\Program Files (x86)\Steam\SteamApps\common\dont_starve\data\scripts
Standalone/Windows: C:\Program Files\dontstarve\data\scripts
Standalone/Mac: /Applications/Don't Starve/Don't Starve.app/Contents/data/scripts
Steam/Linux: /home/username/.local/share/Steam/SteamApps/common/dont_starve/data/scripts

 

Link to comment
Share on other sites

umm hi :) i just want to ask if whats wrong with my custom mod. it seems like my png animation file crashes the whole game. i do not know what was my mistake there. any response will help a lot thankyou! <3


umm hi :) i just want to ask if whats wrong with my custom mod. it seems like my png animation file crashes the whole game. i do not know what was my mistake there. any response will help a lot thankyou! <3

Link to comment
Share on other sites

@Sauleviticus, Like Blueberrys says, you should check the other tutorials first and get a basic understanding of coding and the games structure. Otherwise too many things that people on this forum will say to help you will not make any sense.

 

@yanderequeeN, if you have a problem you should respect two things:
A) Don't misuse someone else's thread for your problem!

b) Give us either your mod or at least a log file to look at! (log is in Documents/Klei/DoNotStarve/log.txt)

Link to comment
Share on other sites

@Sauleviticus

 

Do you have a prefab file for your character?

"..\Your_Mod_Root_Folder\scripts\prefabs\your_character.lua"

Inside there, do you see the "fn" function?

local fn = function(inst)

The code I provided would go inside that function.

 

 

If your answer for any of the questions above isn't yes, I recommend you see this sample character mod and read at least one of these tutorials.

 

 

Most people learn how to mod Dont Starve by looking through the original game files or other mods.

 

Default locations of original code if you haven't changed them yourself:

 

Steam/Windows: C:\Program Files (x86)\Steam\SteamApps\common\dont_starve\data\scripts

Standalone/Windows: C:\Program Files\dontstarve\data\scripts

Standalone/Mac: /Applications/Don't Starve/Don't Starve.app/Contents/data/scripts

Steam/Linux: /home/username/.local/share/Steam/SteamApps/common/dont_starve/data/scripts

Blueberrys

 

Alright, I think I will check it out. Since you are here and you seem pretty good at coding, unlike me. Could you let me know if these are possible and how?

I want my character to take more damage to fire.

I want my character to be immune to damage during the winter. If possible, no freezing screen.

The last thing I am going to do is make a powerful weapon but I think I found a thread for that so I won't ask. Sorry I'm asking for so much help, I will also check what you sent when I have a moment. Thank you for all your help so far, you're a pretty cool guy. :grin:

Link to comment
Share on other sites

@Sauleviticus, Like Blueberrys says, you should check the other tutorials first and get a basic understanding of coding and the games structure. Otherwise too many things that people on this forum will say to help you will not make any sense.

 

@yanderequeeN, if you have a problem you should respect two things:

A) Don't misuse someone else's thread for your problem!

b) Give us either your mod or at least a log file to look at! (log is in Documents/Klei/DoNotStarve/log.txt)

Well I have made a workable character that people have liked so I got that going for me. Just because I don't know this more advanced stuff doesn't mean I don't know a few things.

 This kinda stuff wasn't in the tutorials I read and watched. Not to mention I couldn't find that link he gave me for my life. xD

Link to comment
Share on other sites

@Sauleviticus

 

Do you have a prefab file for your character?

"..\Your_Mod_Root_Folder\scripts\prefabs\your_character.lua"

Inside there, do you see the "fn" function?

local fn = function(inst)

The code I provided would go inside that function.

 

 

If your answer for any of the questions above isn't yes, I recommend you see this sample character mod and read at least one of these tutorials.

 

 

Most people learn how to mod Dont Starve by looking through the original game files or other mods.

 

Default locations of original code if you haven't changed them yourself:

 

Steam/Windows: C:\Program Files (x86)\Steam\SteamApps\common\dont_starve\data\scripts

Standalone/Windows: C:\Program Files\dontstarve\data\scripts

Standalone/Mac: /Applications/Don't Starve/Don't Starve.app/Contents/data/scripts

Steam/Linux: /home/username/.local/share/Steam/SteamApps/common/dont_starve/data/scripts

One more thing, I seem to have figured out how to implement the code into the game. The sanity thing is kinda working. Sanity increases during the day by a very small bit. But during dusk and night, it decreases. So right now, my sanity is decreasing faster then I am gaining sanity.

Is there possibly another code line or maybe a way to edit it to recover allot faster? Thanks and I shall await your post on both my replies. :D

Link to comment
Share on other sites

If you dont lose MORE sanity during the night than you can ever gain during the day then its pointless to lose it at all. The purpose of losing sanity is so you have to take action to prevent going insane. Not just have a cycle of going down then being fully restored with no effort.

Link to comment
Share on other sites

If you dont lose MORE sanity during the night than you can ever gain during the day then its pointless to lose it at all. The purpose of losing sanity is so you have to take action to prevent going insane. Not just have a cycle of going down then being fully restored with no effort.

 

Having for example a character that will drain his whole sanity at night, forcing you to engage with halucinations, and restore his sanity during the day, giving you the chance to progress properly, could make for an interesting game as well  ;) 

Link to comment
Share on other sites

I completely agree a character who loses all their sanity (on average) during a full night would be nice.  I just dont think the sanity they get back during the day should restore their bar fully.  The loss should still be more than the gain without actively taking measures to restore sanity by the player through foods or rest.

Link to comment
Share on other sites

I completely agree a character who loses all their sanity (on average) during a full night would be nice.  I just dont think the sanity they get back during the day should restore their bar fully.  The loss should still be more than the gain without actively taking measures to restore sanity by the player through foods or rest.

 

But the point of there character isn't to lose sanity at all. This character is meant to be completely immune to the effects of losing sanity. I don't mind if I have to use some makeshift way by gaining sanity quickly during the day.

This is why my character right now has 999 sanity... just so he can be played till one of his major "bugs" is fixed. 

Link to comment
Share on other sites

Blueberrys

 

Alright, I think I will check it out. Since you are here and you seem pretty good at coding, unlike me. Could you let me know if these are possible and how?

I want my character to take more damage to fire.

I want my character to be immune to damage during the winter. If possible, no freezing screen.

The last thing I am going to do is make a powerful weapon but I think I found a thread for that so I won't ask. Sorry I'm asking for so much help, I will also check what you sent when I have a moment. Thank you for all your help so far, you're a pretty cool guy. :grin:

 

Yes they are possible. You'll be able to figure out a lot of things simply by reading through the games code. Have a look at these files and see if you can find what you need.

"..\scripts\components\health.lua" (for fire damage, remember to look for "fire")

"..\scripts\components\temperature.lua" (for freezing damage, remember to look for "health" or "freeze")

If you aren't sure what to do with the code you find, just ask.

 

Asking for help is a great way to learn, don't worry about it!

 

 

One more thing, I seem to have figured out how to implement the code into the game. The sanity thing is kinda working. Sanity increases during the day by a very small bit. But during dusk and night, it decreases. So right now, my sanity is decreasing faster then I am gaining sanity.

Is there possibly another code line or maybe a way to edit it to recover allot faster? Thanks and I shall await your post on both my replies. :grin:

 

Look at the comments in the code I provided earlier, it says something about dapperness. I think you can figure this one out, give it a try.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...