Paste #48231: Untitled Paste

Date: 2018/06/29 19:24:40 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"Heavens Handler":
    type: world
    events:
        on player right clicks quartz_block with flint_and_steel in prosperus:
        - if <context.location.add[0,1,0].material> != m@air
        {
            - queue clear
        }
        - if <context.location.add[1,0,0].material> == m@quartz_block && <context.location.add[-1,0,0].material> == m@quartz_block
        {
            - define axis-pos 1,0,0
            - define axis-neg -1,0,0
            - define axis-data 1
            - define axis x
        }
        else if <context.location.add[0,0,1].material> == m@quartz_block && <context.location.add[0,0,-1].material> == m@quartz_block
        {
            - define axis-pos 0,0,1
            - define axis-neg 0,0,-1
            - define axis-data 2
            - define axis z
        }
        else
        {
            - queue clear
        }
        - define origin <context.location.add[0,1,0]>
        - define node <def[origin]>
        - define air-list li@
        - define y-list li@
        - define y-max <def[origin].y>
        - define y-min <def[origin].y>
        - define x-max <def[origin].x>
        - define x-min <def[origin].x>
        - define z-max <def[origin].z>
        - define z-min <def[origin].z>
        - while <def[node].material.is[==].to[m@air]>
        {
            - define air-list <def[air-list].include[<def[node]>]>
            - define y-list <def[y-list].include[<def[node]>]>
            - define y-max <def[y-max].max[<def[node].y>]>
            - define y-min <def[y-min].min[<def[node].y>]>
            - define node <def[node].add[0,1,0]>
        }
        - if <def[node].material> != m@quartz_block
        {
            - queue clear
        }
        else
        {
            - foreach <def[y-list]>
            {
                - define node <def[value]>
                - while <def[node].material.is[==].to[m@air]>
                {
                    - define air-list <def[air-list].include[<def[node]>]>
                    - if <def[axis-data]> == 1
                    {
                        - define x-max <def[x-max].max[<def[node].x>]>
                        - define x-min <def[x-min].min[<def[node].x>]>
                    }
                    - if <def[axis-data]> == 2
                    {
                        - define z-max <def[z-max].max[<def[node].z>]>
                        - define z-min <def[z-min].min[<def[node].z>]>
                    }
                    - define node <def[node].add[<def[axis-pos]>]>
                }
                - if <def[node].material> != m@quartz_block
                {
                    - queue clear
                }
                - define node <def[value]>
                - while <def[node].material.is[==].to[m@air]>
                {
                    - define air-list <def[air-list].include[<def[node]>]>
                    - if <def[axis-data]> == 1
                    {
                        - define x-max <def[x-max].max[<def[node].x>]>
                        - define x-min <def[x-min].min[<def[node].x>]>
                    }
                    - if <def[axis-data]> == 2
                    {
                        - define z-max <def[z-max].max[<def[node].z>]>
                        - define z-min <def[z-min].min[<def[node].z>]>
                    }
                    - define node <def[node].add[<def[axis-neg]>]>
                }
                - if <def[node].material> != m@quartz_block
                {
                    - queue clear
                }
            }
        }
        - modifyblock <def[air-list]> m@portal,<def[axis-data]> no_physics
        - define <def[axis]>-max <def[<def[axis]>-max].add[1>
        - define <def[axis]>-min <def[<def[axis]>-min].add[-1]>
        - define y-max <def[y-max].add[1]>
        - define y-min <def[y-min].add[-1]>
        - note cu@<def[x-min]>,<def[y-min]>,<def[z-min]>,prosperus|<def[x-max]>,<def[y-max]>,<def[z-max]>,prosperus as:heavens-portal-<util.random.duuid>
        on player breaks portal:
        - if <context.location.cuboids.contains_text[heavens-portal]>
        {
            - define cu-remove <context.location.cuboids.filter[starts_with[heavens-portal]]>
            - note remove as:<def[cu-remove]>
        }
        on player breaks quartz_block:
        - if <context.location.cuboids.contains_text[heavens-portal]>
        {
            - define cu-remove <context.location.cuboids.filter[starts_with[heavens-portal]]>
            - note remove as:<def[cu-remove]>
        }
        on player uses portal in prosperus:
        - if <context.from.cuboids.contains_text[heavens-portal]>
        {
#            - define final-location <context.from.replace[prosperus].with[heavens]>
#            - define final-location <def[final-location].x.div[2]>
#            - define final-location <def[final-location].z.div[2]>
#            - determine <def[final-location]>
#            - determine l@<context.from.x.div[2]>,<context.from.y>,<context.from.z.div[2]>,heavens
            - teleport <player> l@<context.from.x.div[2]>,<context.from.y>,<context.from.z.div[2]>,heavens
            - determine cancelled
        }
        on portal created:
        - announce to_console "Portal created for ON PORTAL CREATED, blocks are <context.blocks>"
        on entity creates portal:
        - announce to_console "Portal created for ON ENTITY CREATES PORTAL, type is <context.portal_type>"