Loop blocks through entities

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

PheonBest

Member
Jun 8, 2017
31
1
0
22
Hi !
I want to make this:
loop blocks forward {_loc}:
But when the there's an entity in front of {_loc} the loop stops. Do someone know how to avoid it ?
Edit: skript dev29 spigot 1.12
 
Alright, I don't think I have enough details to be super confident that this is what you mean:

It sounds like, you want to loop blocks between positions X and Y; however, if an entity is between X and Y, the loop breaks.

Something like this may work:
code_language.skript:
command /looptest:
    trigger:
        # start / end positions
        set {_loc1} to block 1 blocks in front of player
        set {_loc2} to block 10 blocks in front of player
        # looping between start and end
        loop blocks between {_loc1} and {_loc2}:
            # adding the loop-block to the list
            add loop-block to {_blockLoc::*}
            # every iteration, loop back through the list
            loop {_blockLoc::*}:
                # see if there's an entity blocking the path yet
                loop entities in radius 0.7 of location of loop-value-2:
                    # sometimes it might catch the player; we'll add an exception.
                    "%loop-entity%" is not "%player%"
                    broadcast "%loop-entity%"
 
Alright, I don't think I have enough details to be super confident that this is what you mean:

It sounds like, you want to loop blocks between positions X and Y; however, if an entity is between X and Y, the loop breaks.

Something like this may work:
code_language.skript:
command /looptest:
    trigger:
        # start / end positions
        set {_loc1} to block 1 blocks in front of player
        set {_loc2} to block 10 blocks in front of player
        # looping between start and end
        loop blocks between {_loc1} and {_loc2}:
            # adding the loop-block to the list
            add loop-block to {_blockLoc::*}
            # every iteration, loop back through the list
            loop {_blockLoc::*}:
                # see if there's an entity blocking the path yet
                loop entities in radius 0.7 of location of loop-value-2:
                    # sometimes it might catch the player; we'll add an exception.
                    "%loop-entity%" is not "%player%"
                    broadcast "%loop-entity%"
Or just:
code_language.skript:
loop blocks in front of location(x-loc of player, y-loc of player, z-loc of player, world of player):
  if monsters and animals in radius 2 of loop-block is set:
    stop loop
 
Or just:
code_language.skript:
loop blocks in front of location(x-loc of player, y-loc of player, z-loc of player, world of player):
  if monsters and animals in radius 2 of loop-block is set:
    stop loop

Under the assumption that we want to exit the loop when a entity is somewhere between (location of player) and (location of current loop-block), would your code not disregard entities that have come into the player's view if that entity is past your 4 block buffer?
 
Under the assumption that we want to exit the loop when a entity is somewhere between (location of player) and (location of current loop-block), would your code not disregard entities that have come into the player's view if that entity is past your 4 block buffer?
I guessed he wanted it to stop when a entity was encountered, but since spigot is synchronous such a thing can't happen
 
Status
Not open for further replies.