Hello,
If you are a scripter in your project and add many attributes in your database but are tired of writing the same stuff many times, this script might help you.
I originally wrote it by adapting an older script from Clarabel from GTBS and realized that it might help others, so I share this here.
It aims to reduce the code needed to add attributes to objects from the database, with this, you can simply add lines of codes like this (either before loading the database or inside method
):
Ruby:
This will create an attribute called
for all objects in
with default value 0, and that can be modified by putting the corresponding note in the database, for instance if for item number 3 you put
in the notes, then:
will be 2 while
will be the default value.
The syntax is:
Ruby:
With
an integer between 0 and 3:
- 0 means that the part inside the parenthesis of the regexp is computed (with
method) and stored
- 1 means that the string itself is stored (useful for file names or plain text)
- 2 means that when the regexp is found, the value is set to
- 3 is for hash tables, the first value is the key and the second is the data stored in it, both values are evaluated with eval first
The supported data and notetags are actors, classes, skills, items, weapons, armors, enemies, troops, states, maps and tilesets.
In the case of troops, the notetags are taken from any comment inside the troop's events, regardless of their page conditions.
Note that this script requires an understanding of regular expressions and simple code, therefore if you don't understand how they work, I suggest you don't use this script.
Also, since the script adds attributes 'dynamically', please choose wisely their names to avoid conflict with preexisting attributes and methods. Finally, the script only modifies classes from the RPG module, so you will need to write more code if you plan on using them in your scripts.
Here is the script:
Ruby:
Terms and Credits
Free for commercial and non-commercial projects as long as you credit me.
Edit: updated to version 1.1, fixing test battle crash and handling tileset notetags.
Edit: updated to version 1.2, bringing hash table storage.
Edit: updated to version 1.3, the methods created by notetags should now be set once per class, this does not change anything aside from maybe performances at launch.
本贴来自国际rpgmaker官方论坛作者:Timtrack处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/simple-notetag-config-v1-3.179996/