layer by layer

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

skanto123

Active Member
Jan 8, 2018
70
0
0
34
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
 
code_language.skript:
set {_layer} to 255.5
loop 255 times:
    set blocks within chunk at event-block where [block input is not bedrock] where [y-coord of block input is {_layer}] to air
    remove 1 from {_layer}
    wait 1 tick
the layer starts at 255.5 because the y-coord of a block is always something.5
 
code_language.skript:
set {_layer} to 255.5
loop 255 times:
    set blocks within chunk at event-block where [block input is not bedrock] where [y-coord of block input is {_layer}] to air
    remove 1 from {_layer}
    wait 1 tick
the layer starts at 255.5 because the y-coord of a block is always something.5
doing it one time is fine but 255 times? I'm more than sure this will lag your server.
 
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?.
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
 
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
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.
 
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
 
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
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_language.skript:
set {_layer} to 255.5
loop 255 times:
    set layer {_layer} of chunk at event-block
    remove 1 from {_layer}
    wait 1 tick
(requires mundosk)
 
Status
Not open for further replies.