#how to detect when you lost your totem and then message:"you lost your totem" appear

1 messages Β· Page 1 of 1 (latest)

hollow harness
#

πŸ‘†

tulip sphinx
#

/execute as @a[hasitem={item=totem}] at @s run /tag @s add TotemOwning /execute as @a[tag=TotemOwning] at @s unless entity @s[hasitem={item=totem}] run /msg @s you lost your totem /execute as @a at @s unless entity @s[hasitem={item=totem}] run /tag @s remove TotemOwning

#

I think that should work

idle plinth
#

/tag @a[hasitem={item=totem}] add totem
/msg @a[tag=totem,hasitem={item=totem,quantity=0}] you lost your totem
/tag @a[tag=totem,hasitem={item=totem,quantity=0}] remove totem

tulip sphinx
#

Ooo i never thought of hasitem that way before

#

🀩

idle plinth
#

Both cmds will work you can choose any of these @hollow harness

hollow harness
tulip sphinx
#

Without a totem yes

idle plinth
#

You want title?

hollow harness
#

wdym whitouth a totem

hollow harness
idle plinth
hollow harness
#

and if i want to add colors to the msj how?

idle plinth
#

Β§

tulip sphinx
#

Β§3

#

Β§d

#

Etc

idle plinth
#

No k

hollow harness
#

Oow i know how now

tulip sphinx
#

Yeah Β§k SUCKS

hollow harness
#

How can i be better at commands like you guys

#

function

tulip sphinx
#

Also CAPS don't work

tulip sphinx
#

My skills are dying off πŸ’€

idle plinth
#

l- bold
o- latin
f- white [normal chat colour]
r- reset all the colours and effect

tulip sphinx
#

f is actually only slightly different color

idle plinth
#

Any other small letters, numbers are colour

tulip sphinx
#

Also you can use Β§β™‘ to get specials

idle plinth
#

k- for hiding your chat that you types

hollow harness
hollow harness
#

What if i want this messaje detect any player lost his totem and detect his name and then mssj apear his name lost totem i think is impossible

tulip sphinx
#

/execute as @a[tag=TotemOwning] at @s unless entity @s[hasitem={item=totem}] run /msg @s @s you lost your totem

#

I think that works?

#

If not use tellraw

#

And a selector

hollow harness
#

okey I will try it and see if it work

tulip sphinx
#

It should work tho

#

Kk

tulip sphinx
#

Woohoo! Self confidence boost πŸ₯³

#

Wait i hate those 😫😫😫

hollow harness
# tulip sphinx Kk

Like this on functions tag @s add TotemOwning
execute as @a[tag=TotemOwning] at @s unless entity @s[hasitem={item=totem}] run msg @s @s you lost your totem
tag @a[tag=totem,hasitem={item=totem,quantity=0}] remove totem

#

Sorry im noob

tulip sphinx
#

Sorry i don't do functions πŸ˜…

hollow harness
#

ow so this just for commands

tulip sphinx
#

It might be for functions yet idk

tulip sphinx
hollow harness
#

I think I have to give it a try

tulip sphinx
#

Ask adish he's really good w commands

hollow harness
tulip sphinx
#

This is awkward πŸ˜‚

hollow harness
#

whyyy

tulip sphinx
#

Its just us waiting for someone and were alone in a post awkwardly talking

hollow harness
#

why you Think like that πŸ˜‚ its normaaale

tulip sphinx
#

Think about it

hollow harness
idle plinth
tulip sphinx
#

Phew also sorry for pinging you πŸ˜…

idle plinth
#

Am in another work

#

Messing with npc

#

πŸ˜…

tulip sphinx
idle plinth
#

NPC can be used as one time function script

#

Aka you can use them as a long cmd into short one!

tulip sphinx
#

Well they kinda only do 5 per npc πŸ’€

idle plinth
tulip sphinx
#

Although i guess you could use the last command to run another npc

idle plinth
#

I think You can write 300 words in npc

tulip sphinx
idle plinth
#

So if the length of the cmd is short then 1 section will contain about 30 cmd

idle plinth
#

In first cmd use /tp @s ~ -200~
Then other cmd

#

It will be act like function

#

I can give you the example after finishing the work πŸ™ƒ

hollow harness
#

I have a question this command execute as @a[scores={Energy=1..100}] run particle ds:reversal4~~~ I think you understand what if i want to create a function to remove that particle for working and another for make it run again is that possible I think I have to use tags?

hollow harness
idle plinth
#

Using /scoreboard players remove @a <score> 1
Will decrease the value 1 to 100

#

So you can use this as a timer

hollow harness
#

so like this tag @s add TotemOwning
execute as @a[tag=TotemOwning] at @s unless entity @s[hasitem={item=totem}] run msg @s @s you lost your totem
tag @a[tag=totem,hasitem={item=totem,quantity=0}] remove totem it doesnt work @tulip sphinx

tulip sphinx
#

As i said im not the best 🀣

#

Im not even decent anymore πŸ’€

golden hinge
#

How is that function being run? Just placed in tick.json?

idle plinth
#

I will be back am in a trouble with another guy [cmd] πŸ˜…

