SkriptLang / Skript

Skript is a Spigot plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
https://docs.skriptlang.org
GNU General Public License v3.0
1.08k stars 373 forks source link

Referencing entities #461

Closed Remixful closed 6 years ago

Remixful commented 7 years ago

I'm trying to find the best way to reference entities for future use (in a global list). Simply adding the entity to a list will just end up null in the variables file. Can anyone give me some ideas on how to achieve this?

Tuke-Nuke commented 7 years ago

Well, since the entity is spawned everytime the server init (or a word init), you would want to store the uuid when the server shutdown and when the server starts again, you search all entities with given uuid. Like

on skript unload:
    loop {AllEntities::*}:
        add uuid of loop-value to {AllEntitiesUUID::*}
    clear {AllEntities::*}
on skript load:
    wait a tick
    loop all entities:
        loop {AllEntitiesUUID::*}:
            if uuid of loop-entity-1 is loop-value-2:
                add loop-entity-1 to {AllEntities::*}
    clear {AllEntitiesUUID::*}
Remixful commented 7 years ago

I've already tried UUID of entity before posting this and I just assumed it only existed for players since it returns none.

image

    loop all entities:
        broadcast "%uuid of loop-value% %loop-value%"

Though the pattern stated in http://bensku.github.io/Skript/expressions.html is:

[the] UUID of %entities/offlineplayers/worlds%

Tuke-Nuke commented 7 years ago

Do you have the latest build of Skript?

Remixful commented 7 years ago

image

I just updated spigot but I doubt that means anything. I am using 1.11.2 by the way.

image Plugins

TheBentoBox commented 7 years ago

I also no longer seem to be able to retrieve entity UUIDs, even just looking at one and running send "%uuid of target%" as an effect command is now returning "<none>".

As a temporary solution, I can use entity uuid of %entity%, which is from an addon (not sure which because the only one that has that syntax registered in the skUnity docs is Umbaska, which I don't have installed). You have basically all of the same addons as I do, though, so you probably have that expression available to you as well.

Remixful commented 7 years ago

Thank you so much @TheBentoBox! entity uuid of %entity% works great. The UUID even remains the same after restarting the server.

Syst3ms commented 7 years ago

@TheBentoBox It's Skellett's actually. But it's a shame it's not working in vanilla Skript.

TheBentoBox commented 7 years ago

No problem @Remixful, glad it's working. I figured it might be Skellett's, since that expression also used to be in RandomSK, which Lime has been trying to entirely port into Skellett. But yeah, it should be fixed here too, it's definitely not working at the moment as far as I can tell.

Tuke-Nuke commented 7 years ago

@Syst3ms It was working when I sent it to Skript, I also made a tons of checking to make sure it was working when using a variable. I will need to check again if it wasn't a bug somewhere else

bensku commented 7 years ago

UUID of entity expression stopped working, because enabling it broke offline player UUIDs. They both cannot work until an old parser issue (has been there for at least a year) is fixed.

TheBentoBox commented 7 years ago

Maybe change the expression to not use the same syntax? Instead of just being uuid of %entity/player/world%, it could be entity uuid of %entity% like in some addons. That way it wouldn't conflict with the current syntax.

Snow-Pyon commented 6 years ago

Not sure when, but this was fixed (tested).

bensku commented 6 years ago

@Snow-Pyon dev30 fixed the parser bug, I think it was that.