Jump to content

Recommended Posts

Hello everyone!

I have a question - that's probably the most common thing to say in here. But I need to acknowledge the fact that I am new to modding and I need your help. I have created a character, art and everything is in place. Now I wanted to add some perks. I would need somebody to help me get the perks working or at least say to me where to put them (in which folder etc).

First perk would be rising sanity from collecting manure, the same way flowers do. I think I will get it done myself. Is that right?

local master_postinit(inst)

inst:ListenForEvent("onpickup", function(inst, data)

if data.item.prefab == "poop" then

inst.components.sanity:DoDelta(5)

end

end)

I don't know if this is going to help me as I want only my character to be able to get benefits from picking up poop.

Second perk is lower insulation and by that I mean faster freezing. I have no clue how to add it whatsoever. The only thing I know is that should be added to 'mycharactername'.lua, and that's basically it. I know it must be a really basic code but I need somebody to hold my hand as I have no idea what to do with it.

Third thing is a lamp, working the same way Willow's lighter is, but emitting more light and not giving temperature. My question for this perk is if I can use the lighter code or would it be better to create a new item from scratch? I don't need any of you to write the exact code by yourself - all I need is pinpointing some threads or tutorials - I am quite intelligent person and I can learn from other people how to do my own stuff.

Thanks in advance. I need this help as soon as possible. Me and my fiance love to play this game, so I've created a characters of me and her for this game but I wanted to give it to her on our anniversary which is in two days... well... tomorrow.

Damn it, something went wrong with the text and I have no clue how to edit it so I will post it again in a more beautiful manner:

 

Hello everyone! I have a question - that's probably the most common thing to say in here. But I need to acknowledge the fact that I am new to modding and I need your help. I have created a character, art and everything is in place. Now I wanted to add some perks. I would need somebody to help me get the perks working or at least say to me where to put them (in which folder etc). First perk would be rising sanity from collecting manure, the same way flowers do. I think I will get it done myself. Is that right?
 
local master_postinit(inst)    inst:ListenForEvent("onpickup", function(inst, data)        if data.item.prefab == "goldnugget" then            inst.components.<span class="searchlite">sanity</span>:DoDelta(5)        end    end)
 
 
 
I don't know if this is going to help me as I want only my character to be able to get benefits from picking up poop. Second perk is lower insulation and by that I mean faster freezing. I have no clue how to add it whatsoever. The only thing I know is that should be added to 'mycharactername'.lua, and that's basically it. I know it must be a really basic code but I need somebody to hold my hand as I have no idea what to do with it.
 
Third thing is a lamp, working the same way Willow's lighter is, but emitting more light and not giving temperature. My question for this perk is if I can use the lighter code or would it be better to create a new item from scratch? I don't need any of you to write the exact code by yourself - all I need is pinpointing some threads or tutorials - I am quite intelligent person and I can learn from other people how to do my own stuff.
 
Thanks in advance. I need this help as soon as possible. Me and my fiance love to play this game, so I've created a characters of me and her for this game but I wanted to give it to her on our anniversary which is in two days... well... tomorrow. 

Be wary that you copied BBCode.

local function master_postinit(inst)    inst:ListenForEvent("onpickup", function(inst, data)        if data.item.prefab == "poop" then            inst.components.sanity:DoDelta(5)        end    end)end

Yes, if put in the master_postinit then it only affects your character.

 

 

Considerations here are:

 

1) If you pickup a stack of say, 5 poop, you don't get 25 sanity, you just get 5.

 

2) You can drop and pickup 1 poop repeatedly to repeatedly get 5 sanity.

 

 

Regarding temperature, you can:

 

1) Give yourself negative inherent insulation, as in

local function master_postinit(inst)	inst.components.temperature.inherentinsulation = -15end

So if you have nothing, your insulation is 0, and if you have an insulation value of 15, your insulation is 0.

Thus, you freeze faster.

 

2) Edit SetTemperature, so values going down go down faster, as in

local function master_postinit(inst)	local old = inst.components.temperature.SetTemperature	inst.components.temperature.SetTemperature = function(self, value)		local last = self.current		local current = value		if (last - current) > 0 then			value = value + self.rate		end		return old(self, value)	endend

3) Or append an extra SetTemperature to the temperature update, as in

local function master_postinit(inst)	local old = inst.components.temperature.OnUpdate	inst.components.temperature.OnUpdate(self, dt, applyhealthdelta)		old(self, dt, applyhealthdelta)		if self.rate < 0 then			self:SetTemperature(math.clamp(self.current + self.rate * dt, self.mintemp, self.maxtemp))		end	endend

so if we are cooling down, we do it at double the sets.

 

 

You should be able to use the lighter or torch code, yeah.

The light part of them is in lighterfire and torchfire, respectively.

 

In the prefab, on the onequip function, you get a prefabfire attached to the entity.

The prefabfires are 4/5 part emitter to make that cool orangey blob, and 1/5 light related.

Thank you, I've done everything. Could you jest tell me what's the easiest way to check if the insulation is working? I have set it to -100 just to test if I will imidiately freeze, but I didn't. Do you know any way to easily check it?

@CarbonLord, to check the insulation put something like -300, then look how much time you need to freeze naked, and then how much time you need to freeze wearing a puffy vest and beefalo hat. It should be the same.

 

Get the items via:

c_spawn("trunkvest_winter")

c_spawn("beefalohat")

 

To modify rates, you will need to use the other methods.

Okay, after 36 seconds when my character is naked my temperature goes down to 6 degrees - the same happens on naked Wilson, so either both of them got insulation number of -300, or the code is not working.

local function master_postinit(inst)    inst.components.temperature.inherentinsulation = -300end

I have put this in mycharactername.lua.

did I do something wrong?

@CarbonLord, winterInsulation in GetInsulation gets capped at 0.

Thus having 0 clothes insulation minus 300 inherent insulation gives you 0 insulation.

 

So it makes sense that you, with 0 insulation, freeze like Wilson, with 0 insulation.

 

To make you "freeze faster", I suggested to make clothes less useful to your character.

 

If you want to change that 36 second number into something else, you will have to use method 2 or 3.

With method 2, you tune:

value = value + self.rate-- where you can change self.rate into other numbers-- or multiply self.rate by 2-- or divide it-- example: value = value + (self.rate + 1 / self.rate)

With method 3, you tune:

self.current + self.rate * dt-- where you can change self.rate into other numbers-- or multiply self.rate by 2-- or divide it-- example: self.current + self.rate * dt * 2

Oh, I just thought you made a mistake when writing the sentence about running around naked, then running around wearing clothes. I just couldn't imagine that the time to freeze would be the same with and without clothes but now I get it. I will still use method number one. It might not be the most original idea for a perk, but it's certainly something. Thank you very much for your help. This thread may be closed now.

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...