Solved Looping issues

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

    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.

Idiosyncratic

Member
Feb 21, 2017
62
0
0
USA
code_language.skript:
loop blocks in radius 4 around player:
 #command here

This will activate at intervals while walking in regions when a variable hits x number, but the command fires way too much. I've got no idea what to try next, it should only fire one time, but I do want to be able to change that eventually to 3 to 5 or so, just need a little help with both these issues.
 
Not really sure what you're trying to do.

Maybe I'm just too tired but if you posted the event you're calling this on and the rest of the code would be helpful

What you're doing now will run the command a lot of times since it runs the command for every block in radius 4 of the player which is a fairly large amount of blocks
 
So can I just make it only select 3-5 blocks somehow?
 
code_language.skript:
set {block1} to random element out of blocks in radius 4 around player

set {block2} to random element out of blocks in radius 4 around player

set {block3} to random element out of blocks in radius 4 around player
 
code_language.skript:
set {block1} to random element out of blocks in radius 4 around player

set {block2} to random element out of blocks in radius 4 around player

set {block3} to random element out of blocks in radius 4 around player
make sure to use local vars in example because people are just gonna copy paste
code_language.skript:
set {_b::*} to blocks in radius 5 of player #this way we don't needlessly go through the blocks 5 times
loop 5 times:
  add a random element out of {_b::*} to {_blocks::*}
 
Nah, I figured that


But still, thanks for the better way of doing it, appreciate it.
[doublepost=1501529368,1501475033][/doublepost]I do have one more question, actually. Could I make it so that it only selects air with solid blocks underneath? Sorry for asking, just want to know. Thanks.
 
code_language.skript:
set {_b::*} to blocks in radius 5 of player
while size of {_blocks::*} is less than 5:
     set {_block} to random element of {_b::*}
     if {_block} is air:
        if block below {_block} is not air:
            add {_block} to {_blocks::*}
    wait 1 tick
 
That may as well be an infinite loop, it would just keep checking for a long time and this needs to be non-apparent.
 
wym by non-apparent?

code_language.skript:
set {_b::*} to blocks in radius 5 of player
while size of {_blocks::*} is less than 5:
     set {_block} to random element of {_b::*}
     if {_block} is air:
        if block below {_block} is not air:
            add {_block} to {_blocks::*}
    remove {_block} from {_b::*}
    if size of {_b::*} is 0:
        stop 
    wait 1 tick
 
That would have lagged for about 30-60 seconds, maybe even have crashed the server. I need it to be basically unnoticeable.

While this fills that need, the command runs more than the amount I set. Should I make it delete certain variables before the command runs, or is there another better solution to this?
 
That would have lagged for about 30-60 seconds, maybe even have crashed the server. I need it to be basically unnoticeable.

While this fills that need, the command runs more than the amount I set. Should I make it delete certain variables before the command runs, or is there another better solution to this?
code_language.skript:
loop blocks in radius 5 of player where [block input is air]:
    if the block below loop-block is not air:
        add loop-block to {_blocks::*}
loop 5 times:
    add a random element out of {_blocks::*} to {_final_blocks::*}
 
Doesn't work at all, the command I'm using is summoning mobs, if that helps.
 
code_language.skript:
on any movement:
 if player is in region "test1":
  if {steps::%player's uuid%} is less than 170:
   add 1 to {steps::%player's uuid%}
  if {steps::%player's uuid%} is more than 169:
   set {steps::%player's uuid%} to 0
   #conditioning and setting blocks here
   execute command "/summon Zombie #variables containing blocks here
 
to summon the zombies do this:
code_language.skript:
loop {_final_blocks::*}:
    spawn a zombie at loop-value's location
 
you can customize it but whatever floats your boat
code_language.skript:
loop {_final_blocks::*}:
    execute command "/summon Zombie %loop-value's x-coord% %loop-value's y-coord% %loop-value's z-coord%"
 
This method works perfectly, thanks for the patience and help.
 
Status
Not open for further replies.