Tag Manager

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

This tag manager is very powerful when it comes to designing your database since you can classify objects anyway you want.  It allows you to assign “tags” to objects.

A tag is simply a single  alphanumeric (A to Z, 0 to 9, some symbols) string with no spaces. Examples of tags include “sword” or “carrot” or “1000eyes”.  Any concept that you can imagine can be reduced to a set of tags that are used to describe the idea:

You can use tags to describe an actor’s gender (“male”, “female”)
You can use tags to describe the rarity of an equip (“common”, “rare”)
You can use tags to describe an actor’s race (“human”, “vampire”, … )

Once tags have been assigned, you can then assign “tag conditions”, which are conditions that must be met in order for an item to be usable. For example, a “collar” might only be equippable by dogs, so you would include a condition that requires an actor to be a “dog” in order to equip it.

tagManager1

Download

Script: download here

Addons

Usage

We start with some basics concepts.
A “tag object” is any ob ject that supports tags. The following objects support tags

  • Actors
  • Classes
  • Skills
  • Items
  • Weapons
  • Armors
  • Enemies
  • States
  • Maps

An actor’s tags is the collection of all tags that are assigned to the actor, her current class, and any equips or states.

Tagging objects

Assign tags to tag objects using the note-tag

<tag: x>
<tag: x y>

For strings x, y. You may have multiple tags in a single note-tag by separating them with the delimiter you have chosen.

tagManager2

Tag Conditions

You can require items or skills to have an effect on the target only when the target has the required tags. Similarly, you can require weapons or armors to be equippable only when all tag conditions are met.

Specify a tag condition using the note-tag

<tag_cond: x>
<tag_cond: x y>

For strings x, y.

All conditions are specified using three basic boolean operators: AND, OR, NOT.
For example,

“a AND b” means an actor must have both tags to meet the condition.
“a OR b” means an actor must have at least one of the tags to meet the condition.
“NOT a” means an actor must not have the tag to meet the condition.

This script does not support parentheses matching, so you will have to use DeMorgan’s laws  to convert them into simpler statements that is recognized by the tag manager.

a AND (b OR c) => (a AND b) OR (a AND c)
NOT (a AND b) =>  (NOT a) OR (NOT b)

This might be tricky at first if you are not familiar with boolean logic but it is not difficult to understand with practice.

tagManager3

Map Conditions

These are the same as tag conditions, except you use them to compare with the current map. Note-tag an object with

<map_cond: x>
<map_cond: x y>

For some strings x, y
You will tag the map as usual with

<tag: x>

Map conditions are used when you require something to be true about the current map. For example, you might have items that are only usable on “world maps”, and this is easily accomplished by adding a map condition for the item and tagging your maps appropriately.

Accessing Tags

Sometimes you would like to explicitly check whether tags exist in your events or other scripts. You can do this by accessing the tags property that is exposed by all Tag Objects.

For example, to access the first actor’s tags, you would say

$game_actors[1].tags

This will return all of the tags that are currently assigned to actor 1.

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

