#(norwaj) Armor check

38 messages · Page 1 of 1 (latest)

regal flax
#

Hello everyone. How do I check if player has armor? (on the head, legs, etc.)

steep deltaBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

mental grotto
#

!t InventoryTag.equipment

radiant jungleBOT
mental grotto
#

Or

#

!t InventoryTag.equipment_map

radiant jungleBOT
regal flax
#

Can I get a specific armor value on just the head or just the legs?

mental grotto
#

use equipment map for that

#

example, if they have leather helmet and boots, the output will be, in human readable code:

equipment_map:
  helmet: leather_helmet
  boots: leather_boots
#

you see how in this scenario, it doesn't have a leggings or chestplate key? that's because

Air items will be left out of the map.

#

so, using that in our advantage

#

you can simply check if the relevant key exists, to know if the player has something equipped

#

!t map.key

radiant jungleBOT
mental grotto
#

oof sorry

#

!t map.get

radiant jungleBOT
# mental grotto !t map.get

Returns the object value at the specified key.
If a list is given as input, returns a list of values.

Returns

ObjectTag

Examples
# Narrates '2'
- narrate <map[a=1;b=2;c=3].get[b]>
# Demonstrates that list input gives list output - narrates '2' then '3'
- foreach <map[a=1;b=2;c=3].get[b|c]> as:value:
    - narrate "One of the values is <[value]>"
mental grotto
#

.get[leggings] for example

#

and then

#

!t .exists

radiant jungleBOT
# mental grotto !t .exists
Cannot Specify Searched Tag

Multiple possible tags: <schematic[<name>].exists>, <ObjectTag.exists>, <server.scoreboard[<board>].exists>.

mental grotto
#

!t object.exissts

radiant jungleBOT
#
Possible Confusion

Did you mean to search for objecttag.exists?

radiant jungleBOT
# mental grotto !t object.exissts

Returns true if the object exists (is non-null). Returns false if the object doesn't exist, is null, or the tag errored.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.

Returns

ElementTag(Boolean)

mellow sky
#

!t has_equipped

radiant jungleBOT
# mellow sky !t has_equipped

Returns whether the entity has any armor equipment item that matches the given item matcher, using the system behind !language Advanced Object Matching.
For example, has_equipped[diamond_*] will return true if the entity is wearing at least one piece of diamond armor.

Group

element checking

Returns

ElementTag(Boolean)

mellow sky
#

if thats relevant to you as well

mental grotto
#

oh whaaat that's a tag i have never heard of

loud bloom
#

there's also:

#

!tag maptag.is_empty

radiant jungleBOT
# loud bloom !tag maptag.is_empty

Returns "true" if the map is empty (contains no keys), otherwise "false".

Returns

ElementTag(Boolean)

Examples
- if <map[a=1;b=2].is_empty>:
    - narrate "This won't show"
- else:
    - narrate "This will show! The map has stuff in it!"
- if <map.is_empty>:
    - narrate "This will show! That map is empty!"
- else:
    - narrate "This won't show"
loud bloom
#

if the equipment_map is empty, they nakey

subtle edgeBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@regal flax