Jump to content

Sleeping at day


Recommended Posts

I believe he ended up replacing the prefab though.

 

Anyway I'm still stuck on this. I keep getting this error:

[string "../mods/Seras/modmain.lua"]:174: attempt to call global 'AddStateGraphPostInit' (a nil value)

when I try to modify the WilsonSG function as suggested.

 

Probably I'm making some error with the AddStateGraphPostInit. I don't really get how it works.

AddStateGraphPostInit("wilson", function(sg)    local oldOnEnter = sg.states.bedroll.onenter    function newOnEnter(inst)        if inst:HasTag("nocturnal") then            -- Code copied from SGWilson            inst.components.locomotor:Stop()                if TheWorld.state.isnight then                inst:PushEvent("performaction", { action = inst.bufferedaction })                inst:ClearBufferedAction()                inst.sg:GoToState("idle")                inst.components.talker:Say(GetString(inst, TheWorld:HasTag("cave") and "ANNOUNCE_NODAYSLEEP_CAVE" or "ANNOUNCE_NODAYSLEEP"))                return            end                        local danger = FindEntity(inst, 10, function(target) return target:HasTag("monster") or target.components.combat and target.components.combat.target == inst end)            local hounded = TheWorld.components.hounded            if hounded and (hounded:GetWarning() or hounded:GetTimeToAttack() <= 0) then                danger = true            end                        if danger then                inst:PushEvent("performaction", { action = inst.bufferedaction })                inst:ClearBufferedAction()                inst.sg:GoToState("idle")                inst.components.talker:Say(GetString(inst, "ANNOUNCE_NODANGERSLEEP"))                return            end                        inst.components.health:SetInvincible(true) -- Just while we play the initial anim            inst.AnimState:PlayAnimation("action_uniqueitem_pre")            inst.AnimState:PushAnimation("bedroll", false)                        if inst.components.grue ~= nil then                inst.components.grue:SetSleeping(true)            end                        if inst.components.talker ~= nil then                inst.components.talker:IgnoreAll()            end                        if inst.components.firebug ~= nil then                inst.components.firebug:Disable()            end                        inst:OnSleepIn()            inst.components.inventory:Hide()            if inst.components.playercontroller ~= nil then                inst.components.playercontroller:EnableMapControls(false)                inst.components.playercontroller:Enable(false)            end                    else            oldOnEnter(inst)        end    endend)
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...