Jump to content

Simple Character Mod, add extra Sanity Drain to Wetness Gauge


Recommended Posts

Here's the gist; I've been creating a simple character mod but I have extremely little knowledge of coding. Everything I've done so far has been done with the help of tutorials. However, I have a specific character trait that I haven't seen anyone else give any hints on how to do. That being a boost to the sanity drain from being wet.

If anyone has any tips on where to even start with this, I'd be very grateful!

Mod folder attached.

Dolly.zip

Link to comment
Share on other sites

local function onprecipitationchanged(src, preciptype)
		if preciptype == "rain" then
			inst.components.sanity.dapperness = dapperness_onrain
		else
			inst.components.sanity.dapperness = -1
		end
	end
	inst:ListenForEvent("precipitationchanged", function(wrld, data) onprecipitationchanged(inst, data) end, TheWorld)
	
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload

This is from the mod Drako, a character who gained sanity from the rain, but I tweaked the code to make the character lose sanity during the rain. This code goes into master postinit.

Link to comment
Share on other sites

2 hours ago, Andreasgamming said:

local function onprecipitationchanged(src, preciptype)
		if preciptype == "rain" then
			inst.components.sanity.dapperness = dapperness_onrain
		else
			inst.components.sanity.dapperness = -1
		end
	end
	inst:ListenForEvent("precipitationchanged", function(wrld, data) onprecipitationchanged(inst, data) end, TheWorld)
	
	
	inst.OnLoad = onload
    inst.OnNewSpawn = onload

This is from the mod Drako, a character who gained sanity from the rain, but I tweaked the code to make the character lose sanity during the rain. This code goes into master postinit.

Tysm! This is amazing help, but I'm not quite sure where the 'master postinit' is. Is it located in the character mod folder or...?

Link to comment
Share on other sites

1 hour ago, Andreasgamming said:

Oh, it is located under scripts-->prefabs--->dolly.lua

The code that manages the amount of health, sanity and hunger.

Again, thank you for your help. However, when I put this line of code into the master postinit, I ran a game, hosted the mod, turned on rain and got this crash.

Image attached.

crash log.PNG

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...