Paste #54461: Untitled Paste

Date: 2019/05/26 13:59:57 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Sleeper:
    type: assignment

    actions:
        on assignment:
            - define location_name "Home"
            - chat "I have saved this location as <def[location_name]>."
            - anchor add <npc.location> "id:<def[location_name]>"
        on spawn:
            - run Sleeper_Task
        on sleep check:
            - run Sleeper_Task

Sleeper_Task:
    type: task
    script:
        - define time <w@world.time>
        - if <def[time]> > 16000 {
            - if !<npc.flag[resting]> {
                - if !<npc.location.cuboids.is_empty> {
                    - define inCuboid <npc.location.cuboids.get[1]>
                    - define bedLoc <def[inCuboid].blocks[white_bed].get[1].center>
#                    - define bedLoc2 <def[bedLoc1].find.blocks[white_bed].within[1]>
#                    - define bedLoc <def[bedLoc1].add[<def[bedLoc1].sub[<def[bedLoc2]>].mul[1]>]>
                    - walk <def[bedLoc]>
                    - announce <def[bedLoc]>
                    - while <npc.navigator.is_navigating> {
                        - wait 5s
                    }
#                    - teleport <npc> <def[bedLoc]> 
#                    - wait 1s
#                    - animate <npc> animation:SLEEP
                    - lookclose <npc> false
                    - sit <def[bedLoc].add[0,-0.70,0]>
                    - look <npc> <def[bedLoc].sub[<def[bedLoc].block_facing>].add[0,1,0]>
                    - flag <npc> resting:true
                }
            }
        }
        else {
            - stand
            - flag <npc> resting:false
            - lookclose <npc> true
#            - animate <npc> animation:STOP_SLEEPING
            - walk <npc.anchor[<npc.anchor.list.get[1]>]>
        }