#Help with naming summon entities

1 messages · Page 1 of 1 (latest)

radiant yacht
#

Are you looking for something like this also don't mind the error spamming it happened because the player was not on the scoreboard also just to let you know this will affect all entities of the type that is set however to bypass this i can set a max distance of 2 blocks if you would like @zenith thunder

#

and this also works in stable version of the scripting API meaning no need to turn on experimental toggles

#

That's fine just so you know in the if statement is currently set for a cow but you can just change it to player or you could even use player name to specify a name of a player if you want instead of type ID

#

Also do you want me to limit the range of it so that it doesn't affect all entities of that type in the world

#

Because currently it doesn't have a limited range

#

Yeah because you can actually specify entities with certain tags as well

#

I'll put in a tag as an example so that you know how to do it for yourself

#

Is this only going to be for players or is this going to be for entities as well

#

Because you can just set it for specifically players if you want

#

Alright ok

#
import { system, world } from '@minecraft/server'

system.runInterval(() => {
    for (const Player of world.getPlayers()) {
        for (const Entity of Player.dimension.getEntities()) {
            const Scoreboard = world.scoreboard
            if (Entity.typeId === "minecraft:cow" && Entity.hasTag("name of your tag goes here") && Scoreboard?.getObjective("test")?.getScore(Player) == 10) {
                Entity.nameTag = Player.name
            }
        }
    }
})```
#

here you go

#

And if you want to make multiple entities just copy the if statement

#

By the way now that I've added that entity has tagged what's in the brackets is what you have to tag the entity so before you test it make sure to tag the entity with that tag

#

Yes it runs every tick so that it updates whenever the entity spawns

#

Or whenever the player actually hits the desired score

#

Yes you can

#

But before the 20 you need to put a comma

#

,20

#

Like that

#

Hold on I'm trying it now

#

Are you going to be adding these entities in via command to the scoreboard

#

Just tell me the proposal here because you can always just close this post after you're done so nobody needs to see it

#

There's no need for that if you make a post and if I see it I will help you out with it there are plenty of others that here as well who are willing to help you and as for the whole time thing and being paid for this I don't do this to be paid I do this to help people because I enjoy it and the time you don't have to worry about if I see that I can't complete something on the day I will tell you and I'll try and complete it on the next day so don't worry about that so there's no need payment

#

Also I can't seem to get the comparison to work but away you could go around it as you could give an entity a tag when they hit a specific score and compare it that way because when you add an entity via a command it uses its entity ID and for some reason even though I'm telling the script to use entity ID it's using the wrong thing

#

But as I've mentioned that can be worked around with a tag

#

No never mind sorry I forgot completely I added the tag thing let me just take that out and try it again

#

Ok I'm just tested it We're gonna have to go with the tag instead because of the fact that it just doesn't want to get the entity ID

#

You can select in the target selector scores so it should be possible

#

This is going to be a problem either way you look at it because even with tags they're fixed unless you remove them and then add a new one and there's even a limited number of tags that can be added to an entity because in the past I have messed with comparing scores I've always used the entity type ID which you cannot add with a command that's only something you can do with a script

#

Yeah I suppose you could do it like that as long as you remember to remove the tags when they exceed the score so that you don't have too many tags and then the system break

#

But anyway you've just given me something new to work on anyway because I need to figure out why the entity ID thing isn't working

#

I also limited the detection range for the entities to be 10 blocks max distance but you can change it if you want

#

You can even add in there specific tags you wanted to look at and or families you wanted to exclude there's lots of things

#

The 10 block limiter is just the range at which the script will retrieve the entities in the area

#

But you can change it so don't worry about that

#

It's just so that it doesn't get entities from the entire world you know

#

There's no point in getting entities from the entire world unless you limit it to a specific type of entity that you want it to get which you can do as well with just a type

#

Well you can change it at any time to whatever range you want

#

Yes it is but you can just change the script before you input it into the world to whatever range you want

#

Sorry my bad miss phrasing

#
Player.dimension.getEntities({ maxDistance: 10 })```
#

Then that will set a max distance for the script to look at and in there you can even set a type families tags exclude tags

#

I recommend looking at the entity query options inside of the documentation

#

You've got an extra set of brackets in there

#

You can just copy and paste the message I sent you and just highlight over the player dimension get entities and just replace it if you want

#

Instead of having to worry about the extra brackets

#

Yep looks right

#

But I would test it just in case but it should be fine

#

Sorry I couldn't get the scoreboard comparison to work I'm still learning scoreboards in scripts myself because I'm still learning scripts in general I am nowhere near an expert

#

I thought you were going to delete this post after you had solved it

#

Because didn't you say that before you sent the whole proposal