Jump to content

Recommended Posts

I've come up with a cool character idea after playing as Woodlegs and his constant sanity loss on land, and I was wondering how to reverse the code to where a character takes sanity loss while sailing.

local function sanityfn(inst)
    local x, y, z = inst.Transform:GetWorldPosition()
    
    local ground = GetWorld()
    local tile = GROUND.GRASS
    if ground and ground.Map then
        tile = ground.Map:GetTileAtPoint(x, y, z)
    end

    local onWater = ground.Map:IsWater(tile)

    local delta = 0
    if not onWater then
        delta = TUNING.WOODLEGS_WATER_SANITY
    end
    
    return delta
end

Any help would be greatly appreciated.

Sorry if I sound noobish, but whenever I put the function that corresponds to the water sanity in the main fn (inst.components.sanity.custom_rate_fn = sanityfn) which is where it's located in Woodleg's prefab, it keeps crashing the game when I load the character up with the error message "variable 'sanityfn' is not declared" in the log. I dunno what to do.

Edited by SecretCereal

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