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.

layer by layer

Discussion in 'Skript' started by skanto123, Feb 2, 2018.

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

    skanto123 Active Member

    Joined:
    Jan 8, 2018
    Messages:
    70
    Likes Received:
    0
    on place of stone:
    if name of player's held item is "&ctest":
    set blocks within chunk at event-block where [block input is not bedrock] to air

    how do i make it do it a layer by layer so from 255 then 254 then 253 all the way to bedrock
     
  2. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    Code (Skript):
    1. set {_layer} to 255.5
    2. loop 255 times:
    3.     set blocks within chunk at event-block where [block input is not bedrock] where [y-coord of block input is {_layer}] to air
    4.     remove 1 from {_layer}
    5.     wait 1 tick
    the layer starts at 255.5 because the y-coord of a block is always something.5
     
  3. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,236
    Likes Received:
    176
    Medals:
    doing it one time is fine but 255 times? I'm more than sure this will lag your server.
     
  4. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    na i tested it
     
  5. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,236
    Likes Received:
    176
    Medals:
    it might be normal for a player within a local server (no latency), but what about a server with i.e: 50 players? 50 of which let's say 13 execute this effect, don't you think it will lag if 13 personsa re doing it within the same amount of time?.
     
  6. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    no i dont think itll lag because its only setting 1 layer of blocks to air at one time which isnt alot. idk if you saw in the other thread where he wanted the whole chunk set at once and it still didnt lag much
     
  7. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,236
    Likes Received:
    176
    Medals:
    I saw it however, it's the same case, it will have a different impact with many players executing it. Your code has to go through all the blocks in the chunk, check if they aren't air nor bedrock, and then set these blocks to air, the calculation itself could be expensive at some point.

    So, if the OP wants this, you may make sure there is a delay or that it isn't executed regularity or your server will lag a lot otherwise.
     
  8. skanto123

    skanto123 Active Member

    Joined:
    Jan 8, 2018
    Messages:
    70
    Likes Received:
    0
    I tested it and when I make it to set the whole chunk to air it creates less lag that a layer at a time
     
  9. it_twit

    it_twit Member

    Joined:
    Jan 26, 2017
    Messages:
    37
    Likes Received:
    3
    Medals:
    That's because the code donut gave you loops every single block in the chunk 255 times each. It will still set the same number of blocks but it will loop a lot more.
    Instead you want to do something like

    Code (Skript):
    1. set {_layer} to 255.5
    2. loop 255 times:
    3.     set layer {_layer} of chunk at event-block
    4.     remove 1 from {_layer}
    5.     wait 1 tick
    (requires mundosk)
     
Thread Status:
Not open for further replies.

Share This Page

Loading...