29 Responses

  1. Disponi says:

    Sorry to bother you about an old script, but can you use tags in damage formulas? Like, say you have an Exorcism spell, could you write a damage formula that says something like if b.has_tag?("GHOST") ; b.add_state(1); 0; else; 0; end;

    Thanks in advance.

  2. Aaron Corson says:

    Is there anyway to check a map condition using a script or conditional branch?

  3. Deputy Diode says:

    Is it possible to make it so an item is only usable on a certain actor through the use of this script? For example, if I had a character who was a vegetarian, could I make an item called “Hot Dog” that that character would refuse to eat? I can figure out how to make it so that character can’t use the item when selecting from her menu in battle, but if someone else uses it on her she’ll still eat it.

    Sorry if this is a dumb question. I feel like I saw it answered somewhere, but I can’t find it…

    • Hime says:

      You can use this script in combination with Common Event Variables to help you with the logic.

      The idea is that, if you had a lot of different meat items, you don’t want to have to write separate checks for each and every item.

      To solve this, you would begin by tagging all your meat items with an appropriate tag, say, “meat”. You would then use the item on an actor, which will call a common event.

      Through the common event variables script, the common event now has access to the item being used, as well as the actor that is being used on. You can use the conditional branch command with the following script condition:

      $game_temp.common_event_item.tags.include?("meat") && $game_temp.common_event_target.id == 3

      Which would check if the target is actor 3, and the item has the “meat” tag. You would then fill in the rest of the event normally.

  4. Georg says:

    Google Translator:

    It may be silly to ask, but is there a way to add a tag ingame ?? Thank You.

  5. AxD141 says:

    How would I check if a state has certain tags?

    Like how one can check for an actor’s tags via $game_actors[#].tags.include?(‘Male’)

    • Hime says:

      Assuming your states cannot be customized during the game, you should be able to access the database state itself:

      $data_states[#].has_tag?(“Some_Tag”)

  6. Feldherren says:

    I think this is the case, but just to be sure: there’s no specific method in this script to check for a particular tag, but that’s probably because we’d just need to go:
    if $game_actors[#].tags.include? ‘Male’

    Right?

  7. Anduie says:

    I am using this with Yanfly's class system. What I'm after is being able to change classes and multiclass while carrying with it restrictions and requirements. However, I'm having an issue with getting tags to work on anything other than the primary class. Furthermore, I don't know how to get tags to affect what classes can be equipped, so, if say the primary class was tagged <tag: Martial> and a secondary class was tagged <tag_cond: !Martial>, that class couldn't be equipped.

    Also, is there a way to make tags permanent or become temporary? What I'm aiming for is if a class (or something else) was equipped for a certain event (say, getting to level 5), a tag becomes permanently attached?

    • Hime says:

      In the script there is a method called "tag_objects". Add the extra classes to it so that it also checks the secondary class.

      For anything else specific to the script, you will need someone to write an add-on.

      There is no support for temporary tags or dynamic tags built-in. I can add support for that if I get around to it, but for yanfly’s script you’ll have to find someone else to do it.

      • Feldherren says:

        Could just attach a tag to a status and apply that, if I’m reading the script properly. Other scripts exist to make states permanent and only removable via event commands.

  8. Matthew says:

    when you mentioned DeMorgan's Laws and placed those two arguments:

    <em>a AND (b OR c) => (a AND b) OR (a AND c)
    NOT (a AND b) => (NOT a) OR (NOT b)</em>

    isn't the top one suppose to be Distributive Laws?

  9. Animebryan says:

    Could this be used to label skills as physical or magical & provide a method to check for them under specific circumstances such as; making a sleeping target only awake up to ‘physical’ damage & not magical? Or have enemies use counter-skills based on whether they were hit with a physical or magical skill?

  10. Ben says:

    Hey, thanks for the script.
    I’m wanting to use this to define levels for enemies, since it’s an option for the damage formulae. Tried inserting the below into the script, beneath the class Game_Enemy < Game_Battler:

    def level
    return [level]
    end

    The thing still works as if every monster is Level 0…clearly did something wrong. First time working with Ruby; do you have suggestions? Thanks.

  11. Skitzen says:

    Hello!
    I have a script (Custom Battle) that changes the battler’s appearance via a note tag for each actor. The script asks for a notetag “battler[name]” To determine the graphic you want for them.
    But in the script I cannot find a way to change what the battler can be /in/ game. Say if the actor’s appearance was changed.. How would I go about it changing the battler, without having to make a whole new character? Is there a way I can use your script to fix this?

    • Hime says:

      I don’t know what your script is but this script does not manage existing note-tags or extend the functionality of any scripts that use note-tags. “Tag” strictly means an arbitraty word that is assigned to an object.

      • Skitzen says:

        Ahhh, sorry. I’ve been trying to find a way to make this thing work. I don’t have a link to the script right now but it’s called “CP’s Battle Engine” u.u; Hmm, I need to find something that can maybe add conditional battlers, but still use this system. Ah well. Thanks for the fast reply though! 🙂

  12. Hakurei Reimu says:

    Can this be applied to skill targets too?
    Like a vampire’s feeding skill only applying to living targets? (as opposed to undead skeletons and such).

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax