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!

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

[#4] Skript Challenge - Loop area

Discussion in 'Skript Challenge' started by BaeFell, Apr 1, 2018.

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

    BaeFell I'm Poppy
    Admin

    Joined:
    Nov 27, 2016
    Messages:
    342
    Likes Received:
    202
    Hi everyone,

    Welcome to another Skript Challenge!

    Based on the #3 Skript Challenge - Area Fill, in this Skript Challenge you must loop between 2 dynamically set points (which you must also provide the code for setting the points)

    Another mathematically thinking Skript Challenge in which you must be aware of how to loop an area but do it efficiently and easily while maintaining code readability.

    The rules are as follows (note: rules may change between challenge):
    - Your code must be in
    Code (Text):
    1. <code>
    tags so that I can easily read it.
    - You can use addons, but, you're not allowed to use a feature from an addon which does this and the addon must of been released publicly prior to the creation of this thread (eg. skQuery's loop between...)
    - You can use another user's code, but please don't edit your messages. I can see all message history and posts that do have edit history like this will not be counted
    Remember: this one is about quality, not just length. So trying to cut variable names from someone elses code will lose points! I want readability and functionality over length
    - Web API's or using an external source (outside of Skript), to get your result in not allowed. All submissions must actually do the conversions themselves.
    - You must list all addons used. I will be testing on Spigot 1.11.2.

    I might add a rule after a submission has been made, it's up to me whether or not that submission is valid. I can deny any submission for any reason.

    Challenge details (specifics about this challenge):
    - The default area will be a rectangle or square. More points if you can easily let me have weird shaped areas.
    - You must provide a way for me to set the points to loop between. More points for making this easy to use and functional
    - There must be a command or something to loop between the 2 points. I'd like to know how many blocks and what type of blocks there are in the area... more information = more points.


    Tips:
    - Be efficient and smart about your code. I like to be able to read the code and make sense of it. Comments and good variable naming is a plus.
    - Try not to crash my server

    How answers will be judged:
    Unlike others, the winner for this one, will be judged based on quality. I and others (who I'm yet to pick), will go around and find the best answers. I'm not sure on the specifics of how the scoring will work, the final judgement and most other things, but I've got a week to figure that out!

    Important
    If you don't understand how your answer will be judged here is an explanation:
    Better code quality = more points. I'm very anti-addon with some things. If you're using an addon for what can be done normally in Skript, then you're not Skripting right. Variable names, code structure, use of functions and code readability matters for this challenge. I'm specifically looking for the best code, not the smallest, but you shouldn't have code that is far too long, otherwise it's unlikely to be efficient.

    The closing date is 7 days from now -> 7th of April - have fun!
    (I might be too busy to post winners on the 8th of April, but any entries after the 7th of April at 11:59PM GMT will not be counted)
     
    • Like Like x 3
  2. Donut

    Addon Developer

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    174
    Medals:
    no addons and tested on dev32. the looping takes some time if the area selection is big so please be patient!
    Code (Skript):
    1. #Set point 1 command
    2. command /setpoint1:  
    3.     trigger:
    4.         set {point1} to player's location
    5.         send "&aPoint 1 has been set to your location."
    6.  
    7. #Set point 2 command
    8. command /setpoint2:  
    9.     trigger:
    10.         set {point2} to player's location
    11.         send "&aPoint 2 has been set to your location."
    12.  
    13. #Main command
    14. command /loopblocks:
    15.     trigger:
    16.         #Make sure everything is good to go before looping
    17.         if {point1} is not set:
    18.             send "&cPoint 1 has not been set."
    19.         else if {point2} is not set:
    20.             send "&cPoint 2 has not been set."
    21.         else if {point1}'s world is not {point2}'s world:
    22.             send "&cBoth points must be in the same world."
    23.         else:
    24.             send "&aLooping blocks... this will take a few moments, please be patient."
    25.  
    26.             #Get min/max coords
    27.             if x-coord of {point1} is greater than x-coord of {point2}:
    28.                 set {_minX} to x-coord of {point2}
    29.                 set {_maxX} to x-coord of {point1}
    30.             else:
    31.                 set {_minX} to x-coord of {point1}
    32.                 set {_maxX} to x-coord of {point2}
    33.             if y-coord of {point1} is greater than y-coord of {point2}:
    34.                 set {_minY} to y-coord of {point2}
    35.                 set {_maxY} to y-coord of {point1}
    36.             else:
    37.                 set {_minY} to y-coord of {point1}
    38.                 set {_maxY} to y-coord of {point2}
    39.             if z-coord of {point1} is greater than z-coord of {point2}:
    40.                 set {_minZ} to z-coord of {point2}
    41.                 set {_maxZ} to z-coord of {point1}
    42.             else:
    43.                 set {_minZ} to z-coord of {point1}
    44.                 set {_maxZ} to z-coord of {point2}
    45.  
    46.             #Loop the blocks
    47.             set {_looping} to true
    48.             set {_loopX} to {_minX}
    49.             set {_loopY} to {_minY}
    50.             set {_loopZ} to {_minZ}
    51.             while {_looping} is true:
    52.                 add block at location at {_loopX}, {_loopY}, {_loopZ} to {_blocks::*}
    53.                 add 1 to {_loopX}
    54.                 if {_loopX} is greater than {_maxX}:
    55.                     set {_loopX} to {_minX}
    56.                     add 1 to {_loopY}
    57.                     if {_loopY} is greater than {_maxY}:
    58.                         set {_loopY} to {_minY}
    59.                         add 1 to {_loopZ}
    60.                         if {_loopZ} is greater than {_maxZ}:
    61.                             set {_looping} to false
    62.                 wait 1 tick
    63.  
    64.             #Get a string containing all the block counts
    65.             loop {_blocks::*}:
    66.                 set {_blockType} to "%loop-value%"
    67.                 add 1 to {_blockCount::%{_blockType}%}
    68.             set {_allBlockCounts} to ""
    69.             loop {_blockCount::*}:
    70.                 set {_allBlockCounts} to "%{_allBlockCounts}%%{_blockCount::%loop-index%}% %loop-index% | "
    71.             set {_allBlockCounts} to the first (length of {_allBlockCounts} - 2) characters of {_allBlockCounts}
    72.  
    73.             #Send results
    74.             send "&aFinished!"
    75.             send "&6Total number of blocks: &e%size of {_blocks::*}%"
    76.             send "&6Block makeup: &e%{_allBlockCounts}%"
     
    • Like Like x 1
    • Winner Winner x 1
  3. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    514
    Likes Received:
    26
    Medals:
    Code (Skript):
    1. command /setpoint <number>:
    2.     trigger:
    3.         if arg-1 is not 1 or 2:
    4.             message "You can only set point 1 and 2"
    5.             stop
    6.         set {point-%arg-1%} to location(floor(x coord of player), floor(y coord of player), floor(z coord of player), world of player)
    7.         message "Point %arg-1% set!"
    8.  
    9. command /lb2:
    10.     trigger:
    11.         if {point-1} is not set:
    12.             message "Set point 1 using '/setpoint 1' first!"
    13.             stop
    14.         if {point-2} is not set:
    15.             message "Set point 2 using '/setpoint 2' first!"
    16.             stop
    17.         if the world of {point-1} is not the world of {point-2}:
    18.             message "You need to have both points in the same world"
    19.             stop
    20.         message "&cWarning: when using large areas, lag will occur!"
    21.         set {_min-x} to x coord of {point-1}
    22.         set {_min-y} to y coord of {point-1}
    23.         set {_min-z} to z coord of {point-1}
    24.         if {_min-x} > x coord of {point-2}:
    25.             set {_min-x} to x coord of {point-2}
    26.         if {_min-y} > y coord of {point-2}:
    27.             set {_min-y} to y coord of {point-2}
    28.         if {_min-z} > z coord of {point-2}:
    29.             set {_min-z} to z coord of {point-2}
    30.         set {_dif-x} to (difference between x coord of {point-1} and x coord of {point-2}) + 1
    31.         set {_dif-y} to (difference between y coord of {point-1} and y coord of {point-2}) + 1
    32.         set {_dif-z} to (difference between z coord of {point-1} and z coord of {point-2}) + 1
    33.         message "Expected time (only works with small areas): &2%{_dif-x} * {_dif-y} / 20% seconds"
    34.         set {_now} to now
    35.         message "Calculation started"
    36.         loop {_dif-x} times:
    37.             loop {_dif-y} times:
    38.                 loop {_dif-z} times:
    39.                     set {_x} to loop-number-1 + {_min-x} - 1
    40.                     set {_y} to loop-number-2 + {_min-y} - 1
    41.                     set {_z} to loop-number-3 + {_min-z} - 1
    42.                     add location({_x}, {_y}, {_z}, world of {point-1}) to {_locs::*}
    43.                 wait 1 tick
    44.         loop {_locs::*}:
    45.             delete {_b}
    46.             set {_b} to "%block at loop-value%"
    47.             if {_blocks::*} is not set:
    48.                 add {_b} to {_blocks::*}
    49.             if {_blocks::*} does not contain {_b}:
    50.                 add {_b} to {_blocks::*}
    51.             add 1 to {_blocks::%{_b}%::amount}
    52.         message "Done!"
    53.         message "Different types of blocks: "
    54.         loop {_blocks::*}:
    55.             message " - &2%{_blocks::%loop-value%::amount}% &rof &2%loop-value% &rbetween the points"
    56.         message "Total blocks between the points: &2%amount of {_locs::*}%"
    57.         message "Calculated area: &2%{_dif-x}% * %{_dif-y}% * %{_dif-z}% = %{_dif-x} * {_dif-y} * {_dif-z}%"
    58.         message "Took &2%difference between now and {_now}%"
    No addons required, tested on 2.2-dev34.
    The biggest area I tried was 31020 blocks, and it took 10 minutes and 25 seconds and got the TPS down to 12.5, so be patient and expect some lag.

    EDIT: I made some changes because I just noticed that the difference expression works a little bit differently than I expected and that Minecraft rounds its coordinates down.
     
    #3 TPGamesNL, Apr 2, 2018
    Last edited: Apr 5, 2018
  4. EWS

    EWS Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    47
    Likes Received:
    15
    Medals:
    I can't say that my code is very readable, but it's reasonably performant.
    1. No lists, so it saves plenty of RAM.
    2. Loops only once (gets all blocks and set them all inside itself).
    3. The block is only set if it's a different one (not blue wool). Greatly increases performance if you want to make small adjustments.
    4. No add %blocks% to {variable::*}, which also increases performance.
    5. No addons, needs an a bit updated version of Bensku's Skript because of unix timestamp (I hate Skript's date/timespan, don't judge me).

    [Old code, challenge isn't exactly about this lol]

    Code (Skript):
    1.  
    2. on leftclick holding gold axe:
    3.    event-block is set
    4.    cancel event
    5.    set {pos1} to location of event-block
    6.    send "Pos1 is now set."
    7.  
    8. on rightclick holding gold axe:
    9.    event-block is set
    10.    cancel event
    11.    set {pos2} to location of event-block
    12.    send "Pos2 is now set."
    13.  
    14. command /rectangle [<text>]:
    15.    trigger:
    16.  
    17.        set {_u} to unix timestamp of now
    18.  
    19.        # Getting positions (useless part)
    20.        set {_1} to {pos1}
    21.        set {_2} to {pos2}
    22.  
    23.        # Just saving 3 lines (elses)
    24.        set {_x} to 1
    25.        set {_y} to 1
    26.        set {_z} to 1
    27.  
    28.        # Determines the direction to be used (it always goes from 1 to 2)
    29.        if x coord of {_1} > x coord of {_2}:
    30.            set {_x} to -1
    31.        if y coord of {_1} > y coord of {_2}:
    32.            set {_y} to -1
    33.        if z coord of {_1} > z coord of {_2}:
    34.            set {_z} to -1
    35.  
    36.        # As {_1} is the only one that is changed, I save it.
    37.        # {_2} is used for base.
    38.        set {_base1} to {_1}
    39.  
    40.        # Getting the blocks.
    41.        # I'm not a big fan of whiles, so I just get the difference.
    42.        loop abs(x coord of {_1} - x coord of {_2}) + 1 times:
    43.            loop abs(z coord of {_1} - z coord of {_2}) + 1 times:
    44.                loop abs(y coord of {_1} - y coord of {_2}) + 1 times:
    45.  
    46.                    # This greatly increases performance if the blocks are already set.
    47.                    if block at {_1} != blue wool:
    48.                        # set block at {_1} to blue wool
    49.  
    50.                    add 1 to {_total}
    51.                    add {_y} to y coord of {_1}
    52.      
    53.                # Goes to the next Z and resets Y...
    54.                add {_z} to z coord of {_1}
    55.                set y coord of {_1} to y coord of {_base1}
    56.  
    57.            # Goes to the next X and resets Z...
    58.            add {_x} to x coord of {_1}
    59.            set z coord of {_1} to z coord of {_base1}
    60.  
    61.            # Optional waiting.
    62.            # wait 1 tick
    63.  
    64.        set {_time} to (unix timestamp of now - {_u}) * 1000
    65.        send " "
    66.        send "&3&lCUBOID STATS"
    67.        send "Blocks changed: &a%{_total}%"
    68.        send "Cuboid took &a%{_time}%ms&f!"
    69.        send " "
    70.        send "Overall speed: &a%{_total} * 1000 / {_time}% blocks/s"
    71.        send " "
    72.  

    In my tests, it scores about ~120,000 blocks/s without 1 tick delay and no preset blocks.
    The tick delay is pretty ridiculous, I know, but I'm too lazy to make a better one. It's just to prevent your server from crashing, not lagging.

    Do more of these challenges, I like them :emoji_stuck_out_tongue:

    @EDIT
    Yeah, so I was setting the blocks, but instead the challenge says to just give information about the blocks. It actually performs better doing that (my record is 284,711 blocks/s).

    [​IMG]
    Twice as fast :emoji_wink:

    New code:
    Code (Skript):
    1.  
    2. on leftclick holding gold axe:
    3.    event-block is set
    4.    cancel event
    5.    set {pos1} to location of event-block
    6.    send "Pos1 is now set."
    7.  
    8. on rightclick holding gold axe:
    9.    event-block is set
    10.    cancel event
    11.    set {pos2} to location of event-block
    12.    send "Pos2 is now set."
    13.      
    14. command /rectangle [<text>]:
    15.    trigger:
    16.  
    17.        set {_u} to unix timestamp of now
    18.  
    19.        # Getting positions (useless part)
    20.        set {_1} to {pos1}
    21.        set {_2} to {pos2}
    22.  
    23.        # Just saving 3 lines (elses)
    24.        set {_x} to 1
    25.        set {_y} to 1
    26.        set {_z} to 1
    27.  
    28.        # Determines the direction to be used (it always goes from 1 to 2)
    29.        if x coord of {_1} > x coord of {_2}:
    30.            set {_x} to -1
    31.        if y coord of {_1} > y coord of {_2}:
    32.            set {_y} to -1
    33.        if z coord of {_1} > z coord of {_2}:
    34.            set {_z} to -1
    35.      
    36.        # As {_1} is the only one that is changed, I save it.
    37.        # {_2} is used for base.
    38.        set {_base1} to {_1}
    39.      
    40.        # Getting the blocks.
    41.        # I'm not a big fan of whiles, so I just get the difference.
    42.        loop abs(x coord of {_1} - x coord of {_2}) + 1 times:
    43.            loop abs(z coord of {_1} - z coord of {_2}) + 1 times:
    44.                loop abs(y coord of {_1} - y coord of {_2}) + 1 times:
    45.          
    46.                    # A list for each block
    47.                    set {_b} to "%block at {_1}%"
    48.                    add 1 to {_blocks::%{_b}%}
    49.  
    50.                    # The total blocks.
    51.                    add 1 to {_total}
    52.              
    53.                    add {_y} to y coord of {_1}
    54.              
    55.                # Goes to the next Z and resets Y...
    56.                add {_z} to z coord of {_1}
    57.                set y coord of {_1} to y coord of {_base1}
    58.          
    59.            # Goes to the next X and resets Z...
    60.            add {_x} to x coord of {_1}
    61.            set z coord of {_1} to z coord of {_base1}
    62.      
    63.            # Optional waiting.
    64.            # wait 1 tick
    65.  
    66.        set {_time} to (unix timestamp of now - {_u}) * 1000
    67.        send " "
    68.        send "&3&lCUBOID STATS"
    69.        send "Blocks changed: &a%{_total}%"
    70.        send "Cuboid took &a%{_time}%ms&f!"
    71.        send " "
    72.        send "Overall speed: &a%{_total} * 1000 / {_time}% blocks/s"
    73.  
    74.        # Gives you a fancier (not that much) message, so you don't get blind when you see it.
    75.        set {_blocks} to ""
    76.        loop {_blocks::*}:
    77.            set {_blocks} to "%{_blocks}%&f, &a%loop-index%: &7%loop-value%"
    78.        send "Block replaced: %last length of {_blocks} - 4 characters of {_blocks}%"
    79.  
    80.        send " "
    81.  
     
    #4 EWS, Apr 2, 2018
    Last edited: Apr 7, 2018
    • Like Like x 1
  5. Zoot

    Zoot Member

    Joined:
    Oct 21, 2017
    Messages:
    5
    Likes Received:
    2
    Medals:
    Tested with Skript version 2.2-dev33 and skDragon version 0.14.0 on PaperSpigot_1.11.2

    Could do without skDragon, just added particles for oomph :emoji_slight_smile:

    Code (Skript):
    1.  
    2. # Positive X = East; Negative X = West;
    3. # Positive Z = South; Negative Z = North;
    4.  
    5. options:
    6.     wand: iron sword of unbreaking 10 named "&f&lSelection Wand"
    7.  
    8. on join:
    9.     clear {playerdata::%player%::blockhistory::*}
    10. # Clears and removes variables from particles for safety
    11.     if {playerdata::%player%::visualizer::pointA} is set:
    12.         set {_temp::*} to split "ABCDEFGHIJKL" at ""
    13.         loop {_temp::*}:
    14.             stopEffect "selectionvisualizer::pointA::%loop-value%::%player%"
    15.         clear {playerdata::%player%::visualizer::pointB}
    16.     if {playerdata::%player%::visualizer::pointB} is set:
    17.         set {_temp::*} to split "ABCDEFGHIJKL" at ""
    18.         loop {_temp::*}:
    19.             stopEffect "selectionvisualizer::pointB::%loop-value%::%player%"
    20.         clear {playerdata::%player%::visualizer::pointB}
    21.  
    22. on quit:
    23.     clear {playerdata::%player%::blockhistory::*}
    24. # Clears and removes variables from particles for safety
    25.     if {playerdata::%player%::visualizer::pointA} is set:
    26.         set {_temp::*} to split "ABCDEFGHIJKL" at ""
    27.         loop {_temp::*}:
    28.             stopEffect "selectionvisualizer::pointA::%loop-value%::%player%"
    29.         clear {playerdata::%player%::visualizer::pointB}
    30.     if {playerdata::%player%::visualizer::pointB} is set:
    31.         set {_temp::*} to split "ABCDEFGHIJKL" at ""
    32.         loop {_temp::*}:
    33.             stopEffect "selectionvisualizer::pointB::%loop-value%::%player%"
    34.         clear {playerdata::%player%::visualizer::pointB}
    35.        
    36. on leftclick:
    37.     if player's tool is {@wand}:
    38.         if clicked block is not air:
    39. # Sets a point with a visual effect
    40.             set {playerdata::%player%::pointA} to location of clicked block
    41.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 north 1 west of clicked block, target location of block 1 north 1 east of clicked block, id "selectionvisualizer::pointA::A::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    42.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 north 1 east of clicked block, target location of block 1 south 1 east of clicked block, id "selectionvisualizer::pointA::B::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    43.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 south 1 east of clicked block, target location of block 1 south 1 west of clicked block, id "selectionvisualizer::pointA::C::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    44.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 south 1 west of clicked block, target location of block 1 north 1 west of clicked block, id "selectionvisualizer::pointA::D::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    45.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 north 1 west of clicked block, target location of block above clicked block, id "selectionvisualizer::pointA::E::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    46.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 north 1 east of clicked block, target location of block above clicked block, id "selectionvisualizer::pointA::F::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    47.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 south 1 east of clicked block, target location of block above clicked block, id "selectionvisualizer::pointA::G::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    48.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 south 1 west of clicked block, target location of block above clicked block, id "selectionvisualizer::pointA::H::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    49.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 north 1 west of clicked block, target location of block below clicked block, id "selectionvisualizer::pointA::I::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    50.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 north 1 east of clicked block, target location of block below clicked block, id "selectionvisualizer::pointA::J::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    51.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 south 1 east of clicked block, target location of block below clicked block, id "selectionvisualizer::pointA::K::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    52.             drawLine particle redstone, RGB 10, 0, 255, center location of block 1 south 1 west of clicked block, target location of block below clicked block, id "selectionvisualizer::pointA::L::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    53.             set {playerdata::%player%::visualizer::pointA} to now
    54.             send "&7(&a!&7) &7Set point &aA&7 at location <tooltip:Click to teleport to this location.><cmd:/sktp %player% %x-coord of clicked block% %y-coord of clicked block% %z-coord of clicked block% %world of clicked block%>&f(%location of clicked block%)." to player
    55.        
    56. on rightclick:
    57.     if player's tool is {@wand}:
    58.         if clicked block is not air:
    59. # Sets a point with a visual effect
    60.             set {playerdata::%player%::pointB} to location of clicked block
    61.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 north 1 west of clicked block, target location of block 1 north 1 east of clicked block, id "selectionvisualizer::pointB::A::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    62.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 north 1 east of clicked block, target location of block 1 south 1 east of clicked block, id "selectionvisualizer::pointB::B::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    63.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 south 1 east of clicked block, target location of block 1 south 1 west of clicked block, id "selectionvisualizer::pointB::C::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    64.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 south 1 west of clicked block, target location of block 1 north 1 west of clicked block, id "selectionvisualizer::pointB::D::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    65.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 north 1 west of clicked block, target location of block above clicked block, id "selectionvisualizer::pointB::E::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    66.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 north 1 east of clicked block, target location of block above clicked block, id "selectionvisualizer::pointB::F::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    67.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 south 1 east of clicked block, target location of block above clicked block, id "selectionvisualizer::pointB::G::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    68.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 south 1 west of clicked block, target location of block above clicked block, id "selectionvisualizer::pointB::H::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    69.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 north 1 west of clicked block, target location of block below clicked block, id "selectionvisualizer::pointB::I::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    70.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 north 1 east of clicked block, target location of block below clicked block, id "selectionvisualizer::pointB::J::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    71.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 south 1 east of clicked block, target location of block below clicked block, id "selectionvisualizer::pointB::K::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    72.             drawLine particle redstone, RGB 255, 0, 10, center location of block 1 south 1 west of clicked block, target location of block below clicked block, id "selectionvisualizer::pointB::L::%player%", onlyFor player, rainbowMode false, solid true, density 5, length 2, zigZag count 0, height 0, visibleRange 32, displacementXYZ 0, 2, 0, pulseDelay 1
    73.             set {playerdata::%player%::visualizer::pointB} to now
    74.             send "&7(&a!&7) &7Set point &aB&7 at location <tooltip:Click to teleport to this location.><cmd:/sktp %player% %x-coord of clicked block% %y-coord of clicked block% %z-coord of clicked block% %world of clicked block%>&f(%location of clicked block%)." to player
    75.        
    76. every second:
    77.     loop all players:
    78. # Clearing visual effects
    79.         if {playerdata::%loop-player%::visualizer::pointA} is set:
    80.             if difference between {playerdata::%loop-player%::visualizer::pointA} and now > 3 seconds:
    81.                 set {_temp::*} to split "ABCDEFGHIJKL" at ""
    82.                 loop {_temp::*}:
    83.                     stopEffect "selectionvisualizer::pointA::%loop-value-2%::%loop-player%"
    84.                 clear {playerdata::%loop-player%::visualizer::pointA}
    85.         if {playerdata::%loop-player%::visualizer::pointB} is set:
    86.             if difference between {playerdata::%loop-player%::visualizer::pointB} and now > 3 seconds:
    87.                 set {_temp::*} to split "ABCDEFGHIJKL" at ""
    88.                 loop {_temp::*}:
    89.                     stopEffect "selectionvisualizer::pointB::%loop-value-2%::%loop-player%"
    90.                 clear {playerdata::%loop-player%::visualizer::pointB}
    91.  
    92. command /sktp [<player>] [<number>] [<number>] [<number>] [<text>]:
    93.     permission: skript.selection
    94.     trigger:
    95.         set {_w} to world("%arg-5%")
    96.         teleport arg-1 to location(arg-2, arg-3, arg-4, {_w})
    97.    
    98. command /manualselection [<text>] [<number>] [<number>] [<number>] [<text>]:
    99.     permission: skript.selection
    100.     trigger:
    101.         if arg-1 = "pointA":
    102.             arg-2 is set
    103.             arg-3 is set
    104.             arg-4 is set
    105.             if arg-5 is set:
    106.                 set {_w} to world("%arg-5%")
    107.                 set {playerdata::%player%::pointA} to location(arg-2, arg-3, arg-4, {_w})
    108.                 send "&7(&a!&7) &7Set point &aA&7 at location <tooltip:Click to teleport to this location.><cmd:/sktp %player% %x-coord of {playerdata::%player%::pointA}% %y-coord of {playerdata::%player%::pointA}% %z-coord of {playerdata::%player%::pointA}% %world of {playerdata::%player%::pointA}%>&f(%location of {playerdata::%player%::pointA}%)." to player
    109.             else:
    110.                 send "&7(&a!&7) Usage /manualselection (pointA/pointB) (x) (y) (z) (world)" to player
    111.         if arg-1 = "pointB":
    112.             arg-2 is set
    113.             arg-3 is set
    114.             arg-4 is set
    115.             if arg-5 is set:
    116.                 set {_w} to world("%arg-5%")
    117.                 set {playerdata::%player%::pointB} to location(arg-2, arg-3, arg-4, {_w})
    118.                 send "&7(&a!&7) &7Set point &aB&7 at location <tooltip:Click to teleport to this location.><cmd:/sktp %player% %x-coord of {playerdata::%player%::pointB}% %y-coord of {playerdata::%player%::pointB}% %z-coord of {playerdata::%player%::pointB}% %world of {playerdata::%player%::pointB}%>&f(%location of {playerdata::%player%::pointB}%)." to player
    119.             else:
    120.                 send "&7(&a!&7) Usage /manualselection (pointA/pointB) (x) (y) (z) (world)" to player
    121.         else:
    122.             send "&7(&a!&7) Usage /manualselection (pointA/pointB) (x) (y) (z) (world)" to player
    123.  
    124. command /selection [<text>] [<number>] [<text>]:
    125.     permission: skript.selection
    126.     trigger:
    127.         if arg-1 is "wand":
    128.             give {@wand} to player
    129.         if arg-1 is "analyze":
    130.             if arg-2 is not set:
    131.                 if arg-3 is not set:
    132.                     send "&7(&a!&7) &7Usage /selection analyze (number) &nor&7 (slow/normal/fast)" to player
    133.             if arg-2 is a number:
    134.                 if arg-2 >= 150:
    135.                     send "&7(&a!&7) &7Unsafe value input. This input will loop &f150 &7blocks per &fTICK&7." to player
    136.                 if arg-2 < 150:
    137.                     analyzeSelection(player, {playerdata::%player%::pointA}, {playerdata::%player%::pointB}, arg-2)
    138.             if arg-3 is "ultraslow":
    139.                 analyzeSelection(player, {playerdata::%player%::pointA}, {playerdata::%player%::pointB}, 1)
    140.             if arg-3 is "slow":
    141.                 analyzeSelection(player, {playerdata::%player%::pointA}, {playerdata::%player%::pointB}, 10)
    142.             if arg-3 is "normal":
    143.                 analyzeSelection(player, {playerdata::%player%::pointA}, {playerdata::%player%::pointB}, 20)
    144.             if arg-3 is "fast":
    145.                 analyzeSelection(player, {playerdata::%player%::pointA}, {playerdata::%player%::pointB}, 30)
    146.             if arg-3 is "ultrafast":
    147.                 analyzeSelection(player, {playerdata::%player%::pointA}, {playerdata::%player%::pointB}, 50)
    148.         if arg-1 is "history":
    149.             if {playerdata::%player%::blockhistory::*} is set:
    150.                 send "&8-----------------------------------------------------" to player
    151.                 loop {playerdata::%player%::blockhistory::*}:
    152.                     send "&7&f%loop-index%: &7%loop-value%" to player
    153.                 send "&8-----------------------------------------------------" to player
    154.             if {playerdata::%player%::blockhistory::*} is not set:
    155.                 send "&8-----------------------------------------------------" to player
    156.                 send "&8&7&fNo blocks loaded in history!" to player
    157.                 send "&8-----------------------------------------------------" to player
    158.  
    159. function analyzeSelection(p: player, pointA: location, pointB: location, speed: number):
    160.     if world of {_pointA} != world of {_pointB}:
    161.         send "&7&l(&5&l!&7&l)&7 Points are located in two different worlds!" to {_p}
    162.         stop
    163.     clear {playerdata::%{_p}%::blockhistory::*}
    164.     set {_time} to now
    165.     set {_world} to world of {_pointA}
    166. # Takes given locations and finds new fixed cuboid points
    167.     set {_x1} to floor(x-coordinate of {_pointA})
    168.     set {_y1} to floor(y-coordinate of {_pointA})
    169.     set {_z1} to floor(z-coordinate of {_pointA})
    170.     set {_x2} to floor(x-coordinate of {_pointB})
    171.     set {_y2} to floor(y-coordinate of {_pointB})
    172.     set {_z2} to floor(z-coordinate of {_pointB})
    173.     if {_z1} > {_z2}:
    174.         set {_northZ} to {_z2}
    175.         set {_southZ} to {_z1}
    176.     if {_z1} < {_z2}:
    177.         set {_northZ} to {_z1}
    178.         set {_southZ} to {_z2}
    179.     if {_x1} > {_x2}:
    180.         set {_eastX} to {_x1}
    181.         set {_westX} to {_x2}
    182.     if {_x1} < {_x2}:
    183.         set {_eastX} to {_x2}
    184.         set {_westX} to {_x1}
    185.     if {_y1} > {_y2}:
    186.         set {_highestY} to {_y1}
    187.         set {_lowestY} to {_y2}
    188.     if {_y1} < {_y2}:
    189.         set {_highestY} to {_y2}
    190.         set {_lowestY} to {_y1}
    191.     if {_x1} = {_x2}:
    192.         set {_eastX} to {_x1}
    193.         set {_westX} to {_x1}
    194.     if {_y1} = {_y2}:
    195.         set {_highestY} to {_y1}
    196.         set {_lowestY} to {_y1}
    197.     if {_z1} = {_z2}:
    198.         set {_northZ} to {_z1}
    199.         set {_southZ} to {_z1}
    200. # Sets optimal cuboid selection points based off input locations
    201.     set {_fixedpointA} to location({_westX}, {_lowestY}, {_southZ}, {_world})
    202.     set {_fixedpointB} to location({_eastX}, {_highestY}, {_northZ}, {_world})
    203.     broadcast "&7(&a!&7) &7Analyzing..."
    204. # Adds the first block because it starts at this one...
    205.     set {_currentlocation} to {_fixedpointA}
    206.     add 1 to {_blockcount}
    207.     set {_loopX} to {_westX}
    208.     set {_loopY} to {_lowestY}
    209.     set {_loopZ} to {_southZ}
    210.     set {_block} to "%block at {_currentlocation}%"
    211.     add 1 to {playerdata::%{_p}%::blockhistory::%{_block}%}
    212.     add 1 to {_lagcounter}
    213. # Loops the south-western-lowest most block until the it reaches the north-western-highest most block
    214. # Loops west to east, south to north, then up the Z coordinate
    215.     while {_currentlocation} != {_fixedpointB}:
    216.         # Lag measures...
    217.         if {_lagcounter} >= {_speed}:
    218.             clear {_lagcounter}
    219.             wait 1 tick
    220.         if {_loopX} != {_eastX}:
    221.             add 1 to {_blockcount}
    222.             add 1 to {_loopX}
    223.             set {_currentlocation} to location({_loopX}, {_loopY}, {_loopZ}, {_world})
    224.             set {_block} to "%block at {_currentlocation}%"
    225.             add 1 to {playerdata::%{_p}%::blockhistory::%{_block}%}
    226.         if {_loopX} = {_eastX}:
    227.             if {_loopZ} != {_northZ}:
    228.                 add 1 to {_blockcount}
    229.                 add 1 to {_lagcounter}
    230.                 set {_loopX} to {_westX}
    231.                 remove 1 from {_loopZ}
    232.                 set {_currentlocation} to location({_loopX}, {_loopY}, {_loopZ}, {_world})
    233.                 set {_block} to "%block at {_currentlocation}%"
    234.                 add 1 to {playerdata::%{_p}%::blockhistory::%{_block}%}
    235.             else if {_loopZ} = {_northZ}:
    236.                 if {_loopY} < {_highestY}:
    237.                     add 1 to {_blockcount}
    238.                     add 1 to {_lagcounter}
    239.                     set {_loopX} to {_westX}
    240.                     set {_loopZ} to {_southZ}
    241.                     add 1 to {_loopY}
    242.                     set {_currentlocation} to location({_loopX}, {_loopY}, {_loopZ}, {_world})
    243.                     set {_block} to "%block at {_currentlocation}%"
    244.                     add 1 to {playerdata::%{_p}%::blockhistory::%{_block}%}
    245.                 else if {_loopY} >= {_highestY}:
    246.                     broadcast "&7(&a!&7) &7Finished analyzing blocks! Took &a%difference between {_time} and now% &7to analyze."
    247.     if {_currentlocation} = {_fixedpointB}:
    248.         send "&4&c&6&e&2&a&b&9&1&d&5&4&c&6&e&2&a&b&9&1&d&5&4&c&6&e&2&a&b&9&1&d&5&4&c█" to {_p}
    249.         send "&7&fTotal blocks in selection: &7%{_blockcount}%" to {_p}
    250.         send "&7&fDifferent types of blocks: &7%size of {playerdata::%{_p}%::blockhistory::*}%" to {_p}
    251.         send "&7➥ <tooltip:Click me!><cmd:/selection history>&7[Click to view types of blocks]" to {_p}
    252.         send "&4&c&6&e&2&a&b&9&1&d&5&4&c&6&e&2&a&b&9&1&d&5&4&c&6&e&2&a&b&9&1&d&5&4&c█" to {_p}
    253.  
    254. # Positive X = East; Negative X = West;
    255. # Positive Z = South; Negative Z = North;
    256.  
    Permissions: skript.selection
    Commands:
    /selection wand: gives you the selection wand
    /selection analyze (1-149) or (ultraslow/slow/normal/fast/ultrafast): Analyzes your selection and gives basic info
    /selection history: Shows types of block in your last selection history (If you have one)
    /manualselection (pointA/pointB) (x) (y) (z) (world): Manually set a point without going there.

    Maybe the next Skript Challenge could be an entire skript that will be uploaded as an official skunity resource. It could be something simple like an essentials / worldedit remake. The winner could be the one who does it the most efficient with variables and size.
     
    #5 Zoot, Apr 7, 2018
    Last edited: Apr 7, 2018
    • Like Like x 1
  6. BaeFell

    BaeFell I'm Poppy
    Admin

    Joined:
    Nov 27, 2016
    Messages:
    342
    Likes Received:
    202
    Last day for entries! Will begin judging them tonight :emoji_slight_smile:
     
  7. Simuciokas

    Simuciokas Member

    Joined:
    Apr 26, 2017
    Messages:
    6
    Likes Received:
    4
    Medals:
    Supports cube, round and linear shapes with a bit more info of it in output
    Shows info about total amount of blocks, block type, amount of each block type, amount of chunks, the locations in chunks and container's items
    size of ...
    is only used in selected position count
    Global variables are used to not use repeating code (ex. blocks() function would be repeated 2 times, in sphere and cuboid selections)
    Selections are done with a wooden hoe

    Code (Text):
    1.  
    2. on load:
    3.     clear {main::*}
    4.  
    5. #selection point stuff
    6. function click(i: integer, b: block):
    7.     set {main::pos::%{_i}%} to {_b}
    8.     broadcast "Position %{_i}% has been set (x %x-coord of {main::pos::%{_i}%}%, y %y-coord of {main::pos::%{_i}%}%, z %z-coord of {main::pos::%{_i}%}%)"
    9.  
    10. #all the needed stuff for information about the block
    11. function blocks(x: number, y: number, z: number):
    12.  
    13.     #counting total amount of blocks
    14.     add 1 to {main::amount}
    15.  
    16.     #setting location (local)
    17.     set {_location} to location({_x}, {_y}, {_z}, ({main::pos::1}'s world))
    18.  
    19.     #getting the block (local)
    20.     set {_blockName} to "%block at {_location}%"
    21.  
    22.     #setting chunk (local)
    23.     set {_chunk} to "%{_location}'s chunk%"
    24.  
    25.     #adding block type to a list by it's name
    26.     if {main::blockTypes::%{_blockName}%} is not set:
    27.         set {main::blockTypes::%{_blockName}%} to true
    28.  
    29.     #adding chunks to a list and counting amount
    30.     if {main::blockChunks::%{_chunk}%} is not set:
    31.         set {main::blockChunks::%{_chunk}%} to true
    32.         add 1 to {main::blocksChunks::amount}
    33.      
    34.     #adding the blocks to a list, by their names in a chunk
    35.     add block at {_location} to {main::blocks::%{_chunk}%::%{_blockName}%::*}
    36.  
    37.     #counting specific amount of blocks
    38.     add 1 to {main::blockAmount::%{_blockName}%}
    39.  
    40. #checking which coordinate is higher where {_?2} is always bigger than {_?1}, then getting the length of the axis
    41. function coordsAndAxis():
    42.     if x-coord of {main::pos::1} > x-coord of {main::pos::2}:
    43.         set {main::x1} to x-coord of {main::pos::2}
    44.         set {main::x2} to x-coord of {main::pos::1}
    45.     else:
    46.         set {main::x1} to x-coord of {main::pos::1}
    47.         set {main::x2} to x-coord of {main::pos::2}
    48.     if y-coord of {main::pos::1} > y-coord of {main::pos::2}:
    49.         set {main::y1} to y-coord of {main::pos::2}
    50.         set {main::y2} to y-coord of {main::pos::1}
    51.     else:
    52.         set {main::y1} to y-coord of {main::pos::1}
    53.         set {main::y2} to y-coord of {main::pos::2}
    54.     if z-coord of {main::pos::1} > z-coord of {main::pos::2}:
    55.         set {main::z1} to z-coord of {main::pos::2}
    56.         set {main::z2} to z-coord of {main::pos::1}
    57.     else:
    58.         set {main::z1} to z-coord of {main::pos::1}
    59.         set {main::z2} to z-coord of {main::pos::2}
    60.     set {main::x} to {main::x2} - {main::x1} + 1
    61.     set {main::y} to {main::y2} - {main::y1} + 1
    62.     set {main::z} to {main::z2} - {main::z1} + 1
    63.  
    64. #axis length check
    65. function length() :: strings:
    66.     if {main::x} = 1:
    67.         return "y" and "z"
    68.     if {main::y} = 1:
    69.         return "x" and "z"
    70.     if {main::z} = 1:
    71.         return "x" and "y"
    72.     return {_none}
    73.  
    74. #shape perfection check
    75. function perfect() :: boolean:
    76.     if {main::x} != {main::y}:
    77.         return false
    78.     else if {main::x} != {main::z}:
    79.         return false
    80.     return true
    81.  
    82. #broadcast axis lengths
    83. function axis():
    84.     broadcast "Axis lengths:"
    85.     broadcast "x - %{main::x}%", "y - %{main::y}%" and "z - %{main::z}%"
    86.  
    87. #new line
    88. function space():
    89.     broadcast ""
    90.  
    91. #position 1 selection
    92. on leftclick with wooden hoe:
    93.     clicked block is set
    94.     cancel event
    95.     click(1, clicked block)
    96.  
    97. #position 2 selection
    98. on rightclick with wooden hoe:
    99.     clicked block is set
    100.     cancel event
    101.     click(2, clicked block)
    102.  
    103. #arg-1 can be <cube", "rectangle" or "square"> or <"linear", "line" or "vector"> or <"sphere", "circle", "egg" or "round">
    104. #arg-2 can be "detailed" or "simple"
    105. command blocks [<text="cube">] [<text="detailed">]:
    106.     trigger:
    107.  
    108.         #if positions are not set
    109.         if size of {main::pos::*} != 2:
    110.             send "Position(s) not set"
    111.             stop
    112.          
    113.         #if world's of both positions are not the same
    114.         if {main::pos::1}'s world != {main::pos::2}'s world:
    115.             send "Positions' worlds are different"
    116.             stop
    117.          
    118.         space()
    119.      
    120.         broadcast "&aUsed command /blocks %arg-1% %arg-2%"
    121.      
    122.         #cuboid stuff
    123.         if arg-1 = "cube", "rectangle" or "square":
    124.      
    125.             #checking which coordinate is higher where {main::?2} is always bigger than {main::?1}, then getting the length of the axis
    126.             coordsAndAxis()
    127.  
    128.             loop {main::y} times:
    129.                 loop {main::z} times:
    130.                     loop {main::x} times:
    131.  
    132.                         #counting and doing shit with the block
    133.                         blocks(({main::x1} - 1 + loop-value-3), ({main::y1} - 1 + loop-value-1), ({main::z1} - 1 + loop-value-2))
    134.  
    135.         #line stuff
    136.         else if arg-1 = "linear" or "line":
    137.             loop blocks from {main::pos::1} to {main::pos::2}:
    138.  
    139.                 #counting and doing shit with the block
    140.                 blocks((x-coord of loop-value), (y-coord of loop-value), (z-coord of loop-value))
    141.          
    142.         #round stuff
    143.         else if arg-1 = "sphere", "circle", "egg" or "round":
    144.             #checking which coordinate is higher where {main::?2} is always bigger than {main::?1}, then getting the length of the axis
    145.             coordsAndAxis()
    146.  
    147.             #getting the highest selection point to deduct numbers from
    148.             set {_location} to location({main::x2}, {main::y2}, {main::z2}, world of {main::pos::1})
    149.  
    150.             #if it's a dot, we just input one block
    151.             if {main::pos::1} = {main::pos::2}:
    152.                 blocks((x-coord of {_location}), (y-coord of {_location}), (z-coord of {_location}))
    153.             else:
    154.                 #getting the middle block's location
    155.                 remove {main::x}/2 from x-coord of {_location}
    156.                 remove {main::y}/2 from y-coord of {_location}
    157.                 remove {main::z}/2 from z-coord of {_location}
    158.  
    159.                 set {_block} to block at {_location}
    160.  
    161.                 set {_radius} to max({main::x},{main::y},{main::z})/2
    162.  
    163.                 loop blocks in radius {_radius} of {_block}:
    164.                     x-coord of loop-value is between {main::x1} and {main::x2}
    165.                     y-coord of loop-value is between {main::y1} and {main::y2}
    166.                     z-coord of loop-value is between {main::z1} and {main::z2}
    167.                     blocks((x-coord of loop-value), (y-coord of loop-value), (z-coord of loop-value))
    168. #can be used for debug
    169. #                    set loop-value to stone bricks
    170.                  
    171.         else:
    172.             broadcast "just wrong input :( %arg-1%"
    173.             stop
    174.          
    175.         space()
    176.  
    177.         #showing detailed stuff
    178.         if arg-2 = "detailed":
    179.  
    180.             loop {main::blockTypes::*}:
    181.  
    182.                 #Showing what's block
    183.                 broadcast "&6%loop-index-1%(s) at:"
    184.  
    185.                 loop {main::blockChunks::*}:
    186.  
    187.                     #checking if the blockType in a chunk exists
    188.                     {main::blocks::%loop-index-2%::%loop-index-1%::1} is set
    189.  
    190.                     #broadcasting chunk
    191.                     broadcast " At %loop-index-2%:"
    192.  
    193.                     #looping the blocks in a chunk of a blockType
    194.                     loop {main::blocks::%loop-index-2%::%loop-index-1%::*}:
    195.  
    196.                         #broadcasting the location of the block
    197.                         broadcast "  &7%location of loop-value-3%"
    198.  
    199.                         #checking if the block is a container to show more info
    200.                         if loop-value-3 = chest, furnace, dropper, hopper, brewing stand, dispenser or trapped chest:
    201.  
    202.                             #if the container has any items in it
    203.                             if items in loop-value-3 is set:
    204.  
    205.                                 broadcast "  &6Containing:"
    206.  
    207.                                 #sets the amount of items it has in a list variable by it's name
    208.                                 loop items in loop-value-3's inventory:
    209.                                     set {_item} to "%loop-value-4%"
    210.                                     add 1 to {_chestInventory::%{_item}%}
    211.  
    212.                                 #loops the list variable showing the amount of an item
    213.                                 loop {_chestInventory::*}:
    214.                                     broadcast "   &7%loop-value-4% of %loop-index-4%"
    215.  
    216.                                 #clears the var for another container
    217.                                 clear {_chestInventory::*}
    218.  
    219.                             else:
    220.                                 broadcast "   &6Empty"
    221.  
    222.                 broadcast "&c-----------------------"
    223.                 space()
    224.          
    225.         #showing amounts of each block type
    226.         loop {main::blockTypes::*}:
    227.             broadcast "%{main::blockAmount::%loop-index%}% of %loop-index%"
    228.          
    229.         space()
    230.          
    231.         #total amount of chunks.
    232.         broadcast "Total amount of chunks: %{main::blocksChunks::amount}%"
    233.      
    234.         #total amount of blocks
    235.         broadcast "Total amount of blocks: %{main::amount}%"
    236.      
    237.         space()
    238.      
    239.         broadcast "Selection shape:"
    240.      
    241.         #1 block amount is a dot :^)
    242.         if {main::amount} = 1:
    243.             broadcast "dot"
    244.         else:
    245.  
    246.             #cuboid stuff
    247.             if arg-1 = "cube", "rectangle" or "square":
    248.          
    249.                 #checking which length out of x, y, z is equal to 1 and setting the list var to other symbols
    250.                 #if none are equal to 1 returns none
    251.                 #ex. if x = 1, then return "y" and "z"
    252.                 set {_notCube::*} to length()
    253.                 if {_notCube::1} is not set:
    254.                     if perfect() is true:
    255.                         broadcast "perfect cube"
    256.                     else:
    257.                         broadcast "non-perfect cube (cuboid?)"
    258.                 else:
    259.                     if {main::%{_notCube::1}%} = {main::%{_notCube::2}%}:
    260.                         broadcast "square"
    261.                     else:
    262.                         broadcast "rectangle"
    263.                 space()
    264.                 axis()
    265.  
    266.             #line stuff
    267.             else if arg-1 = "linear" or "line":
    268.                 if round(distance between {main::pos::1} and {main::pos::2}) = distance between {main::pos::1} and {main::pos::2}:
    269.                     broadcast "straight line"
    270.                 else:
    271.                     broadcast "wiggly/non-straight(?) line"
    272.                 space()
    273.                 broadcast "with length %distance between {main::pos::1} and {main::pos::2}%"
    274.  
    275.             #round stuff
    276.             else if arg-1 = "sphere", "circle", "egg" or "round":
    277.                 #checking which length out of x, y, z is equal to 1 and setting the list var to other symbols
    278.                 #if none are equal to 1 returns none
    279.                 #ex. if x = 1, then return "y" and "z"
    280.                 set {_notSphere::*} to length()
    281.                 if {_notSphere::*} is set:
    282.                     if {main::%{_notSphere::1}%} = {main::%{_notSphere::2}%}:
    283.                         broadcast "perfect 2d circle"
    284.                     else:
    285.                         broadcast "2d egg"
    286.                 else:
    287.                     if perfect() is true:
    288.                         broadcast "perfect 3d sphere"
    289.                     else:
    290.                         broadcast "3d egg"
    291.                 broadcast "with radius %{_radius}%"
    292.                 space()
    293.                 axis()
    294.             else:
    295.                 broadcast "Unknown shape.. This shouldn't happen. Hm :thonk:"
    296.  
    297.  
    298.         #everything's done, so deleting stored information
    299.         clear {main::*}
    300.  
     
    #7 Simuciokas, Apr 7, 2018
    Last edited: Apr 7, 2018
  8. K

    KroterPvP Well-Known Member

    Joined:
    Apr 10, 2017
    Messages:
    176
    Likes Received:
    7
    I coded it using the latest version of skript bensku's edit and a 1.11.2 server. No addons needed.
    Use /tool to receive the selection tool. Rightclick any block to select the first corner, rightclick a second block to select the second corner. It will automaticly loop the area when the second corner is selected. If the selected area is bigger than 5.000 blocks, it will wait a tick when looping blocks to prevent your server from crashing.

    Code (Skript):
    1. # Main command to get the tool to select corners
    2. command /tool:
    3.     trigger:
    4.         give player iron axe named "&ePoint Selection"
    5.  
    6. # When you rightclick using an iron axe:
    7. on rightclick using iron axe:
    8. # Axe's name is "&ePoint Selection":
    9.     name of event-item contains "&ePoint Selection":
    10. # It will continue only if the rightclicked block isn't air:
    11.         event-block is not air:
    12. # If this variable is not set means you are selecting point 1.
    13.             {variable::p1} is not set:
    14. # Setting the variable that refers to point 1 to the location of clicked block
    15.                 set {variable::p1} to event-block's location
    16.                 send "&7You successfully selected the point: &b##1"
    17. # If the first corner is already set:
    18.             else:
    19.                 send "&7You successfully selected the point: &b##2"
    20.                 send ""
    21.                 send "&7Operation started. Let me do my work..."
    22. # Setting another var to the corner 1
    23.                 set {_p1} to {variable::p1}
    24. # Deleting the main corner 1 variable so you will be able to do more than 1 process at the same time
    25.                 delete {variable::*}
    26. # This variable contains the starting time
    27.                 set {_start-time} to now
    28. # Positive coords
    29.                 set {_x} to (x-coord of {_p1} - (x-coord of event-block + 1))
    30.                 set {_y} to (y-coord of {_p1} - (y-coord of event-block + 1))
    31.                 set {_z} to (z-coord of {_p1} - (z-coord of event-block + 1))
    32. # Negative number
    33.                 set {_sign::%{_x}%} to "-1" parsed as number
    34.                 set {_sign::%{_y}%} to "-1" parsed as number
    35.                 set {_sign::%{_z}%} to "-1" parsed as number
    36. # It coord is negative
    37.                 if x-coord of {_p1} > x-coord of event-block:
    38. # Negative coord
    39.                     set {_x} to (x-coord of {_p1} - (x-coord of event-block - 1))
    40. # Positive number
    41.                     set {_sign::%{_x}%} to "+1" parsed as number
    42.                 if y-coord of {_p1} > y-coord of event-block:
    43.                     set {_y} to (y-coord of {_p1} - (y-coord of event-block - 1))
    44.                     set {_sign::%{_y}%} to "+1" parsed as number
    45.                 if z-coord of {_p1} > z-coord of event-block:
    46.                     set {_z} to (z-coord of {_p1} - (z-coord of event-block - 1))
    47.                     set {_sign::%{_z}%} to "+1" parsed as number
    48. # Selection is bigger than 5000 blocks
    49.                 if abs({_x} * {_y} * {_z}) > 5000:
    50.                     send ""
    51.                     send " &7Too big selection (&a%abs({_x} * {_y} * {_z})% &7blocks)! Tick delay is activated for this selection."
    52. # Looping the absolute value of x, y, z variables
    53.                     loop abs({_z}) times:
    54.                         loop abs({_y}) times:
    55.                             loop abs({_x}) times:
    56.                                 wait 1 tick
    57. # Adding the current looping block to a variable containing total blocks processed.
    58.                                 add block at {_p1} to {_blocks::*}
    59. # Remove positive or negative number depending if the coord is negative or positive
    60.                                 remove {_sign::%{_x}%} from x-coord of {_p1}
    61. # Sets the x coord to it's default value
    62.                             add {_x} to x-coord of {_p1}
    63.                             remove {_sign::%{_y}%} from y-coord of {_p1}
    64.                         add {_y} to y-coord of {_p1}
    65.                         remove {_sign::%{_z}%} from z-coord of {_p1}
    66. # Selection is less than 5000 blocks
    67.                 else:
    68. # Same as above but without the waiting tick
    69.                     loop abs({_z}) times:
    70.                         loop abs({_y}) times:
    71.                             loop abs({_x}) times:
    72.                                 add block at {_p1} to {_blocks::*}
    73.                                 remove {_sign::%{_x}%} from x-coord of {_p1}
    74.                             add {_x} to x-coord of {_p1}
    75.                             remove {_sign::%{_y}%} from y-coord of {_p1}
    76.                         add {_y} to y-coord of {_p1}
    77.                         remove {_sign::%{_z}%} from z-coord of {_p1}
    78. # Looping each block the variable contains
    79.                 loop {_blocks::*}:
    80. # Setting a variable to the block
    81.                     set {_blockType} to "%loop-value%"
    82. # Adding 1 to the variable of the block if it's repeated
    83.                     add 1 to {_blockCount::%{_blockType}%}
    84.                 set {_allBlockCounts} to ""
    85. # Looping each value the variable contains contains
    86.                 loop {_blockCount::*}:
    87. # Getting the block list, with a cool formating
    88.                     set {_allBlockCounts} to "%{_allBlockCounts}%<tooltip:&7(&a%{_blockCount::%loop-index%}%&7)>&a%loop-index%&7, "
    89. # Replacing some characters of the variable because I don't like them
    90.                 replace all "_" in {_allBlockCounts} with " "
    91. # And the final message!
    92.                 send ""
    93.                 send "&a&lFINISHED! &7See the results:"
    94.                 send "&7Some of them contain tooltips."
    95.                 send ""
    96.                 send " &7Elapsed time: &a%difference between {_start-time} and now%"
    97.                 send " &7Number of blocks: &a%abs({_x} * {_y} * {_z})%"
    98.                 send " &7Block list: %{_allBlockCounts}%"
     
  9. BaeFell

    BaeFell I'm Poppy
    Admin

    Joined:
    Nov 27, 2016
    Messages:
    342
    Likes Received:
    202
    Last 20 minutes!
     
  10. BaeFell

    BaeFell I'm Poppy
    Admin

    Joined:
    Nov 27, 2016
    Messages:
    342
    Likes Received:
    202
    Challenge over. Thread locked. Winners will be announced within a day or two.
     
Thread Status:
Not open for further replies.
Loading...