Paste #48141: Untitled Paste

Date: 2018/06/28 17:06:15 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"Heavens Portal 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 xaxis-pos 1,0,0
            - define xaxis-neg -1,0,0
            - define axis 1
        }
        elseif <context.location.add[1,0,0].material> == m@quartz_block && <context.location.add[-1,0,0].material> == m@quartz_block
        {
            - define xaxis-pos 0,0,1
            - define xaxis-neg 0,0,-1
            - define axis 2
        }
        else
        {
            - queue clear
        }
        - define origin <context.location.add[0,1,0]>
        - define node <def[origin]>
        - define air-list li@
        - define y-list li@
        - 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 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]>]>
                    - define node <def[node].add[<def[xaxis-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]>]>
                    - define node <def[node].add[<def[xaxis-neg]>]>
                }
                - if <def[node].material> !== m@quartz_block
                {
                    - queue clear
                }
            }
        }
        - modifyblock <def[air-list]> m@portal,<def[axis]> no_physics
        - note cu@<def[air-list]> 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 <def[cu-remove]>
        }
        on player breaks quartz_block:
        - if <context.location.find.blocks[portal].within[2].cuboids.filter[starts_with[heavens-portal]]>
        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>"