Jump to content

Temperature check character mod help


Recommended Posts

I was attempting to create a character that has buffs when cold and de-buffs when hot and found a way to check temperature on the forums however I needed it modified to work for both hot and cold. This is my first attempt at trying to code myself so of course... the game crashed. going back through the code I can not find any issues with it but as I said, I am inexperienced. 

This is the code:

local function CheckTemperature(inst)
        if inst.components.temperature then
            local t = inst.components.temperature
            if t:GetCurrent() > 15 and t:GetCurrent() < 60 and not inst:HasTag("tempy") then
                inst:AddTag("tempy")
                inst:RemoveTag("tempz") and RemoveTag("tempx") 
                inst.components.sanity.dapperness = 0
                inst.components.health:StartRegen(0, 0)    
                inst.components.hunger.burnrate = 1
                inst.components.health.absorb = 0.10    
                inst.components.combat.damagemultiplier = 1
                inst.components.locomotor.walkspeed = 4
                inst.components.locomotor.runspeed = 6
            end
            if t:GetCurrent() < 15 and not inst:HasTag("tempz") then
                inst:AddTag("tempz")
                inst:RemoveTag("tempy")
                inst.components.sanity.dapperness = 2
                inst.components.health:StartRegen(1, 1)    
                inst.components.hunger.burnrate = 0.5
                inst.components.health.absorb = 0.20    
                inst.components.combat.damagemultiplier = 1.25
                inst.components.locomotor.walkspeed = 4.5
                inst.components.locomotor.runspeed = 7
            end
             if t:GetCurrent() > 60 and not inst:HasTag("tempx") then
                inst:AddTag("tempx")
                inst:RemoveTag("tempy")
                inst.components.sanity.dapperness = -2
                inst.components.health:StartRegen(-1, 1)    
                inst.components.hunger.burnrate = 2
                inst.components.health.absorb = 0    
                inst.components.combat.damagemultiplier = 0.75
                inst.components.locomotor.walkspeed = 3.5
                inst.components.locomotor.runspeed = 5
            end
        end
    end
    inst:DoPeriodicTask( 0.0, function(inst)
        CheckTemperature(inst)
    end)

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