Deleted an 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.
G

Goetheus

Hi guys!

I would like to delete (and not kill) an entity.
Before updates, I used this, i.e. :

code_language.skript:
set {_entity} to target entity
delete entity from {_entity}

Now, this syntaxe don't work. How can I proceed?

I noticed that syntaxe works :
code_language.skript:
delete loop-entity

But not these :
code_language.skript:
delete targeted entity
delete target entity
delete target

Thank you for help!
 
Deleting an entity makes it disappear immediately.

Killing an entity makes it drop the items, perform the death animation and play cloud particles effect when the animation is done.
 
What's the difference for you ?
When you kill an entity, there are animation, sounds and drop items.
When you delete an entity, it disappear instantly without animation, sounds or drop.

EDIT : Oops, too slow ^^'
[doublepost=1487802668,1487783913][/doublepost]Hi guys!

I noticed that "kill target entity" = "delete target entity" O_o

I'm in 1.11.2 with Umbaska, Skellett, SkStuff, SharpSk, SkRayFall, MundoSk, SkQuery, skUtilities, and TuSke.
Before, it was different, and today "delete target entity" generate an error in console...

So ! For now, I would like to know how to really kill an entity (with animation, drops...).

Thank you!

EDIT 2 or 3, I don't know :
When you write this:
code_language.skript:
set {_entity} to target
Kill {_entity}
The entity is killed (animation + drop).

The problem is, if you write this:
code_language.skript:
set {_entity} to target
delete {_entity}
Nothing happen...

Help me :'(
 
Last edited by a moderator:
I'm not sure that this is the best solution but I went ahead and came up with a ghetto fix I suppose, it does require SkStuff for nbt but I see you have it, I haven't tested it but I have a variation of this on my server so I'm pretty sure it works as I only changed a few things, also I did get a little confused as to what it is you want after reading the rest of your posts but assuming you still want what you wrote in the original post the following should be a solution

code_language.skript:
function despawnentity(e: entity):
  add "{NoDrops:1}" to nbt of {_e}
  teleport {_e} 1000 blocks above {_e}
  wait 1 tick
  kill {_e}
On death:
  if tag "NoDrops" of nbt of victim is 1:
    clear drops

EDIT:
I've tested it using the following code and it works like a charm:
code_language.skript:
on right click on entity:
  despawnentity(clicked entity)
Edit 2:
Oh gawd, something is wrong, after some more testing I found out the drops are not being cleared, this must be something to do with the nbt aspect of the code, looking into it...
Edit 3:
Okay I think the problem is that you can't add custom nbt to an entity, I know SkStuff has something to add custom nbt to an item so I just figured it would work on an entity too but I guess not, the reason the variation of code I use on my server works is because I'm not adding custom nbt to the entity instead I add "{CustomNameVisible:1}" to nbt of entity which is a real nbt tag, what that tag does is so that an animal's name will show above its head regardless of whether you're looking at it or not, here is the updated code with that tag
code_language.skript:
function despawnentity(e: entity):
  teleport {_e} 1000 blocks above {_e}
  add "{CustomNameVisible:1}" to nbt of {_e}
  wait 1 tick
  kill {_e}
On death:
  if tag "CustomNameVisible" of nbt of victim is 1:
    clear drops
 
Last edited by a moderator:
I'm not sure that this is the best solution but I went ahead and came up with a ghetto fix I suppose, it does require SkStuff for nbt but I see you have it, I haven't tested it but I have a variation of this on my server so I'm pretty sure it works as I only changed a few things, also I did get a little confused as to what it is you want after reading the rest of your posts but assuming you still want what you wrote in the original post the following should be a solution

code_language.skript:
function despawnentity(e: entity):
  add "{NoDrops:1}" to nbt of {_e}
  teleport {_e} 1000 blocks above {_e}
  wait 1 tick
  kill {_e}
On death:
  if tag "NoDrops" of nbt of victim is 1:
    clear drops

EDIT:
I've tested it using the following code and it works like a charm:
code_language.skript:
on right click on entity:
  despawnentity(clicked entity)
Edit 2:
Oh gawd, something is wrong, after some more testing I found out the drops are not being cleared, this must be something to do with the nbt aspect of the code, looking into it...
Edit 3:
Okay I think the problem is that you can't add custom nbt to an entity, I know SkStuff has something to add custom nbt to an item so I just figured it would work on an entity too but I guess not, the reason the variation of code I use on my server works is because I'm not adding custom nbt to the entity instead I add "{CustomNameVisible:1}" to nbt of entity which is a real nbt tag, what that tag does is so that an animal's name will show above its head regardless of whether you're looking at it or not, here is the updated code with that tag
code_language.skript:
function despawnentity(e: entity):
  teleport {_e} 1000 blocks above {_e}
  add "{CustomNameVisible:1}" to nbt of {_e}
  wait 1 tick
  kill {_e}
On death:
  if tag "CustomNameVisible" of nbt of victim is 1:
    clear drops

Interesting workaround! Thank you!

Was so simply before the update with two lines...
Why they change it?! :'(
 
Nothing was changed in Skript.

The "entity from %variable%" thing was from Umbaska 2

It is intended for the following code to not delete the entity itself:
code_language.skript:
on something:
  set {_entity} to event-entity
  delete {_entity}

Skript will delete the variable, not the entity that is contained in the variable.
 
Status
Not open for further replies.