hollow harness
hollow harness
hollow harness
hollow harness
tulip sphinx
#

You need a command block to run the function

#

Btw

golden hinge
#

Those commands won't work how you want. The result is receiving that message every tick when no totem is in the inventory

tulip sphinx
#

No bc its based off a tag that is guven to those that had a totem

golden hinge
#

TotemOwning is granted unconditionally to every player at the start. Even if the tag is removed at the end of the tick, it will be applied again before the other logic.

tulip sphinx
#

Im confused now πŸ’€

#

So it works as a command but not a function?

golden hinge
#

You'll want to compare across ticks, seeing if the player had a totem in their hand. (This won't actually tell if the totem was used, just if the player lost the item in that slot. Moving it or dropping it will trigger the effect too.)

execute as @a[tag=holdTotem] unless entity @s[hasitem={item=totem,location=slot.weapon.mainhand}] run msg @s No longer holding a totem!
tag @a remove holdTotem
tag @a[hasitem={item=totem,location=slot.weapon.mainhand}] add holdTotem
golden hinge
# tulip sphinx Im confused now πŸ’€

What I sent works much the same as your did, but the order of commands is important. We need the tag application to occur last, so that the player's inventory can change between ticks. We can detect that change with hasitem

hollow harness
#

@tulip sphinx

golden hinge
#

Either. You can paste that text block into a single function, or place each individual command into three command blocks

tulip sphinx
#

Why tho? No space for 3 command blocks?

golden hinge
#

Functions are generally more convenient and powerful.

tulip sphinx
#

Pshh more limited too

#

Oh wait thats script im thinking of πŸ€¦β€β™‚οΈ

golden hinge
#

Admittedly functions are trickier to hook into the world on their own, but one can always combine command blocks and functions to great effect

tulip sphinx
#

Well ig not most people can make a function so that limits its diversity too Β―_(ツ)_/Β―

golden hinge
#

Lots of people tend to neglect that fact.

tulip sphinx
#

Yeah tbh i love doing commands over functions A i can't use functions πŸ’€ and B i love how much more knowledge is given and that interactive puzzle solving flair in commands

golden hinge
#

You opted to do a function, right? We can troubleshoot that

#
  • Did you reload your changes? Restarting the game or with /reload
  • Did you save your changes to the function?
  • Is your function being invoked? Try putting a simple command inside like say hi
  • Is your behavior pack applied?
tulip sphinx
#

That is a goated command tho ngl i just wish it was for commands too 😭

#

And the rest of the game at that 😭

hollow harness
golden hinge
#

Can you post your pack structure here? A screenshot would work. I want to see where your function and tick.json are in relation to each other

#

Should be like this:

πŸ“‚ BP
πŸ“‚ fuctions
πŸ“„ tick.json
πŸ“„ myfunction.mcfunction

//tick.json
{
  "values": [
    "myfunction"
  ]
}
tulip sphinx
#

HISSS COM.MOJANG FILES

tulip sphinx
#

Armor health!?

#

You can test that vanilla πŸ’€

#

Player health tho nsm πŸ’€πŸ˜­

hollow harness
#

no I was looking to make armor health to a specific armor I made it but I switched to script and now im lazzy to rename

tulip sphinx
#

Oh like custom armor?

#

Bc every vanilla armor has health πŸ˜…

hollow harness
#

Oh yeah custom armor

tulip sphinx
#

Did it have durability?

#

Like could it break?

hollow harness
#

Yess

tulip sphinx
#

Then theres armor health πŸ’€πŸ’€πŸ’€

golden hinge
hollow harness
#

armor_health1

tulip sphinx
#

