Solved id of entity?

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

NewbyZ

Member
Jan 26, 2017
75
2
0
25
Any way to know the id (or uuid) of an entity?
%id of entity% changes when chunk is unloaded...

The purpose of this is to be able to detect at any time that particular entity
 
Last edited:
I believe Umbaska has an Entity UUID expression; however, I don't know how/if it works, as I've never used it.

However, I've never used it before, and I'm not entire sure if Umbaska is still a thing?
[doublepost=1500627649,1500622449][/doublepost]You could also do something like this with Skript-mirror:

code_language.skript:
function getUUID(e: entity) :: text:
    return "%{_e}.getUniqueId()%"

command /entityID:
    trigger:
        message "%getUUID(target entity)%"

on script load:
    import "java.util.UUID"
 
  • Like
Reactions: NewbyZ
I believe Umbaska has an Entity UUID expression; however, I don't know how/if it works, as I've never used it.

However, I've never used it before, and I'm not entire sure if Umbaska is still a thing?
[doublepost=1500627649,1500622449][/doublepost]You could also do something like this with Skript-mirror:

code_language.skript:
function getUUID(e: entity) :: text:
    return "%{_e}.getUniqueId()%"

command /entityID:
    trigger:
        message "%getUUID(target entity)%"

on script load:
    import "java.util.UUID"

How could I use this?

Example:
code_language.skript:
spawn armor stand at player's location
set {_a} to spawned entity

How can I make that {_a} detect it as uuid?

If I do while {_a} exists:

At the moment when the chunk where {_a} is unloaded, that entity no longer exists but is still there.

I hope you have understood me
 
How could I use this?

Example:
code_language.skript:
spawn armor stand at player's location
set {_a} to spawned entity

How can I make that {_a} detect it as uuid?

If I do while {_a} exists:

At the moment when the chunk where {_a} is unloaded, that entity no longer exists but is still there.

I hope you have understood me

I think I understand; so you want to use the entity's uuid to save it, then also get the entity from the uuid previously saved.

Now, according to this, there is no built in function to return an entity from a uuid; however, we can work around that via loops:

code_language.skript:
function getUUID(e: entity) :: text:
    return "%{_e}.getUniqueId()%"
 
function getEntity(uuid: text) :: entity:
    loop all entities where ["%getUUID(entity input)%" contains "%{_uuid}%"]:
        return loop-entity
    return null

command /entityID:
    trigger:
        set {_uuid} to getUUID(target entity)
        set {_entity} to getEntity({_uuid})
        broadcast "%{_entity}%"
 
on script load:
    import "java.util.UUID"

I added a function called "getEntity", which, given a uuid, will return an entity.
 
Last edited by a moderator:
  • Like
Reactions: NewbyZ
I think I understand; so you want to use the entity's uuid to save it, then also get the entity from the uuid previously saved.

Now, according to this, there is no built in function to return an entity from a uuid; however, we can work around that via loops:

code_language.skript:
function getUUID(e: entity) :: text:
    return "%{_e}.getUniqueId()%"
 
function getEntity(uuid: text) :: entity:
    loop all entities where ["%getUUID(entity input)%" contains "%{_uuid}%"]:
        return loop-entity

command /entityID:
    trigger:
        set {_uuid} to getUUID(target entity)
        set {_entity} to getEntity({_uuid})
        broadcast "%{_entity}%"
 
on script load:
    import "java.util.UUID"

I added a function called "getEntity", which, given a uuid, will return an entity.

Thanks!!
 
I think I understand; so you want to use the entity's uuid to save it, then also get the entity from the uuid previously saved.

Now, according to this, there is no built in function to return an entity from a uuid; however, we can work around that via loops:

code_language.skript:
function getUUID(e: entity) :: text:
    return "%{_e}.getUniqueId()%"
 
function getEntity(uuid: text) :: entity:
    loop all entities where ["%getUUID(entity input)%" contains "%{_uuid}%"]:
        return loop-entity
    return null

command /entityID:
    trigger:
        set {_uuid} to getUUID(target entity)
        set {_entity} to getEntity({_uuid})
        broadcast "%{_entity}%"
 
on script load:
    import "java.util.UUID"

I added a function called "getEntity", which, given a uuid, will return an entity.
lol vanilla skript can do entity uuids.
 
lol vanilla skript can do entity uuids.

Can you give me an example of the syntax? I couldn't find anything in the docs about it.
[doublepost=1500686484,1500684356][/doublepost]
lol vanilla skript can do entity uuids.

I saw SkUnity's UUID expression that does not state spawnable entities as a valid input, and I assumed Skript did't have the expression for spawnable entities.

In addition, I saw the same expression on Bensku's Fork's docs, but it returned null using the following example:

code_language.skript:
command /entityID:
    trigger:
        broadcast "%uuid of target entity%" # returns null
 
Can you give me an example of the syntax? I couldn't find anything in the docs about it.
[doublepost=1500686484,1500684356][/doublepost]

I saw SkUnity's UUID expression that does not state spawnable entities as a valid input, and I assumed Skript did't have the expression for spawnable entities.

In addition, I saw the same expression on Bensku's Fork's docs, but it returned null using the following example:

code_language.skript:
command /entityID:
    trigger:
        broadcast "%uuid of target entity%" # returns null
https://github.com/bensku/Skript/pull/373
 
Don't work :emoji_frowning:
0a7eb453dcbbecbfeaa1132e5dc4bed7.png
 
Status
Not open for further replies.