#what are the easiest ways to have entities run commands?
1 messages · Page 1 of 1 (latest)
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
how do I include the command as part of the event? using run_command?
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
command is ONE way... I listed the others...
entity_sensor
environment_sensor
timer
scheduler
any component that can activate an event. Like I said depends on you imagine this working.
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...
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.
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...
It didn't occur to me to search for syntax. Thank you for the help!
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
I got it to work! Thank you!