Jump to content

Recommended Posts

I don't remember exactly where it is, but I know that this is set on the sleeping-aids and not the character. Look in bedroll_straw.lua, bedroll_furry.lua, tent.lua and/or siestahut.lua. They have different values. I don't think this kind of change lends itself well for a character mod.

Not saying you can't find a workaround, though. Something about listening for a sleep-event, and when that triggers, unregister from it, set a hungerbeforesleep variable on the player, and then listen for a wakeup event. When the wakeup-event triggers you could subtract a specific amount from hungerbeforesleep, and set the hunger for your player to the result, then unregister from the wakeup-event and listen for the next sleep-event.

Edited by Ultroman

This should work -

It essentially rewrites the sleep function on the sleeping bags, etc.

So that if the character name is your CHARNAME

then the sleep function restores a number of calories after the sleep.

You should be able to place it in the modmain.lua, of your mod.

Spoiler

 

-- BEDROLL || 33 Sanity || 0 Health || -75 Hunger

function newsleepbag(inst)

   local oldonsleep = inst.components.sleepingbag.onsleep

    inst.components.sleepingbag.onsleep = function(inst, sleeper)
      oldonsleep(inst, sleeper)
        if sleeper.prefab == "CHARNAME" then
        sleeper:DoTaskInTime(1.3, function()
            sleeper.components.hunger:DoDelta(30, false, true)

-- Restores 30 calories after the Bedroll's normal function removes 75

        end)
        end
    end
end

-- FURROLL || 33 Sanity || 30 Health || -75 Hunger 

function newsleepfur(inst)

   local oldonsleep = inst.components.sleepingbag.onsleep

    inst.components.sleepingbag.onsleep = function(inst, sleeper)
      oldonsleep(inst, sleeper)
        if sleeper.prefab == "CHARNAME" then
        sleeper:DoTaskInTime(1.3, function()
            sleeper.components.hunger:DoDelta(30, false, true)

-- Restores 30 calories after the Fur roll's normal function removes 75
        end)
        end
    end
end

-- TENT || 50 Sanity || 60 Health || -75 Hunger

function newsleeptent(inst)

   local oldonsleep = inst.components.sleepingbag.onsleep

    inst.components.sleepingbag.onsleep = function(inst, sleeper)
      oldonsleep(inst, sleeper)
        if sleeper.prefab == "CHARNAME" then
        sleeper:DoTaskInTime(1.3, function()
            sleeper.components.hunger:DoDelta(30, false, true)
  -- Restores 30 calories after the Tent's normal function removes 75
        end)
        end
    end
end

-- LEANTO || 50 Sanity || 60 Health || -25 Hunger

function newsleepseiesta(inst)

   local oldonsleep = inst.components.sleepingbag.onsleep

    inst.components.sleepingbag.onsleep = function(inst, sleeper)
      oldonsleep(inst, sleeper)
        if sleeper.prefab == "CHARNAME" then
        sleeper:DoTaskInTime(1.3, function()
            sleeper.components.hunger:DoDelta(10, false, true)
  -- Restores 10 calories after the Tent's normal function removes 25
        end)
        end
    end
end

--adds the newsleep function to bedroll_straw, bedroll_furry, and tent
AddPrefabPostInit("bedroll_straw", newsleepbag)
AddPrefabPostInit("bedroll_furry", newsleepfur)
AddPrefabPostInit("tent", newsleeptent)
AddPrefabPostInit("siestahut", newsleepsiesta)


 

 

Sorry for answering that late, but thanks for your answers! Gonna give it a try asap.

Ok so, I've tried and there is a problem. Even if the character doesn't sleep the hunger is still restored. Right-clicking on a tent during the day will restore 30 hunger freely, for exemple.

Edited by GalloViking

You need to check out the original functions in bedroll_straw.lua, bedroll_furry.lua, tent.lua and siestahut.lua. I believe they have some sort of check for daytime. You must employ this as well around your hunger-change. I'm not sure you need this for bedrolls, though. Bedrolls and tent/siestahut work differently.

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