#what are the easiest ways to have entities run commands?

1 messages · Page 1 of 1 (latest)

dim zealot
#

animation controllers have a guide, run_command as an event response doesn't have one as far as I've found. Are there any other ways to have an entity execute a command or run a function?

I'm trying to have an enderman teleport entities via spreadplayers if it helps, but learning how I can call commands is important too

graceful mantle
#

You can just create events inside the entity and call them on the entity via the event entity command And those events can run command

#

How you do this depends upon your imagination. You can even have the enderman run a random timer and run the event, or use the entity sensor component and when close to a certain kind, run the event.

#

There the environment sensor too

dim zealot
#

from what the wiki says, the event entity command activates an entity event via a command. I'm looking to do the opposite, activating a command via an event

graceful mantle
#

This site should become your best friend...https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/componentlist

Just read any thing that catches your eye and play with it. See how they use it in the vanilla packs. They usually list the vanilla mobs that use the component with a link to the code.

Some things are not used that much, but you can always do a search on the wiki or in this discord to see how others have used it or get advice

#

And you will want to learn how to use the Filters, it is the section above components. Plenty of examples in the vanilla pack. Well the whole Entity JSON section....... Triggers and Built-in events...

dim zealot
# graceful mantle command is ONE way... I listed the others... entity_sensor environment_sensor ...

I'm not sure if I'm communicating my question clearly enough. The event entity command activates an event, the entity sensor activates and event, the environment sensor activates an event, etc. The things you listed are all how to call events. My question is how to run a command using an event, for example, using an entity sensor, or timer, or environment sensor to call eventX, an event that runs the "say test" command. The problem I'm having is making eventX run the "say test" command. I couldn't find the syntax for the run_command event response and the only guide I found uses animation controllers to run commands. Do you know the syntax to make an event that runs the "say test" command whenever any sensor or event trigger calls the event, or any alternative ways to run a command from an entity or entity event?

I apologize for the confusion, and appreciate your help.

graceful mantle
#

Example...json "ev:test": { "sequence": [ { "run_command": {"command":[ "tag @a remove TestHello", "tag @a add TestHello", "tell @a[tag=TestHello] §6Well Hey There YOU!!! Whatcha Doin'?", "tag @a remove TestHello" ]} }, {"add":{"component_groups":["cg:despawn"]}} ] }

#

Try searching this discord for command and you will find plenty of examples if you had searched for "run_command" it would come up

#

always use the double quotes to eliminate bad matches...

dim zealot
#

It didn't occur to me to search for syntax. Thank you for the help!

graceful mantle
#

The command is the same across blocks, items, entities

#

I did not include the target, self because it is default... so if you need it to be on OTHER, you have to include the target, if it makes sense to use

dim zealot
#

I got it to work! Thank you!