Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

FAQ: How do I use tagging?

1cec0ld edited this page Sep 7, 2013 · 18 revisions

Tagging allows for basic persistence of information outside of the scope of a single event with an integer or string value. An entity tag is set until tag is unset by a routine, or the entity no longer exists. They will persist even across server restarts, and player tags are never deleted except by an explicit unset routine. The examples below assume you are familiar with these tagging routines:

Tags are relatively simple to use. Here's a simple example:

Death:
    - 'set.target_tag_deathcount': '+1'
Spawn:
    - 'if entity.istagged.deathcount':
        - 'message.entity': 'You have died %{entity_tag_deathcount} times on this server!'
Command:
    - 'remember &player':
        - 'set.sender_stag_remembered': "Player: %{player}"
        - 'message.sender': "I will remember \"%{sender_stag_remembered}\" for you"
    - 'remember #number':
        - 'set.sender_stag_remembered': "Number: %{number}"
        - 'message.sender': "I will remember \"%{sender_stag_remembered}\" for you"
    - 'remember':
        - 'set.sender_stag_remembered': "Remember: %{sender_stag_remembered}"
        - 'message.sender': "I will remember \"%{sender_stag_remembered}\" for you"
    - 'remind':
        - 'if sender.isstagged.remembered':
            - 'message.sender': "You remembered \"%{sender_stag_remembered}\""
        - 'if !sender.isstagged.remembered':
            - 'message.sender': "You can't seem to remember anything."
    - 'forget':
        - 'unstag.sender.remembered'
        - 'message.sender': "Hopefully you didn't forget something important."
Aliases:
    Routine:
        uncurse:
            - 'set.target_tag_cursed': '-1'
            - 'if target_tagvalue_cursed <= 0':
                - 'untag.target.cursed'
            - 'if target_tagvalue_cursed > 0':
                - 'delay.20': # 1 second
                    - '_uncurse'
Damage:
    - 'if attacker.group._cursedOne and target.type.player':
        - 'set.target_tag_cursed'
        - 'delay.20': # 1 second
            - '_uncurse'

I hate losing all the arrows I shoot at mobs, and I'd like to be able to get some of them back.

Damage:
    - 'if projectile.type.arrow':
        - 'set.target_tag_arrows': '+1'
Death:
    - 'if target.istagged.arrows':
        - 'targeteffect.dropitem.arrow.roll(target_tag_arrows)'

A more advanced example here is intended to produce a "Left for Dead 2" type of play:

Damage:
    - 'if attacker.group.Undead and !target.istagged.infected':
        - 'if target.type.player and target_health < 7':
            - 'message.world': '&4%{target_name} has been infected by %{attacker_name}!' # Inform the world of their blunder with a nicely-formatted message.
            - 'set.target_tag_infected' # Set the infection tag.
    - 'if !attacker.group.PermaInfected and !attacker.istagged.infected': # Not an infected or zombie person.
        - 'if attacker.wielding.gold_sword': '3' # Gold swords have a purifying effect, with people who aren't infected.
Death:
    - 'if !attacker.group.Undead':
        - 'if attacker.wielding.gold_sword and target.istagged.infected':
            - 'message.world': '&6%{target_name} was purified by %{attacker_name}!' # Purification get!
            - 'untag.target.infected'

Summary: Members of the group PermaZombie infect others, who can in turn infect others. Non-infected players wielding a gold sword can "purify" infected players by killing them.

Another example involving recursion and the usage of a tag's associated value with a Delay routine can also be found at the Explode calculation wiki entry.

Clone this wiki locally