1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Check for specific block layout help

Discussion in 'Skript' started by Gerlif, Oct 31, 2018.

Thread Status:
Not open for further replies.
  1. Gerlif

    Gerlif New Member

    Joined:
    Apr 23, 2017
    Messages:
    8
    Likes Received:
    0
    Hey, so what I want to do is basically check if a certain build is present when right-clicking it.

    The build is pretty simple, from above would look like:

    -xxx-
    x---x
    x---x
    x---x
    -xxx-

    Where X = Obsidian

    So, what I need help with is how to detect this "frame" of obsidian in a Skript?
    I want players to be able to right-click any block of the frame, and then it triggers an event.
     
  2. Andalmere

    Andalmere Active Member

    Joined:
    Jan 28, 2017
    Messages:
    63
    Likes Received:
    11
    What is the value of -? Any blocks including air?
     
  3. Gerlif

    Gerlif New Member

    Joined:
    Apr 23, 2017
    Messages:
    8
    Likes Received:
    0
    Yep!
     
  4. Andalmere

    Andalmere Active Member

    Joined:
    Jan 28, 2017
    Messages:
    63
    Likes Received:
    11
    I don't know what you really want but I assumed that your portal's orientation is vertical and the blocks inside that obsidian portal are all air. Anyways I'll provide a code, please keep in mind that you should test this first because I am just imagining here the code structure and there may be some typo.
    Code (Skript):
    1. on right click on obsidian:
    2.     # SIDE CHECKING
    3.     # In this root condition, we are checking if the side of the clicked block
    4.     # is at the center. Variable {_n}, {_s}, {_w}, {_e} represents the direction of the portal
    5.     # which is equivalent to north, south, east and west. And these variable's
    6.     # are located in the center of the assumed portal.
    7.     if block 1 meter above event-block is obsidian:
    8.         if block 1 meter below event-block is obsidian:
    9.             set {_n} to blocks 2 meters north of event-block
    10.             set {_s} to blocks 2 meters south of event-block
    11.             set {_w} to blocks 2 meters west of event-block
    12.             set {_e} to blocks 2 meters east of event-block
    13.             # In this condition, we checked first the north side of the clicked obsidian to
    14.             # assess if there is an existing portal.
    15.             if block 2 meters above {_n} is obsidian:
    16.                 set {_n2} to block 2 meters above {_n}
    17.                 if block 1 meter north of {_n2} is obsidian:
    18.                     if block 1 meter south of {_n2} is obsidian:
    19.                         # If the condition has passed these conditions above. Then we can
    20.                         # conclude that there are 3 obsidians above the assumed portal on
    21.                         # the north side. Same thing goes below for the other sides of the
    22.                         # portal.
    23.                         if block 2 meters below {_n} is obsidian:
    24.                             set {_n2} to block 2 meters below {_n}
    25.                             if block 1 meter north of {_n2} is obsidian:
    26.                                 if block 1 meter south of {_n2} is obsidian:
    27.                                     if block 2 meters north of {_n} is obsidian:
    28.                                         set {_n2} to block 2 meters north of {_n}
    29.                                         if block 1 meter above {_n2} is obsidian:
    30.                                             if block 1 meter below {_n2} is obsidian:
    31.                                                 # And lastly, if the checking reached at this bottom part
    32.                                                 # of the checks, we can conclude that there is a REAL
    33.                                                 # portal. Insert some code here that you want to execute.
    34.                                                 add 1 to {_portals}
    35.             # The process here is repeated from above and the only changes are the directions.
    36.             if block 2 meters above {_s} is obsidian:
    37.                 set {_s2} to block 2 meters above {_s}
    38.                 if block 1 meter north of {_s2} is obsidian:
    39.                     if block 1 meter south of {_s2} is obsidian:
    40.                         if block 2 meters below {_s} is obsidian:
    41.                             set {_s2} to block 2 meters below {_s}
    42.                             if block 1 meter north of {_s2} is obsidian:
    43.                                 if block 1 meter south of {_s2} is obsidian:
    44.                                     if block 2 meters south of {_s} is obsidian:
    45.                                         set {_s2} to block 2 meters south of {_n}
    46.                                         if block 1 meter above {_s2} is obsidian:
    47.                                             if block 1 meter below {_s2} is obsidian:
    48.                                                 # Insert some codes here.
    49.                                                 add 1 to {_portals}
    50.             if block 2 meters above {_e} is obsidian:
    51.                 set {_e2} to block 2 meters above {_e}
    52.                 if block 1 meter east of {_e2} is obsidian:
    53.                     if block 1 meter west of {_e2} is obsidian:
    54.                         if block 2 meters below {_e} is obsidian:
    55.                             set {_e2} to block 2 meters below {_e}
    56.                             if block 1 meter east of {_e2} is obsidian:
    57.                                 if block 1 meter west of {_e2} is obsidian:
    58.                                     if block 2 meters east of {_e} is obsidian:
    59.                                         set {_e2} to block 2 meters east of {_e}
    60.                                         if block 1 meter above {_e2} is obsidian:
    61.                                             if block 1 meter below {_e2} is obsidian:
    62.                                                 # Insert some codes here.
    63.                                                 add 1 to {_portals}
    64.             if block 2 meters above {_w} is obsidian:
    65.                 set {_w2} to block 2 meters above {_w}
    66.                 if block 1 meter east of {_w2} is obsidian:
    67.                     if block 1 meter west of {_w2} is obsidian:
    68.                         if block 2 meters below {_w} is obsidian:
    69.                             set {_w2} to block 2 meters below {_e}
    70.                             if block 1 meter east of {_w2} is obsidian:
    71.                                 if block 1 meter west of {_w2} is obsidian:
    72.                                     if block 2 meters west of {_w} is obsidian:
    73.                                         set {_w2} to block 2 meters west of {_w}
    74.                                         if block 1 meter above {_w2} is obsidian:
    75.                                             if block 1 meter below {_w2} is obsidian:
    76.                                                 # Insert some codes here.
    77.                                                 add 1 to {_portals}
    78.     # Here the clicked block is located on the top portion of the portal side.
    79.     if block 1 meter below event-block is obsidian:                                  
    80.         if block 2 meters below event-block is obsidian:
    81.             set {_block} to block 1 meter below event-block
    82.             set {_n} to blocks 2 meters north of {_block}
    83.             set {_s} to blocks 2 meters south of {_block}
    84.             set {_w} to blocks 2 meters west of {_block}
    85.             set {_e} to blocks 2 meters east of {_block}
    86.             if block 2 meters above {_n} is obsidian:
    87.                 set {_n2} to block 2 meters above {_n}
    88.                 if block 1 meter north of {_n2} is obsidian:
    89.                     if block 1 meter south of {_n2} is obsidian:
    90.                         if block 2 meters below {_n} is obsidian:
    91.                             set {_n2} to block 2 meters below {_n}
    92.                             if block 1 meter north of {_n2} is obsidian:
    93.                                 if block 1 meter south of {_n2} is obsidian:
    94.                                     if block 2 meters north of {_n} is obsidian:
    95.                                         set {_n2} to block 2 meters north of {_n}
    96.                                         if block 1 meter above {_n2} is obsidian:
    97.                                             if block 1 meter below {_n2} is obsidian:
    98.                                                 # Insert some codes here.
    99.                                                 add 1 to {_portals}
    100.             if block 2 meters above {_s} is obsidian:
    101.                 set {_s2} to block 2 meters above {_s}
    102.                 if block 1 meter north of {_s2} is obsidian:
    103.                     if block 1 meter south of {_s2} is obsidian:
    104.                         if block 2 meters below {_s} is obsidian:
    105.                             set {_s2} to block 2 meters below {_s}
    106.                             if block 1 meter north of {_s2} is obsidian:
    107.                                 if block 1 meter south of {_s2} is obsidian:
    108.                                     if block 2 meters south of {_s} is obsidian:
    109.                                         set {_s2} to block 2 meters south of {_n}
    110.                                         if block 1 meter above {_s2} is obsidian:
    111.                                             if block 1 meter below {_s2} is obsidian:
    112.                                                 # Insert some codes here.
    113.                                                 add 1 to {_portals}
    114.             if block 2 meters above {_e} is obsidian:
    115.                 set {_e2} to block 2 meters above {_e}
    116.                 if block 1 meter east of {_e2} is obsidian:
    117.                     if block 1 meter west of {_e2} is obsidian:
    118.                         if block 2 meters below {_e} is obsidian:
    119.                             set {_e2} to block 2 meters below {_e}
    120.                             if block 1 meter east of {_e2} is obsidian:
    121.                                 if block 1 meter west of {_e2} is obsidian:
    122.                                     if block 2 meters east of {_e} is obsidian:
    123.                                         set {_e2} to block 2 meters east of {_e}
    124.                                         if block 1 meter above {_e2} is obsidian:
    125.                                             if block 1 meter below {_e2} is obsidian:
    126.                                                 # Insert some codes here.
    127.                                                 add 1 to {_portals}
    128.             if block 2 meters above {_w} is obsidian:
    129.                 set {_w2} to block 2 meters above {_w}
    130.                 if block 1 meter east of {_w2} is obsidian:
    131.                     if block 1 meter west of {_w2} is obsidian:
    132.                         if block 2 meters below {_w} is obsidian:
    133.                             set {_w2} to block 2 meters below {_e}
    134.                             if block 1 meter east of {_w2} is obsidian:
    135.                                 if block 1 meter west of {_w2} is obsidian:
    136.                                     if block 2 meters west of {_w} is obsidian:
    137.                                         set {_w2} to block 2 meters west of {_w}
    138.                                         if block 1 meter above {_w2} is obsidian:
    139.                                             if block 1 meter below {_w2} is obsidian:
    140.                                                 # Insert some codes here.
    141.                                                 add 1 to {_portals}
    142.     # Here the clicked block is located on the bottom portion of the portal side.
    143.     if block 1 meter above event-block is obsidian:                                  
    144.         if block 2 meters above event-block is obsidian:
    145.             set {_block} to block 1 meter above event-block
    146.             set {_n} to blocks 2 meters north of {_block}
    147.             set {_s} to blocks 2 meters south of {_block}
    148.             set {_w} to blocks 2 meters west of {_block}
    149.             set {_e} to blocks 2 meters east of {_block}
    150.             if block 2 meters above {_n} is obsidian:
    151.                 set {_n2} to block 2 meters above {_n}
    152.                 if block 1 meter north of {_n2} is obsidian:
    153.                     if block 1 meter south of {_n2} is obsidian:
    154.                         if block 2 meters below {_n} is obsidian:
    155.                             set {_n2} to block 2 meters below {_n}
    156.                             if block 1 meter north of {_n2} is obsidian:
    157.                                 if block 1 meter south of {_n2} is obsidian:
    158.                                     if block 2 meters north of {_n} is obsidian:
    159.                                         set {_n2} to block 2 meters north of {_n}
    160.                                         if block 1 meter above {_n2} is obsidian:
    161.                                             if block 1 meter below {_n2} is obsidian:
    162.                                                 # Insert some codes here.
    163.                                                 add 1 to {_portals}
    164.             if block 2 meters above {_s} is obsidian:
    165.                 set {_s2} to block 2 meters above {_s}
    166.                 if block 1 meter north of {_s2} is obsidian:
    167.                     if block 1 meter south of {_s2} is obsidian:
    168.                         if block 2 meters below {_s} is obsidian:
    169.                             set {_s2} to block 2 meters below {_s}
    170.                             if block 1 meter north of {_s2} is obsidian:
    171.                                 if block 1 meter south of {_s2} is obsidian:
    172.                                     if block 2 meters south of {_s} is obsidian:
    173.                                         set {_s2} to block 2 meters south of {_n}
    174.                                         if block 1 meter above {_s2} is obsidian:
    175.                                             if block 1 meter below {_s2} is obsidian:
    176.                                                 # Insert some codes here.
    177.                                                 add 1 to {_portals}
    178.             if block 2 meters above {_e} is obsidian:
    179.                 set {_e2} to block 2 meters above {_e}
    180.                 if block 1 meter east of {_e2} is obsidian:
    181.                     if block 1 meter west of {_e2} is obsidian:
    182.                         if block 2 meters below {_e} is obsidian:
    183.                             set {_e2} to block 2 meters below {_e}
    184.                             if block 1 meter east of {_e2} is obsidian:
    185.                                 if block 1 meter west of {_e2} is obsidian:
    186.                                     if block 2 meters east of {_e} is obsidian:
    187.                                         set {_e2} to block 2 meters east of {_e}
    188.                                         if block 1 meter above {_e2} is obsidian:
    189.                                             if block 1 meter below {_e2} is obsidian:
    190.                                                 # Insert some codes here.
    191.                                                 add 1 to {_portals}
    192.             if block 2 meters above {_w} is obsidian:
    193.                 set {_w2} to block 2 meters above {_w}
    194.                 if block 1 meter east of {_w2} is obsidian:
    195.                     if block 1 meter west of {_w2} is obsidian:
    196.                         if block 2 meters below {_w} is obsidian:
    197.                             set {_w2} to block 2 meters below {_e}
    198.                             if block 1 meter east of {_w2} is obsidian:
    199.                                 if block 1 meter west of {_w2} is obsidian:
    200.                                     if block 2 meters west of {_w} is obsidian:
    201.                                         set {_w2} to block 2 meters west of {_w}
    202.                                         if block 1 meter above {_w2} is obsidian:
    203.                                             if block 1 meter below {_w2} is obsidian:
    204.                                                 # Insert some codes here.
    205.                                                 add 1 to {_portals}
    206.     # TOP/BOTTOM CHECKING
    207.     # In this case, the clicked block is located at the bottom/top portion side of
    208.     # the assumed portal. The process here is almost the same except for the orientations.
    209.     # I don't think that I'll explain it again here because the code itself is self-
    210.     # explanatory.
    211.     if block 1 meter north of event-block is obsidian:
    212.         if block 1 meter south of event-block is obsidian:
    213.             set {_center} to blocks 2 meters below event-block
    214.             set {_s} to blocks 4 meters below event-block
    215.             set {_1} to blocks 2 meters south of {_center}
    216.             set {_2} to blocks 2 meters north of {_center}
    217.             if block 1 meter north of {_s} is obsidian:
    218.                 if block 1 meter south of {_s} is obsidian:
    219.                     if block 1 meter above {_1} is obsidian:
    220.                         if block 1 meter above {_1} is obsidian:
    221.                             if block 1 meter above {_2} is obsidian:
    222.                                 if block 1 meter above {_2} is obsidian:
    223.                                     # Insert some codes here.
    224.                                     add 1 to {_portals}
    225.     if block 1 meter east of event-block is obsidian:
    226.         if block 1 meter west of event-block is obsidian:
    227.             set {_center} to blocks 2 meters below event-block
    228.             set {_s} to blocks 4 meters below event-block
    229.             set {_1} to blocks 2 meters west of {_center}
    230.             set {_2} to blocks 2 meters east of {_center}
    231.             if block 1 meter east of {_s} is obsidian:
    232.                 if block 1 meter west of {_s} is obsidian:
    233.                     if block 1 meter above {_1} is obsidian:
    234.                         if block 1 meter above {_1} is obsidian:
    235.                             if block 1 meter above {_2} is obsidian:
    236.                                 if block 1 meter above {_2} is obsidian:
    237.                                     # Insert some codes here.
    238.                                     add 1 to {_portals}
    239.     if block 1 meter north of event-block is obsidian:
    240.         if block 2 meters north of event-block is obsidian:
    241.             set {_block} to block 1 meter north of event-block
    242.             set {_center} to blocks 2 meters below {_block}
    243.             set {_s} to blocks 4 meters below event-block
    244.             set {_1} to blocks 2 meters west of {_center}
    245.             set {_2} to blocks 2 meters east of {_center}
    246.             if block 1 meter east of {_s} is obsidian:
    247.                 if block 1 meter west of {_s} is obsidian:
    248.                     if block 1 meter above {_1} is obsidian:
    249.                         if block 1 meter above {_1} is obsidian:
    250.                             if block 1 meter above {_2} is obsidian:
    251.                                 if block 1 meter above {_2} is obsidian:
    252.                                     # Insert some codes here.
    253.                                     add 1 to {_portals}
    254.     if block 1 meter south of event-block is obsidian:
    255.         if block 2 meters south of event-block is obsidian:
    256.             set {_block} to block 1 meter south of event-block
    257.             set {_center} to blocks 2 meters below {_block}
    258.             set {_s} to blocks 4 meters below event-block
    259.             set {_1} to blocks 2 meters west of {_center}
    260.             set {_2} to blocks 2 meters east of {_center}
    261.             if block 1 meter east of {_s} is obsidian:
    262.                 if block 1 meter west of {_s} is obsidian:
    263.                     if block 1 meter above {_1} is obsidian:
    264.                         if block 1 meter above {_1} is obsidian:
    265.                             if block 1 meter above {_2} is obsidian:
    266.                                 if block 1 meter above {_2} is obsidian:
    267.                                     # Insert some codes here.
    268.                                     add 1 to {_portals}
    269.     if block 1 meter west of event-block is obsidian:
    270.         if block 2 meters west of event-block is obsidian:
    271.             set {_block} to block 1 meter west of event-block
    272.             set {_center} to blocks 2 meters below {_block}
    273.             set {_s} to blocks 4 meters below event-block
    274.             set {_1} to blocks 2 meters west of {_center}
    275.             set {_2} to blocks 2 meters east of {_center}
    276.             if block 1 meter east of {_s} is obsidian:
    277.                 if block 1 meter west of {_s} is obsidian:
    278.                     if block 1 meter above {_1} is obsidian:
    279.                         if block 1 meter above {_1} is obsidian:
    280.                             if block 1 meter above {_2} is obsidian:
    281.                                 if block 1 meter above {_2} is obsidian:
    282.                                     # Insert some codes here.
    283.                                     add 1 to {_portals}
    284.     if block 1 meter east of event-block is obsidian:
    285.         if block 2 meters east of event-block is obsidian:
    286.             set {_block} to block 1 meter east of event-block
    287.             set {_center} to blocks 2 meters below {_block}
    288.             set {_s} to blocks 4 meters below event-block
    289.             set {_1} to blocks 2 meters west of {_center}
    290.             set {_2} to blocks 2 meters east of {_center}
    291.             if block 1 meter east of {_s} is obsidian:
    292.                 if block 1 meter west of {_s} is obsidian:
    293.                     if block 1 meter above {_1} is obsidian:
    294.                         if block 1 meter above {_1} is obsidian:
    295.                             if block 1 meter above {_2} is obsidian:
    296.                                 if block 1 meter above {_2} is obsidian:
    297.                                     # Insert some codes here.
    298.                                     add 1 to {_portals}
    299.     #                      
    300.    
    301.     if block 1 meter north of event-block is obsidian:
    302.         if block 1 meter south of event-block is obsidian:
    303.             set {_center} to blocks 2 meters above event-block
    304.             set {_n} to blocks 4 meters above event-block
    305.             set {_1} to blocks 2 meters south of {_center}
    306.             set {_2} to blocks 2 meters north of {_center}
    307.             if block 1 meter north of {_n} is obsidian:
    308.                 if block 1 meter south of {_n} is obsidian:
    309.                     if block 1 meter above {_1} is obsidian:
    310.                         if block 1 meter above {_1} is obsidian:
    311.                             if block 1 meter above {_2} is obsidian:
    312.                                 if block 1 meter above {_2} is obsidian:
    313.                                     # Insert some codes here.
    314.                                     add 1 to {_portals}
    315.     if block 1 meter east of event-block is obsidian:
    316.         if block 1 meter west of event-block is obsidian:
    317.             set {_center} to blocks 2 meters above event-block
    318.             set {_n} to blocks 4 meters above event-block
    319.             set {_1} to blocks 2 meters west of {_center}
    320.             set {_2} to blocks 2 meters east of {_center}
    321.             if block 1 meter east of {_n} is obsidian:
    322.                 if block 1 meter west of {_n} is obsidian:
    323.                     if block 1 meter above {_1} is obsidian:
    324.                         if block 1 meter above {_1} is obsidian:
    325.                             if block 1 meter above {_2} is obsidian:
    326.                                 if block 1 meter above {_2} is obsidian:
    327.                                     # Insert some codes here.
    328.                                     add 1 to {_portals}
    329.     if block 1 meter north of event-block is obsidian:
    330.         if block 2 meters north of event-block is obsidian:
    331.             set {_block} to block 1 meter north of event-block
    332.             set {_center} to blocks 2 meters above {_block}
    333.             set {_n} to blocks 4 meters above event-block
    334.             set {_1} to blocks 2 meters west of {_center}
    335.             set {_2} to blocks 2 meters east of {_center}
    336.             if block 1 meter east of {_n} is obsidian:
    337.                 if block 1 meter west of {_n} is obsidian:
    338.                     if block 1 meter above {_1} is obsidian:
    339.                         if block 1 meter above {_1} is obsidian:
    340.                             if block 1 meter above {_2} is obsidian:
    341.                                 if block 1 meter above {_2} is obsidian:
    342.                                     # Insert some codes here.
    343.                                     add 1 to {_portals}
    344.     if block 1 meter south of event-block is obsidian:
    345.         if block 2 meters south of event-block is obsidian:
    346.             set {_block} to block 1 meter south of event-block
    347.             set {_center} to blocks 2 meters above {_block}
    348.             set {_n} to blocks 4 meters above event-block
    349.             set {_1} to blocks 2 meters west of {_center}
    350.             set {_2} to blocks 2 meters east of {_center}
    351.             if block 1 meter east of {_n} is obsidian:
    352.                 if block 1 meter west of {_n} is obsidian:
    353.                     if block 1 meter above {_1} is obsidian:
    354.                         if block 1 meter above {_1} is obsidian:
    355.                             if block 1 meter above {_2} is obsidian:
    356.                                 if block 1 meter above {_2} is obsidian:
    357.                                     # Insert some codes here.
    358.                                     add 1 to {_portals}
    359.     if block 1 meter west of event-block is obsidian:
    360.         if block 2 meters west of event-block is obsidian:
    361.             set {_block} to block 1 meter west of event-block
    362.             set {_center} to blocks 2 meters above {_block}
    363.             set {_n} to blocks 4 meters above event-block
    364.             set {_1} to blocks 2 meters west of {_center}
    365.             set {_2} to blocks 2 meters east of {_center}
    366.             if block 1 meter east of {_n} is obsidian:
    367.                 if block 1 meter west of {_n} is obsidian:
    368.                     if block 1 meter above {_1} is obsidian:
    369.                         if block 1 meter above {_1} is obsidian:
    370.                             if block 1 meter above {_2} is obsidian:
    371.                                 if block 1 meter above {_2} is obsidian:
    372.                                     # Insert some codes here.
    373.                                     add 1 to {_portals}
    374.     if block 1 meter east of event-block is obsidian:
    375.         if block 2 meters east of event-block is obsidian:
    376.             set {_block} to block 1 meter east of event-block
    377.             set {_center} to blocks 2 meters above {_block}
    378.             set {_n} to blocks 4 meters above event-block
    379.             set {_1} to blocks 2 meters west of {_center}
    380.             set {_2} to blocks 2 meters east of {_center}
    381.             if block 1 meter east of {_n} is obsidian:
    382.                 if block 1 meter west of {_n} is obsidian:
    383.                     if block 1 meter above {_1} is obsidian:
    384.                         if block 1 meter above {_1} is obsidian:
    385.                             if block 1 meter above {_2} is obsidian:
    386.                                 if block 1 meter above {_2} is obsidian:
    387.                                     # Insert some codes here.
    388.                                     add 1 to {_portals}      
    389.     send "There are %{_portals}% detected. :)"
    This code can be optimized and may require addons.
     
  5. Gerlif

    Gerlif New Member

    Joined:
    Apr 23, 2017
    Messages:
    8
    Likes Received:
    0
    Thanks a lot for the help, this is sorta the way I was thinking of it being done as well.
    I'm just wondering if there isn't a more effective solution, hmmm... maybe not :emoji_slight_smile:

     
  6. Andalmere

    Andalmere Active Member

    Joined:
    Jan 28, 2017
    Messages:
    63
    Likes Received:
    11
    Just reply back here if something isn't working and I'll try to provide a fix asap.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...