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 Loop entity, location

Discussion in 'Skript' started by Craaft3r, Aug 6, 2022.

Tags:
Thread Status:
Not open for further replies.
  1. Craaft3r

    Craaft3r New Member

    Joined:
    Aug 6, 2022
    Messages:
    7
    Likes Received:
    0
    Hi everyone! I'm trying to create a script that when executing the command does a check of all the entities, fetches the coordinates of each one and sends a message .. But I can't!

    Code:
    Code (Text):
    1. command /entity:
    2.     trigger:
    3.         loop all entities in radius 8 of player:
    4.             loop-entity is zombie:
    5.                 set {_entity} to location of loop-entity
    6.                 set x-coordinate of {_entity} to {_x}
    7.                 set {_y} to y-position of {_entity}
    8.                 set {_z} to z-position of {_entity}
    9.                 send "%{_x}%, %{_y}%, %{_z}%" to player
    Skript Version: 2.6.3
    Minecraft Version: 1.19.1
     
    #1 Craaft3r, Aug 6, 2022
    Last edited: Aug 6, 2022
  2. mordrowned

    mordrowned Member

    Joined:
    Apr 22, 2021
    Messages:
    40
    Likes Received:
    2
    Please next time use code blocks, but is there an error message?
     
  3. Craaft3r

    Craaft3r New Member

    Joined:
    Aug 6, 2022
    Messages:
    7
    Likes Received:
    0
    I thought about using the code lock, but didn't find the method, sorry. No gives no errors, when sending alone <none>, <none>, <none>
     
  4. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
    1. you are setting the x-coordinate of _entity to a non existing variable
    2. just do
    Code (Text):
    1. loop all entities in radius 8 of player where [input is a zombie]:
     
  5. Craaft3r

    Craaft3r New Member

    Joined:
    Aug 6, 2022
    Messages:
    7
    Likes Received:
    0
    Fixed for coordinates. The problem was the condition

    This is better:
    Code (Text):
    1. if "%loop-entity%" contains "zombie"
    Do you know another method even for distant entities? If so, even better (Without using the radius)
     
  6. mordrowned

    mordrowned Member

    Joined:
    Apr 22, 2021
    Messages:
    40
    Likes Received:
    2
    You can use
    Code (Text):
    1. loop all entities:
    which loops all loaded entities

    and you can use this for looping all entities in a world.

    Code (Text):
    1. loop all entities in world "world":
    2.  
     
  7. Craaft3r

    Craaft3r New Member

    Joined:
    Aug 6, 2022
    Messages:
    7
    Likes Received:
    0
    I should make particles appear as the lighthouse in every position of the entities, so that the player can see where they are
     
  8. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
    looping all the entities is a bad ideas for many reasons, it will loop entities such as item frames and armor stands etc which you probably don't want to loop (this can be fixed with a filter anyway), even with that fixed you still shouldn't loop ALL OF THEM, chances are performance will drop. loop all the entities in a big radius like 50 and call it a day
     
  9. mordrowned

    mordrowned Member

    Joined:
    Apr 22, 2021
    Messages:
    40
    Likes Received:
    2
    You could indeed use this instead of you want only all zombies

    Code (Text):
    1. Loop all zombies in radius x around player:
    2.  
    3. Loop all zombies in world "world":
     
  10. Craaft3r

    Craaft3r New Member

    Joined:
    Aug 6, 2022
    Messages:
    7
    Likes Received:
    0
    Optimal! So as not to make a cycle of all entities present in the world. Do you know how I can convert this vanilla to skript?

    Code (Text):
    1. console command "/particle glow_squid_ink %{_x}% %{_y}% %{_z}% 0.1 100 0.1 0 2500 force"
     
  11. mordrowned

    mordrowned Member

    Joined:
    Apr 22, 2021
    Messages:
    40
    Likes Received:
    2
    You can use the play particle effect.

    https://docs.skunity.com/syntax/search/visual effect


    Code (Text):
    1. set {_loc}'s x-pos to {_x}
    2. set {_loc}'s y-pos to {_y}
    3. set {_loc}'s z-pos to {_z}
    4. play 2500 GLOW SQUID INK with offset of 0.1, 100, 0.1 and speed 0 at {_loc}
    5.  
    If that doesn't work, let me know (I don't know how to do force/normal in skrip though)
     
  12. Craaft3r

    Craaft3r New Member

    Joined:
    Aug 6, 2022
    Messages:
    7
    Likes Received:
    0
    ok, it works also goes without "force" or "normal".

    mordrowned and JakeTheChad: thank you so much for the support!
     
  13. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
Thread Status:
Not open for further replies.

Share This Page

Loading...