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 chunks

Discussion in 'Skript' started by sandor_1234, Jun 18, 2017.

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

    sandor_1234 Active Member

    Joined:
    Jan 26, 2017
    Messages:
    165
    Likes Received:
    5
    How can i get the chunks in the radius x of the player?
    Like:
    Code (Skript):
    1. loop chunks in radius 4:
    2.    add loop-value to {faction.land::}
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Try loop-chunk?
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    The first part won't work:
    The second part probably will work fine.
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Oh wait, I wasn't reading your code carefully.

    Code (Skript):
    1. loop chunks in radius 4 around player:
    You need to specify where the chunks will be looped.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Nope, already tried that and it doesn't matter in this case :emoji_frowning: .

    Can't understand this loop: 'loop chunks in radius 4 around player' (fflagg.sk, line 14: loop chunks in radius 4 around player:')
    --- Double Post Merged, Jun 18, 2017, Original Post Date: Jun 18, 2017 ---
    I found this as a other way to loop chunks:
    https://pastebin.com/ksFZgeYY
    It was part of a faction skript which would show a /f map thingy.
    Does some one understand how it works? xD
    --- Double Post Merged, Jun 20, 2017 ---
    Bump
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    I made a function which returns a list of chunks.

    Code (Text):
    1.  
    2. function chunks_in_radius(center: location, radius: number) :: chunks:
    3.     set {_pos} to {_center}
    4.     set z-coordinate of {_pos} to z-coordinate of {_center} - 16 * {_radius}
    5.     loop 2 * {_radius} + 1 times:
    6.         set x-coordinate of {_pos} to x-coordinate of {_center} - 16 * {_radius}
    7.         loop 2 * {_radius} + 1 times:
    8.             add chunk at {_pos} to {_chunks::*}
    9.             add 16 to x-coordinate of {_pos}
    10.         add 16 to z-coordinate of {_pos}
    11.     return {_chunks::*}
    12.  
    Usage:
    Code (Text):
    1.  
    2. set {_chunks::*} to chunks_in_radius(player, 4)
    3.  
     
    • Useful Useful x 1
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Could you explain me how it works?
    Does it just add / remove 16 from the coords to get the chunks around it?
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    225
    Yes. You give it the center location, then it subtracts the radius in both the x- and z-direction so you end up in a corner of your square. Then it loops only over the x-coordinates until it reaches the maximum. This is basically just a line. Then it resets the x-coordinate and adds 16 to the z-coordinate and loops over the x-coordinates again. This creates a second line next to the first one. This is repeated until it reaches the maximum z-coordinate.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...