Jump to content

Loop all players, slow down temperature


Recommended Posts

In my new (first mod) I'm trying to figure out how to loop all players and if they're standing on GROUND.CARPET then make their temperature slow down (if decreasing) and/or add a small amount of heat that the carpet applies.

I have no idea how to do this, I had a look at 2 other temperature mods but I don't think they gave useful to my case here.

Edited by Dcrew
Link to comment
Share on other sites

You cannot interfere with the temperature calculations without great peril. I would just add a constant increase in heat, if the temperature rate is currently negative. Put this in your modmain.lua

AddPlayerPostInit(function(inst)
	inst:DoTaskInTime(1.0, function(inst)
		if inst.components.temperature and inst.components.temperature.rate < -0.1 then
			local map = TheWorld.Map
			local tile_type = map:GetTileAtPoint(pt:Get())
			if tile_type == GLOBAL.GROUND.CARPET then
				inst.components.temperature:DoDelta(0.1)
			end
		end
	end)
end)

 

Link to comment
Share on other sites

do you think adding insulation to your character while standing on carpet would be sufficient?
If so, look at my "home base bonus" mod, it does exactly this.
https://steamcommunity.com/sharedfiles/filedetails/?id=738448215

winter insulation makes your temperature gown down slower, which is dangerous in summer.

or some better code is found within my critter bonus mod, adding insulation to every player that is near a critter:
https://steamcommunity.com/sharedfiles/filedetails/?id=1188606939

Edited by Serpens
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...