Discord Thread getting a single specific armor stand in a radius

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

This thread came from the skUnity Discord. You can't reply to it here but if you join the skUnity Discord, you'll be able to post a reply there. The thread link is part of the thread's message.
Status
Not open for further replies.

skUnity Discord

Site Manager
Aug 5, 2023
12,755
0
0
The skUnity Discord
discord.gg
# a
is there anyway to get the closest armor stand with a differentiator e.g

-- get a armor stand with a certain nbt in radius 5 of entity
-- get a armor stand in a certain list in radius 5 of entity

i've tried
code_language.skript:
set {_t2} to nearest armor stand in radius 3 around entity
but from what i've tried i'm pretty sure you cant check for a differentiator with this,
ive also tried looping armor stands in a radius but i only want to get one out of all the armor stands in that radius
i've tried a lot more but i cant bother explaining each one rn

i've been at this for like 20 hours i feel so stupid ;-;

Posted by: inputmessage from the skUnity Discord. View the thread on skUnity Discord here
 
Just do it one at a time
code_language.skript:
if {_distance} is not set:
  set {_distance} to (distance between a and b)
if (distance between a and b) < {_distance}:
  set {_closest} to loop-entity 
  set {_distance} to (distance between a and b)

broadcast {_closest}

Posted by: x8ight from the skUnity Discord.
 
so like
code_language.skript:
                loop all armor stands in radius 3 of {_t}:
                    set {_value} to tag "custom;valueholder" of nbt of loop-value
                    if {_value} >= 0:
                        if {_distance} is not set:
                            set {_distance} to (distance between loop-entity and {_t})
                            set {_closest} to loop-entity 
                        else if (distance between loop-value and {_t}) < {_distance}:
                            set {_closest} to loop-entity 
                            set {_distance} to (distance between loop-entity and {_t})

Posted by: inputmessage from the skUnity Discord.
 
Since getting distance is taxing on the server, it'd be best to just retrieve it once
Not before the conditions it isn't
You set it inside the conditions for some reason
That means you retrieve the same distance twice per iteration

Posted by: theunderscore from the skUnity Discord.
 
How?
If you loop the entities and use
set {_entities::%distance between loop-value and player%} to loop-value
, it'll be sorted automatically
Just use
1st element or {_entities::*}
outside of the loop, and it's done
Note that I'm on my phone so apologies if I type slowly

Posted by: theunderscore from the skUnity Discord.
 
Bro
This line
Please read instructions
Now it'd be hilarious if put that line before the loop and complained it wasn't set lmfao
Now it'd be hilarious if you put that line before the loop and complained it wasn't set lmfao

Posted by: theunderscore from the skUnity Discord.
 
so like
code_language.skript:
                loop all armor stands in radius 3 of {_t}:
                    set {_value} to tag "custom;valueholder" of nbt of loop-value
                    if {_value} >= 0:
                        set {_entities::%distance between loop-value and {_t}%} to loop-value
                    set {_closest} to 1st element of {_entities::*}
wait ? im stupid
yeah i cant get this to work
i give up ;-;
literally been trying to do this for 2 days

Posted by: inputmessage from the skUnity Discord.
 
Your choice, but it's not that complicated of a problem so I don't get why you're not explaining it fully
"cant get this work" explains nothing, but if you wanna given up that's fine by me

Posted by: theunderscore from the skUnity Discord.
 
Status
Not open for further replies.