Sign in to follow this  
RadiantRoma

Sleeping indifferent to time of day

Recommended Posts

RadiantRoma    386

I would like a character of mine to be able to sleep during the day, dusk, night and in caves.

If it would be easier to make a custom sleeping item, that would be good too. But it would be preferable for it to work with every bed. I looked through other mods that had similar abilities, but they led to dead ends that I couldn't figure out.

Thank you for any help!

Edited by Cherryzion

Share this post


Link to post
Share on other sites
Serpens    551

Hmm.. I took a look at the game code and you would need to modify two things:
In the tent.lua you need to modify "wakeuptest".
And in stategraph "SGwilson.lua" , the parts where ""ANNOUNCE_NODAYSLEEP"" or night/cave equivalent is used.

The wakeuptest functino is a local function, so you can't change it that simple. The simplest way would be to completely replace the old tent.lua file with your edited file.
I never edited a stategraph and don't know much about it, so I can't tell you how to do this.

But my advice would be:
Make a new sleeping item exclusive to your character instead. This might be much easier.

Share this post


Link to post
Share on other sites
RadiantRoma    386

So! I am going to make a custom bedroll, and I'm pretty certain the prefab I created will be alright. I'll post the prefab to this post. The prefab basically follows the animations and states in SGwilson.lua,, so I need to change the stategraph thing. I'm not accustomed to changing state graphs, and don't really know how to. 

In SGwilson, I found this under local states, state = bedroll,

Spoiler

local failreason =
                (TheWorld.state.isday and
                    (TheWorld:HasTag("cave") and "ANNOUNCE_NODAYSLEEP_CAVE" or "ANNOUNCE_NODAYSLEEP")
                )

                or (IsNearDanger(inst) and "ANNOUNCE_NODANGERSLEEP")
                -- you can still sleep if your hunger will bottom out, but not absolutely
                or (inst.components.hunger.current < TUNING.CALORIES_MED and "ANNOUNCE_NOHUNGERSLEEP")
                or (inst.components.beaverness ~= nil and inst.components.beaverness:IsStarving() and "ANNOUNCE_NOHUNGERSLEEP")
                or nil

            if failreason ~= nil then
                inst:PushEvent("performaction", { action = inst.bufferedaction })
                inst:ClearBufferedAction()
                inst.sg:GoToState("idle")
                if inst.components.talker ~= nil then
                    inst.components.talker:Say(GetString(inst, failreason))
                end
                return
            end
 

So if I could just change the line that is bolded, or just completely remove it, I think it would work well. Would changing this line affect everyone in the server, just my character, or just my custom bedroll?

If someone could help, I'd really appreciate it!

sleepbag.lua

Share this post


Link to post
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
Sign in to follow this