/execute at @a[hasitem={item=customArmor,data=(armor health)] run

hollow harness
golden hinge
#

That would be great

tulip sphinx
#

Data= is the durability values

#

For armor

hollow harness
tulip sphinx
#

/effect @a[hasitem={item=CustomArmor,data=1}] (effect)

hollow harness
#

@golden hinge

golden hinge
#

Sorry, nevermindβ€”it's in there. But it's placed wrong

#

The tag @a[...] add holdTotem command needs to be at the end of the function. The command order is very specific

hollow harness
golden hinge
#

Place the commands exactly as I had them and it should work.

tulip sphinx
hollow harness
tulip sphinx
#

You do you then Β―_(ツ)_/Β―

hollow harness
golden hinge
#

Oh, that's the off-hand. We need more logic to handle that

#

Probably not the most elegant solution, but try this:

execute as @a[tag=holdTotemMainhand] unless entity @s[hasitem={item=totem,location=slot.weapon.mainhand}] run msg @s No longer holding a totem!
execute as @a[tag=holdTotemOffhand] unless entity @s[hasitem={item=totem,location=slot.weapon.offhand}] run msg @s No longer holding a totem!
tag @a remove holdTotemMainhand
tag @a remove holdTotemOffhand
tag @a[hasitem={item=totem,location=slot.weapon.mainhand}] add holdTotemMainhand
tag @a[hasitem={item=totem,location=slot.weapon.offhand}] add holdTotemOffhand
hollow harness
#

I want it directly not steve whispers to you

#

@golden hinge

golden hinge
#

You can change the /msg command to whatever you need it to be. e.g. /tellraw

#

If you need more complex logic, you could invoke another function from there instead. @s will be the player who lost the totem from their hand

hollow harness
reef pecan
hollow harness
hollow harness
# reef pecan All good?

Is there any problem here again function file not found in tick.json execute as @a[tag=holdTotemMainhand] unless entity @s[hasitem={item=totem,location=slot.weapon.mainhand}] run tellraw @s No longer holding a totem! tag @a remove holdTotemMainhand tag @a remove holdTotemOffhand tag @a[hasitem={item=totem,location=slot.weapon.mainhand}] add holdTotemMainhand tag @a[hasitem={item=totem,location=slot.weapon.offhand}] add holdTotemOffhand

#

@golden hinge

golden hinge
#

Yea, that is invalid syntax for /tellraw. The command expects JSON in a very specific format.
https://minecraft.wiki/w/Raw_JSON_text_format#Bedrock_Edition

Minecraft Wiki

Raw JSON text is the format Minecraft uses to send and display rich text to players. It can also be sent by players themselves using commands and data packs. Raw JSON text is written in JSON, a human-readable data format.

#

e.g.

tellraw @a {"rawtext":[{"text":"No longer holding a totem!"}]}
reef pecan
#

For some reason this doesn't work for him
/tag @e[type=player,hasitem={item=totem_of_undying,location=slot.weapon.offhand,quantity=0}] add z

/tag @e[type=player,hasitem={item=totem_of_undying,location=slot.weapon.offhand}] remove z

/execute if entity @e[type=player,hasitem={item=totem_of_undying, quantity=0,location=slot.weapon.offhand}] run /tellraw yourname {"rawtext":[{"selector":"@e[type=player,tag=!z,hasitem={item=totem_of_undying,location=slot.weapon.offhand,quantity=0}]"},{"text":" Has used up a totem"}]}

#

Any ideas why?

hollow harness
reef pecan
reef pecan
golden hinge
reef pecan
#

Let me do some testing brb

reef pecan
#

Ok so I fixed the logic up a little, basically what it should do is first it'll announce to everyone that a person without the tag of z (to prevent spamming) who has no totem in their offhand it'll send a tellraw, afterwards it'll tag them with z (people without totems)

#

And without the tag, yet it still continues spamming despite me having the tag z

hollow harness
reef pecan
#

I knew the execute was at fault

#

The tellraw is going to run with spaces where the selector is supposed to go anyways

#

I added the execute if

reef pecan
#

/execute if entity @e[type=player,tag=!z,hasitem={item=totem_of_undying, quantity=0,location=slot.weapon.offhand}] run /tellraw @a {"rawtext":[{"selector":"@e[type=player,tag=!z,hasitem={item=totem_of_undying,location=slot.weapon.offhand,quantity=0}]"},{"text":" Has used up a totem"}]}

/tag @e[type=player,hasitem={item=totem_of_undying,location=slot.weapon.offhand,quantity=0}] add z

/tag @e[type=player,hasitem={item=totem_of_undying,location=slot.weapon.offhand}] remove z
Ok put these in separate function files @hollow harness

#

Tick magic for the win baby

hollow harness
#

Its working now

#

I want name with color red is it possible

#

@reef pecan

earnest marsh
# hollow harness I want name with color red is it possible

Add a "text" and use the Β§4 before the selector in the raw json. Add Β§r to clear the color and format before the last "text"

execute if entity @e[type=player, tag=!z, hasitem={item=totem_of_undying,  quantity=0, location=slot.weapon.offhand}] run tellraw @a {"rawtext":[{"text":"Β§4"}, {"selector":"@e[type=player,tag=!z, hasitem={item=totem_of_undying, location=slot.weapon.offhand, quantity=0}]"}, {"text":"Β§r Has used up a totem"}]}
reef pecan
#

But we bedrock players have it good, at least we don't have to do {"color":"red"} like java players (prob incorrect syntax but you get the point)

hollow harness
#

Working yay tyssm guys

reef pecan
hollow harness
#

When you enter it also detects that you spent one

#

And once you death not detect also

#

@earnest marsh @reef pecan

reef pecan
#

I don't think players would just be holding totems in their main hand

#

Atp it would be pointless to have any armor or anything like that

#

Mittens could probably help you making it the way you want, currently busy right now and can't test anything

hollow harness
reef pecan
earnest marsh
#

The issue is due to limitations of hasitem. The command can't tell if the player actually used the totem, dropped it, or put it in a chest.

You would need to make it so players couldn't move the totems out of inventory by using a replaceitem command that adds item lock mode lock_in_inventory (that way player could use offhand or main hand).

Also will need to add unique data to totem so player can have multiple totems in inventory. Will
use clear on normal data totems then replaceitem.

Then use an item counter to track amount of totems in inventory.

Then use a combination of unique player ids that summon an armor stand in a ticking area so you can use scoreboard operations to assign players' totem item count score to their armor stand.

Then use scoreboard operations to detect when a players' totem item count is less than the armor stands and execute your command off that trigger.