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.

Solved If loop-entity is set

Discussion in 'Skript' started by PatoFrango, Jul 18, 2018.

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

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    222
    Likes Received:
    14
    Hi,

    I'm coding a thing that loops all armor stands in radius of a block. What I want to do is, if it finds indeed an armor stand, it sends a message saying "Test". If not, it sends "lol".

    The thing is, when it's supposed to say "lol", in other words, when no armor stand is found, simply nothing happens. No errors detected on reload. I feel like I've done this before, 'cause it's not the most complicated of the tasks, I just don't remember how I did it.
    Code (Skript):
    1. loop all armor stands in radius 2 of {_block}:
    2.     if loop-entity is set:
    3.         send "{@prefix} &cTest"
    4.     else:
    5.         send "lol" to player
     
    #1 PatoFrango, Jul 18, 2018
    Last edited: Jul 18, 2018
  2. Best Answer:
    Post #2 by Donut, Jul 18, 2018
  3. Donut

    Donut Well-Known Member

    Joined:
    Mar 27, 2017
    Messages:
    1,340
    Likes Received:
    176
    Medals:
    loop entity will always be set because it wont loop if there are no armorstands
     
  4. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,499
    Likes Received:
    102
    Medals:
    Try
    Code (Skript):
    1. loop all armor stands in radius 2 of {_block}:
    2.     set {_msg} to "{@prefix} &cTest"
    3. message {_msg} if {_msg} is set, else "lol"
     
  5. PatoFrango

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    222
    Likes Received:
    14
    I had already tried something like that, and it worked. Yes, the issue was what Donut said. Thank you both.
    Code (Skript):
    1. loop all armor stands in radius 2 of {_block}:
    2.     if loop-entity is set:
    3.         send "{@prefix} &cTest"
    4.         set {_found} to true
    5. if {_found} is not set:
    6.     # code
     
  6. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,234
    Likes Received:
    174
    Medals:
    You can simplify your code to only one condition actually:
    Code (Skript):
    1. if armor stands in radius 2 of {_block} are set:
    2.   #Code
     
Thread Status:
Not open for further replies.

Share This Page

Loading...