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.

[#3] Skript Challenge - Area Fill - Winners announced!

Discussion in 'Skript Challenge' started by BaeFell, Feb 25, 2017.

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

    BaeFell I'm Poppy
    Admin

    Joined:
    Nov 27, 2016
    Messages:
    834
    Likes Received:
    226
    Hi everyone,

    Welcome to another Skript Challenge!

    So here's the third one! If you have any suggestions for #4 or general improvements, let me know :emoji_slight_smile:

    This Skript Challenge is kinda mathematical, but mostly around being smart with how your script works. The task is to create a way for me to fill an area. The area fill must be suitable for any size or shape area. The areas will be completely closed in (so no holes in walls etc). Example:

    [​IMG]
    Filled:
    [​IMG]
    There are no holes in the walls, floor or ceiling (apart from an open door but they're classed as a block). But also note the odd shape. This is just an example, areas can be very complex.

    The rules are as follows (note: rules may change between challenge):
    - Your code must be in [code]<code>[/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 (don't think any do) and the addon must of been released publicly prior to the creation of this thread.
    - You cannot use a feature like "fill area from location of player" or whatever.
    - You can use another user's code, but please don't edit your messages. I can see all message history and you'll not be counted at all.
    Remember: this one is about quality, not just length. So trying to cut variable names from someone elses code will lose points!
    - WebAPI'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 can use an addon to place blocks, but not to fill the area.
    - 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):
    - Your code must work with any size or shape area. Areas are not square and sometimes spin off into rooms.
    - You must provide a way for me to know where you're starting from. So for example: using a command + location of player, right click on sign + location of player, right click on sign + event-location


    Tips:
    - Make it easy for me to change the block which is filling. Constantly repeating "set {_block} to 1", isn't going to be good.
    - Be smart about how I can get out if the area is being filled
    - Try not to crash my server

    I have done this before and the code works well. It uses no addons and is 31 lines long (including some if checks etc).

    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 -> 4th of March - have fun!
    (I might forget to do the winners, but should close after 7 days).
     
    • Like Like x 1
    • Useful Useful x 1
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Not simple, it's hard but i like that xD
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    I managed to do it in about ~35 lines :emoji_wink:
     
    • Like Like x 1
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Usage:
    Type command at location of player

    Function:
    5 Lines plus optional wait
    Code (Skript):
    1. function fill(loc: location, block: itemtype):
    2.     loop blocks in radius 1 around {_loc}:
    3.         if loop-block is air:
    4.             set loop-block to {_block}
    5.             wait a second
    6.             fill(location of loop-block, {_block})
    Example code:
    Code (Skript):
    1. function fill(loc: location, block: itemtype):
    2.     loop blocks in radius 1 around {_loc}:
    3.         if loop-block is air:
    4.             set loop-block to {_block}
    5.             wait a second
    6.             fill(location of loop-block, {_block})
    7. command /bae:
    8.     trigger:
    9.         fill(location of player, light green stained clay)
    Video:

    Code (Skript):
    1. function fill(loc: location, block: itemtype):
    2.     loop blocks in radius 1 around {_loc}:
    3.         if loop-block is air:
    4.             set loop-block to {_block}
    5.             if {stop} is not set:
    6.                 wait a second
    7.                 fill(location of loop-block, {_block})
     
    • Like Like x 4
    • Winner Winner x 2
    • Agree Agree x 1
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Hiya!

    I considered going more ham with this and making it really in-depth, but I figure simplicity is good if it works. This is 14 lines of actual Skript, no add-ons, has a built-in failsafe for if people provide an item type that isn't a block, and allows you to tell it a configurable amount of outwards iterations it will do between each tick delay. All it's missing is a way for the player to get out of the area if they're in the floodfill zone, which could be done in a few ways (I may come back and improve upon it to add something like that, though I'm pretty happy with its current state, and I imagine this as a tool for admins who have access to things like spectator mode anyways).

    Executes from you.

    Code (Skript):
    1. function floodFill(root: location, block: item, iterationsBetweenDelay: integer, iterationNum: number = 0):
    2.     if {_iterationNum} is {_iterationsBetweenDelay}:
    3.         wait 1 tick
    4.         set {_iterationNum} to 0
    5.     loop blocks in radius 1 of {_root}'s location:
    6.         loop-block is air
    7.         set loop-block to {_block}
    8.         if loop-block is air:
    9.             stop
    10.         floodFill(loop-value, {_block}, {_iterationsBetweenDelay}, {_iterationNum} + 1)
    11.  
    12. command /floodfill <item> [<integer=10>]:
    13.     usage: /floodfill <block type> <iterations between delay>
    14.     trigger:
    15.         floodFill(player's location, arg-1, arg-2)
     
    • Like Like x 2
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Code (Skript):
    1.  
    2. command /TryThisCommand:
    3.     permission: try.this.command
    4.     trigger:
    5.         message "Don't move"
    6.         loop all blocks in radius 4 around player's location:
    7.             set loop-block to air
    8.             wait 0.001 seconds
    9.             set block below player to glass block
    10.         loop all blocks in radius 2 around player's location:
    11.             if loop-block is air:
    12.                 set loop-block to glass block
    13.         loop all blocks in radius 1 around player's location:
    14.             if loop-block is glass block:
    15.                 set loop-block to air
    16.         set block below player to glass block
    17.         set block above player to air
    18.         wait 3 seconds
    19.         thrust player upwards at speed 1
    20.         wait 0.2 seconds
    21.         thrust player forwards at speed 1
    22.         message "The End"
    I used Skellett as an addon
     
    #6 ShaneBee, Feb 26, 2017
    Last edited by a moderator: Feb 26, 2017
    • Like Like x 1
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Commands:
    /areaFill <Item> <Radius> [<Delay>] - Start filling from your location
    /areaFill cancel - Cancel or roll back filling

    Features
    :
    - Delayed filling
    - Filling radius
    - Cancel or roll back filling (/areaFill cancel)

    Requirements:
    - Skript 2.2+

    Code (Skript):
    1.  
    2. function areaFill(startLocation: location, location: location, block: itemtype, radius: number, delay: timespan):
    3.     loop blocks in radius 1 of {_location}:
    4.         if {areaFill.cancel} is not set:
    5.             if distance between {_startLocation} and loop-block is smaller than {_radius} + 1:
    6.                 if loop-block is air:
    7.                     set loop-block to {_block}
    8.                     add location of loop-block to {areaFill.placed::*}
    9.                     wait {_delay}
    10.                     areaFill({_startLocation}, loop-block, {_block}, {_radius}, {_delay})
    11.  
    12. command /areaFill <text> [<number>] [<timespan=10 tick>]:
    13.     permission: op
    14.     usage: &c/areaFill <Cancel|Undo|Block> [<Radius>] [<Delay>]
    15.     trigger:
    16.         if arg 1 is not "cancel":
    17.             if arg 1 parsed as itemtype is set:
    18.                 if arg 2 is set:
    19.                     clear {areaFill.placed::*}
    20.                     delete {areaFill.cancel}
    21.                     areaFill(block at player, block at player, arg 1 parsed as itemtype, arg 2, arg 3)
    22.                     send "&aFilling started!"
    23.                     send "&2Block: &b%arg 1%"
    24.                     send "&2Radius: &b%arg 2%"
    25.                     send "&2Delay: &b%arg 3%"
    26.                 else:
    27.                     send "&c/areaFill %arg 1% <Radius> [<Delay>]"
    28.             else:
    29.                 send "&c/areaFill <Cancel|Undo|Block> [<Radius>] [<Delay>]"
    30.         else:
    31.             set {areaFill.cancel} to true
    32.             loop {areaFill.placed::*}:
    33.                 delete block at loop-value
    34.             clear {areaFill.placed::*}
    35.             send "&cFilling canceled or rolled back!"
    36.  

    [​IMG]
     
    #7 ShaneBee, Feb 26, 2017
    Last edited by a moderator: Feb 27, 2017
    • Like Like x 1
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Code (Skript):
    1. function a(location:location):
    2.     set {_0} to random number between 2 and 20
    3.     loop blocks in radius 1 around {_location}:
    4.         loop {_0} times:
    5.             wait tick
    6.         loop-block = air
    7.         a(location of loop-block)
    8.         set block at location at loop-block to any_wool_block
    9. command a:
    10.     trigger:
    11.         a(location of block at player)
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    How to use:
    Use the command /fill <block> inside the area, the script will automatically fill the area with your chosen block type and will teleport you outside of the area.
    If you somehow forget to completely close the area off, and this happens to you:
    [​IMG]
    Then you would always have the option to cancel the process, by using this command "/fill stop".

    Code (Skript):
    1.  
    2. function fill(loc: location, p: player, loc2: location, b: material):
    3.     wait 1 tick
    4.     {fill} is true
    5.     if block at {_loc2} is not air:
    6.         add 1 to {_loc2}'s y-coordinate
    7.     else:
    8.         teleport {_p} to {_loc2}
    9.     loop blocks in radius 1 around {_loc}:
    10.         loop-block is air
    11.         set loop-block to {_b}
    12.         fill(loop-block's location, {_p}, {_loc2}, {_b})
    13.  
    14. command /fill [<text=dirt>]:
    15.     trigger:
    16.         if arg-1 is "stop":
    17.             set {fill} to false
    18.         else:
    19.             set {fill} to true
    20.             fill(player's location, player, player's location, arg-1 parsed as material)
    21.  
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    You should ad that you will be teleported out of the area, and also that you can let it go instant instead of every second
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Try it in empty 3d triangle. It will probably not work if looping area is cube, not circle. In this way It should work only in cubic areas
     
  12. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Nope.
     
    • Like Like x 1
  13. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Code (Skript):
    1. options:
    2.     filter: air
    3.     block: sponge
    4.  
    5. function text2Loc(location:string,world:world = "world") :: location:
    6.     set {_location::*} to {_location} parsed as "x: %number%, y: %number%, z: %number%"
    7.     return location({_location::1}, {_location::2}, {_location::3}, {_world})
    8.  
    9. function chunkLoad(location:location,block:block):
    10.     stop #to do...
    11.  
    12. function b(location:location):
    13.     add {_location} to {_locations::*}
    14.     add chunk of {_location} to {_chunks::*}
    15.     set {_location} to chunk of {_location}
    16.     set {_chunks::%{_location}%::*} to text2Loc("%{_locations::*}%")
    17.     set {_location} to now
    18.     execute console command "tps"
    19.     while {_chunks::*} is set:
    20.         loop {_chunks::*}:
    21.             {_locations::*} isn't set:
    22.                 loop {_chunks::%loop-value%::*}:
    23.                     add text2Loc("%loop-value-2%") to {_locations::*}
    24.             while {_locations::*} is set:
    25.                 loop {_locations::*}:
    26.                     loop blocks in radius 1 around loop-value-2:
    27.                         loop-block = {@filter}
    28.                         if chunk of loop-block = loop-value-1:
    29.                             wait tick
    30.                             set loop-block to {@block}
    31.                             add 1 to {_blocks}
    32.                             chunkLoad(location at loop-block,loop-block)
    33.                             add location at loop-block to {_locations::*}
    34.                         else if "%{_chunks::*}%" contains "%chunk of loop-block%":
    35.                             add location of loop-block to {_chunks::%chunk of loop-block%::*}
    36.                         else:
    37.                             add chunk of loop-block to {_chunks::*}
    38.                             add location of loop-block to {_chunks::%chunk of loop-block%::*}
    39.                     remove loop-value-2 from {_locations::*}
    40.                 wait tick
    41.             broadcast "<green>%loop-value-1% complite!"
    42.             delete {_chunks::%loop-value%::*}
    43.             remove loop-value from {_chunks::*}
    44.             wait second
    45.     execute console command "tps"
    46.     broadcast "<green>all complite! blocks:""%{_blocks}%"" and time:""%difference between now and {_location}%"""
    47.  
    48. command b:
    49.     trigger:
    50. b(location)
    p.s. in theory load one chunk
     
  14. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Like, 2/3 days until this closes. Get your submissions in <3
     
  15. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    I will get around to posting the winners tomorrow! Sorry about the delay. Been very busy with work.

    Locked for now.
     
    • Like Like x 1
  16. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    I pinky promise I'll do this tomorrow!
     
    • Funny Funny x 2
    • Like Like x 1
    • Informative Informative x 1
  17. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    It's time to announce the Winners of the 3rd Skript Challenge! Finally...
    @BaeFell has given me the honour of deciding the winners (probably because he forgot again...). As such, it is my honour to announce the following 3 winners.

    The selection process was quite simple, as most of the submissions a) didn't work properly, or achieve the needed result and b) were mostly based off of @LimeGlass's submission.

    In no particular order, the winners are.

    @LimeGlass - First Submission, Lowest amount of lines, Small and Simple and easily repeatable.
    @Mr_Simba - Much like LimeGlass, but with extra detail in the included failsafe.
    @Blueyescat - With added detail in the form of his arguments, added cancellation ability and more.

    Congratulations to all the winners, and thank you to everyone else who submitted!
    Just some helpful advice for future events;
    1. Try to be original, there are always more than one way of achieving a goal. If you make the most longest and craziest response, then so be it. It's awesome in its own right.
    2. While we're not against building off of others', at least add something new to it (ie; a stop feature)
    3. Make sure it actually does what is required... There's one submission here that didn't even get close to the wanted result.

    Thats all! Thanks a lot!

    (Winners: Your badges will be given in due time, make sure to annoy @BaeFell if you haven't gotten it by next week)

    (This was posted here, since @BaeFell forgot to give me permission to post in the proper place...)
     
    • Like Like x 2
Thread Status:
Not open for further replies.

Share This Page

Loading...