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.

Loop blocks through entities

Discussion in 'Skript' started by PheonBest, Jul 2, 2017.

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

    PheonBest Member

    Joined:
    Jun 8, 2017
    Messages:
    31
    Likes Received:
    1
    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
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    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 (Skript):
    1.  
    2. command /looptest:
    3.     trigger:
    4.         # start / end positions
    5.         set {_loc1} to block 1 blocks in front of player
    6.         set {_loc2} to block 10 blocks in front of player
    7.         # looping between start and end
    8.         loop blocks between {_loc1} and {_loc2}:
    9.             # adding the loop-block to the list
    10.             add loop-block to {_blockLoc::*}
    11.             # every iteration, loop back through the list
    12.             loop {_blockLoc::*}:
    13.                 # see if there's an entity blocking the path yet
    14.                 loop entities in radius 0.7 of location of loop-value-2:
    15.                     # sometimes it might catch the player; we'll add an exception.
    16.                     "%loop-entity%" is not "%player%"
    17.                     broadcast "%loop-entity%"
    18.  
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Or just:
    Code (Skript):
    1. loop blocks in front of location(x-loc of player, y-loc of player, z-loc of player, world of player):
    2.   if monsters and animals in radius 2 of loop-block is set:
    3.     stop loop
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    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?
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I guessed he wanted it to stop when a entity was encountered, but since spigot is synchronous such a thing can't happen
     
Thread Status:
Not open for further replies.

Share This Page

Loading...