NeMV - Tags

Nekoyoubi

Plugin & Utility Developer
Veteran
Joined
May 2, 2013
Messages
92
Reaction score
69
First Language
English
Primarily Uses
Plugin: NeMV - Tags


Version: 1.2.3


Author: Nekoyoubi


Release: March 28th 2016


Download: https://raw.githubusercontent.com/nekoyoubi/NeMV/master/NeMV_Tags.js


Introduction


This plugin allows actors, enemies, classes, skills, states, items, weapons, armors, and events to be tagged and those tags to be easily retrieved via script.


Features

  • Simple notetag syntax
  • Applies to nearly any object (now even events!)
  • Reduces conditional blocks considerably



Example Use Cases


The general usage below should give you a couple of ideas, but in case you miss them here are the examples mentioned, and maybe a few others:

  • Adding/removing states to items (e.g. fresh/spoiled food)
  • Defining thematic categories of items (e.g. scientific/magical)
  • Giving enemies traits to affect the behaviors of skills (e.g. weapons that hurt plants extra)
  • Giving actors/enemies a gender to better influence random conversation (e.g. "Yeah, girl power!" when all party actors are tagged female)
  • Changing the user experience dynamically (e.g. only show crafting UI options when the party actually has a crafting material)
  • Customizing skills (e.g. only purge positive states from an enemy without specifying every possible buff)
  • Tracking event activation (e.g. how many treasure chests the player opens or elders they talk to)
  • Add visual markers to types of events (e.g. highlight all "harvestable" plants on a common event)



Anyway, those are just a few things that come to mind (and a couple that I'm using in my project currently), but I'm sure there are many, many more that can surface over time.


How to Use


Add tags to your actor, class, enemy, skill, state, item, weapon, armor, or event as illustrated below.


Multiple tags per entry can be separated by white-space or commas, and tags are case insensitive.


Add tags to events via the Comment event command.


<Tags: Plant>


... or...


<TAGS: root, red, alchemy>


... or...


<tags: BOSS FIRERESIST EXTRAGOLD>


Once your tags are added, they can be accessed in almost any location via:


[Object].hasTag("plant") // for exact tag checking

// ... or you can use asterisks to specify wild-card tag searches (v1.1)...

[Object].hasTag("*RESIST") // for performing a wild-card search looking for anything that ends with "resist"


This will return a boolean result indicating whether your object contains that tag or not. Tags can also be added and removed programmatically by calling either:


[Object].addTag("spoiled")


... or...


[Object].removeTag("fresh")


Note: Removing a tag that does not exist will NOT throw an error.


Events Note: Due to the volatile nature of events, adding and removing tags dynamically is not currently possible. Tags on events do change between the events pages; they simply cannot be addTag()/removeTag()'d.


A couple of utility methods have also been added to allow you to quickly scan the party for tags on items they either possess or have equipped, or tags on states they may have active.


NeMV.Tags.AnyPartyItemsHaveTag("magical")


... will return true if the party possesses any items tagged as "magical".


NeMV.Tags.AnyPartyStatesHaveTag("weapon")


... will return true if a party actor has a state tagged as "weapon".


NeMV.Tags.EventsThatHaveTag("harvestable")


... will return a collection of Game_Event objects tagged as "harvestable".


Script (external)


NeMV on GitHub  | Tags on GitHub  | Tags on MV Plugins  | Tags on Stitch Gaming | >> Download Tags <<


FAQ


Q: Does this work with YEP - ______?


A: There is some additional support for YEP - Item Core, and that works assuming you use... 


DataManager.getBaseItem(item)


Other than that, I don't know of any conflicts with anything in the YEP.


Q: Is this able to be used in commercial projects?


A: Absolutely! Wouldn't that be cool?!


Q: If I use this, do I need to say so anywhere?


A: If you can make use of my work on any level, then I would absolutely love to know about it, but I make no attribution requirements or the like. NeMV is licensed under the WTFPLv2.


Credits & Thanks

  • Yanfly for always giving such awesome feedback!



Author's Notes


I put together this little plugin that I thought may be of use to someone, and since I don't have any real posts here yet, I thought I'd give it a go. Happy tagging!
 
Last edited by a moderator:

nerochepiace

Veteran
Veteran
Joined
Dec 1, 2015
Messages
48
Reaction score
2
First Language
italian
Primarily Uses
I think that is one of the MOST useful utility plugin I have seen!


Thank you!
 

autophagy

tank nerd
Veteran
Joined
Jun 9, 2014
Messages
75
Reaction score
63
First Language
German
Primarily Uses
RMMV
Hi!


Great plugin, thank you!


I don't know much about JS programming but I managed to make this work with Yanfly's Item Core / Augment Attachments by using ._equips[x].hasTag("x") instead of .equips()[x].hasTag("x") to check an independent armor's or weapon's tags. For some reason $gameActors.actor(x).equips()[x].hasTag("x") didn't work for me. I don't know what the difference between those two is but apparently it matters....My game kept crashing. I could have used the script call with DataManager.getBaseItem(item) but that only gives you the tags of the base item, no? I needed the tags of the independent item because I add and remove tags with augments during the game.


To dynamically add or remove a tag with an augment, I used this:

Code:
<Augment Attach Eval: Test>
item.tags.push("test".toUpperCase());
</Augment Attach Eval: Test>
Code:
<Augment Detach Eval: Test>
var index = item.tags.indexOf("test".toUpperCase());
if (index > -1) item.tags.splice(index, 1);
</Augment Detach Eval: Test>
Cause item.addTag("x") and item.removeTag("x") didn't work for me, so I copied over the content of the functions from the Tags plugin.


Took me a while to figure this out, I hope it helps people who have the same problem I had! It's possible that I used the instructions wrong or made things utterly overcomplicated but I was just trial and erroring for the last hour with no idea what I was even doing and this is the result.
 
Joined
Oct 29, 2014
Messages
156
Reaction score
4
First Language
English
How would I use this plugin to create an exorcism skill that can only harm demons and the undead, then?
 

gambitben

Veteran
Veteran
Joined
Jun 8, 2013
Messages
138
Reaction score
100
First Language
Spanish English
Primarily Uses
RMMV
Hey, I'm loving the plugin but I'm not able to check if the actor has a weapon with a tag. What method should I use? Using user.hasTag() only Works if the actor has the tag, but not if the actor has a sword with such tag. Thank you for your time :rhappy:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Been so busy lately that I wonder if I should slowly start preparing the advent calendar resources so I have enough in december.
Man, I wish it was harder for mean d-holes to make me feel like crying.
Made 8 games. Was aiming for 20. Gonna go for 40. Because 20 + 20. /Bed.
Got myself card game plugin, its bit laggy but worth it
Finally made battler stuff for my last character...

Forum statistics

Threads
94,535
Messages
921,707
Members
124,400
Latest member
Standanddeliver
Top