Jump to content

Recommended Posts

Hi! I began to work on my own mod. I've figured out a lot by myself but I'll need help to continue.

 

The first thing I wanted to do was to modify the sanity rate under certain circumstances. I looked in Willow's file and took this code and used it to make my character become happy during the winter.

local function sanityfn()	local i=0	if(GetSeasonManager():GetSeasonString()=="winter") then		i=0.2	end	i=i+wod:CountFollowers(false)*0.1	return iendlocal fn = function(inst)        -- choose which sounds this character will play    inst.soundsname = "wolfgang"    -- a minimap icon must be specified    inst.MiniMapEntity:SetIcon( "wilson.png" )    -- todo: Add an example special power here.    inst.components.health:SetMaxHealth(800)    --inst.components.leader:CountFollowers(false)     inst.components.sanity.custom_rate_fn = sanityfn        end

The next thing I want to do is to make him happier if he have more followers.

inst.components.leader:CountFollowers(false) 

This line is giving me my number of followers but I am not able to send it to the function above.

I think that my code is executed in the sanity.lua file. So it won't get any parameter and I can't call this line in the function.

I hope that you understand what I wanted to do. Is-there any way to get this number from the sanity file?

 

My thanks to anybody who could help me!

custom_rate_fn is called with the prefab as the parameter, you just need to catch it in your sanityfn.

local function sanityfn( inst )	-- inst is the prefab that the sanity component is added to (in this case, your character)	local numfollowers = inst.components.leader:CountFollowers()end
By the way, you don't have to specifically do CountFollowers(false); if you call CountFollowers without a parameter, then the parameter will be "nil" and "not nil" evaluates to true, so it'll work the same way.

Oh yes! I remember!

 

I did that but I had an error wich is actually corrected and I didn't try again!

 

and the false was in the processus of "omg, the game crash, something is wrong, I'll try to change that or that see if it help"

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
×
  • Create New...