#item that allows you to control entity

1 messages · Page 1 of 1 (latest)

cosmic hinge
#

I'm creating an item that when used adds a selected tag to the nearest entity, but when I use it again near another entity it adds another target tag. The select entity is attracted by the target entity, I'm getting close to it using 2 commands (of course there are more things but they are not commands), But I'm having an error.

For this command to work it needs a small delay between them, I tried to make this small delay using triggers, when the item is used the test:select event is triggered

            "test:select": {
                "run_command": {
                    "command": [
                        "execute if entity @e[r=15, tag=!target, tag=!select] run tag @e[r=2, c=2] add select"
                    ]
                },
                "trigger": {
                    "event": "test:select_second"
                }
            },
            "test:select_second": {
                "run_command": {
                    "command": [
                        "execute if entity @e[r=15, tag=select] run execute at @e[r=2, tag=!select, tag=!target] run tag @e[r=2, c=2] add target"
                    ]

Commands


execute if entity @e[r=15, tag=!target, tag=!select] run tag @e[r=2, c=2] add select


Adds the *target* tag to an entity if the entity does not have the *select and target* tag and if one already exists with the *select* tag.

execute if entity @e[r=15, tag=select] run execute at @e[r=2, tag=!select, tag=!target] run tag @e[r=2, c=2] add target```

This is the problem I'm having:

[Json][error]-Syntax error: Unexpected "entity": at "xecute if >>entity<< @e[r=15, "

[Commands][error]-Command response could not compile commands
dry atlas
#

check to make sure over 1.19.5 to use new execute

Besides that what I see is...
if there is an entity that has neither tag within 15 blocks, tag the closest 2 within 2 blocks with select

same thing for target

not sure how that is supposed to work with tagging within 2 blocks with no confirmation of any being that close.

#

but overall, your execute statement is overcomplicated and can be simplified

cosmic hinge
cosmic hinge
dry atlas
#

so you want to make sure there are no other target/select entities around, first right?

#

But you do know that if there are 2 entities within 2 blocks of you that meet the criteria, it will tag both... I do not think that this is what you want

#

I assume that if this is an item, you can only do one at a time, correct

#

You post suggested this, but your code is trying to do it all at once

cosmic hinge
cosmic hinge
dry atlas
#

add family=!player

#

or if you will be selecting other players, add rm=0.5 that means outside of self position

#

It will not delay that way, this runs fast, all in one 1 tick, 1/2oth of a second

#

you would need to add it to a function that can do the delay for you.... but commands is fine to run right after one another, I do not see a problem with that, as it will do it in order

cosmic hinge
#

The delay uses ticks, right?

dry atlas
#

this would be hard to delay. would involve a whole scoreboard timer system that took over.. doable, but not simple, needs to be though out.

#

why do you think you need a delay?

#

your post initially said use the item again

#

so you should do that and the second time should do the other one if the 1st one exist and no second one exists

cosmic hinge
#

Because without it it didn't work properly

dry atlas
#

then your target and the other have to both be within 2 blocks of you and that doesn't sound like what you really want

#

execute unless entity @e[r=15, tag=target] unless entity @e[r=15,tag=select] at @s run tag @e[c=1,r=2,rm=1] add select

cosmic hinge
#

Because the commands needed to run on top of each other (I think) I decided to use command blocks instead of using commands in the player, but the commands will run in the player and not in command blocks (my god I'm getting confused)

dry atlas
#

then walk over to the other entity/person that is within 15 blocks of the select

#

execute if entity @e[r=15,tag=select] unless @e[r=15,tag=target] at @s run tag @e[c=1,r=2,rm=1] add target

#

but you said item how is that to work with a command block

#

I thought you are using a stick or somthing

#

if cmd blk a bit diff... I assume you want to put the block in the middle of an area..

#

if so, the frist one is fine, but the second one should pplay off of the entity with select

cosmic hinge
#

Yes I'm using item, but when I was testing I used command blocks it was faster than testing the mod, you have to download the new mod version all the time when you're creating mods using bridgev2

dry atlas
#

unless you need to work that way, use VSCode, work directly in the dev folders

#

or check to see if you can have the folders be there, can't imagine they make it that hard

cosmic hinge
#

I'm on Android, to put them in the development folders using the bridge you have to be on a pc

dry atlas
#

oh

#

how are you testing then....... like in a fenced in area, summon two pigs and press the button on the chain, to see if worked, tp the taged animals to another location

cosmic hinge
#

Exactly!

#

Putting the command on the item had this error

[Json][error]-Syntax error: Unexpected "entity": at "te unless >>entity<< @e[r=15, "

[Commands][error]-Command response could not compile commands

#

And the entity has not received any tag

dry atlas
#

run the command in chat to work out any syntax errors

#

but if the pack is getting it, then your format version in the item or the pack may be off

#

if it works in chat but not in the item

#

I tried it, it did not like the double unless had to add a buffer

#

execute unless entity @e[r=15, tag=target] as @s at @s run execute unless entity @e[r=15,tag=select] at @s run tag @e[c=1,r=2,rm=1] add select

#

that worked in chat... standing next to a cow

#

the double unless should have worked tho

#

for the second one... in chat.. this worked
execute if entity @e[r=15,tag=select] unless entity @e[r=15,tag=target] at @s run tag @e[c=1,r=2,rm=1] add target

#

I forgot the entity on the unless last time

#

for a command block test, obviously give more room, then r=2

#

unless the pen is real small

cosmic hinge
#

I went to see the error and changed a few things to make it work

/execute if entity @e[r=15,tag=select] unless entity @e[r=15,tag=target] at @e[r=2] run tag @e[c=1,r=2,rm=1] add target

So it must be something in the item itself?

dry atlas
#

okay, but is the 2nd entity within 2 blocks of the other, and technically you need the tag=select in that @e[r=2]

#

so you want the select entity to tag his target?

#

just saying at @e[r=2] is telling it to make all entities within 2 blocks of the command issuer to run the tag command

cosmic hinge
#

But isn't [c=1] preventing from more than one entity to be tagged?

dry atlas
#

not that part...

#

the middle one

#

before tag...

#

can be more than one

cosmic hinge
#

Oh i see

dry atlas
#

why did you change it from self

cosmic hinge
#

Did not work...

#

let me try again

dry atlas
#

if the command blocks is running it, it is the @s

#

if you are using the item, you are the @s

#

2 ways to go:

  1. you tag the select and the select tags his own target
  2. you tag the select, then you go tag the target separately.. tho make sure all within 15 blocks of you
cosmic hinge
#

Oh it works now...

#

It's the 2 I'm trying to do

dry atlas
#

maybe for now, add have to be sneaking for one of them

#

until can figure out how to do one at a time

cosmic hinge
#

oh my god that would be so much easier

dry atlas
#

so it would all be in a sequence, each in its one.. one no sneak, one with sneak

#

I gotta go, I will check back to see if you accomplished your goal

cosmic hinge
#

Its ok, thank you so much I was going crazy doing this alone!

cosmic hinge
#

Ok, I was thinking about how to make the command simpler and I did this


execute at @e[tag=!select,r=2,c=1,family=!player] run tag @s add target```

I took advantage of the way to detect whether the player is crouching or not to switch between commands.

But something is wrong, the command in the chat works, but when I use the item to run the command this error happens:

```[Json][error]-Syntax error: Unexpected "@e": at "xecute as >>@e<<[tag=!targ"

[Commands][error]-Command response could not compile commands```
dry atlas
#

which one is it? and take off the slash

#

oh do as @e

cosmic hinge
#

Oh the slash is not in the actual command, for some reason i put it there

dry atlas
#

what is the format version of the file?

cosmic hinge
#

the item is 1.16.100

dry atlas
#

have to be 1.19.50 or higher... I said it a few times

#

can't use new execute in less than that

cosmic hinge
#

Oh I thought you were talking about the manifest

dry atlas
#

well that too, lol, but the item/block/entity.. anywhere with the run command and new execute

cosmic hinge
#

Got it

#

I will try again

dry atlas
#

if you need 1.16.1`00 just write it the old way

#

just but the selector in the tag statement, did not need the execute technically

#

tag @e[tag=!target,r=2,c=1,family=!player] add select

#

people have been over complicating I notice.... simple works when it is not complicated with multuple entites and score/block testing and and or... execute if you need more depth

#

nite

cosmic hinge
#

Now it doesn't give any error, but it doesn't add the tag?

#

oh now it works