设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 127|回复: 0

[转载发布] Pretty Plugin Parameters - Death to the Note Tag!

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9072

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58885
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68851

    灌水之王

    发表于 2026-7-26 18:59:54 | 显示全部楼层 |阅读模式
    Pretty Plugin Params v1.0


    Introduction

                            Note: You do not need this plugin for any FROG plugins.  This functionality has been baked into FROG_Core from the beginning.  This is for you to use in your own plugins.  My hope is that this plugin will be included in future versions of the RPG Maker MV software.               
    Click to expand...


    The new MV 1.5 plugin parameters are awesome!  They really make things easy on developers.  No more learning how each and every plugin maker designs their note tags.  No more learning a bunch of note tag commands for every plugin in order just to use it.  No more typos which cause things not to work or perhaps even crash your game.  You just tell the plugin what values it needs and what types of data they collect.

    It's much cleaner too.  Asking a game dev to enter in complex data into note tags is just asking them to make mistakes and creates a lot of frustration.  They might end up not even using your plugin if they can't get it to work.  You also get the advantage of being able to supply a default configuration which makes it easy for devs to play around with your plugin without having to invest a lot of time and energy trying to set things up just to test.

    But the designers of RMMV dropped the ball on one thing.  As great as the new plugin parameters are, they didn't give plugin developers an easy way to get the data out in a usable fashion.  When you read the data, you do get an object but only for the first layer.  Everything contained within the this single layer of object properties is a big mess of strings that need to be run through JSON.parse constantly.  It really gets in your way and largely becomes more trouble than it's worth.  Because of this, most plugin developers have stuck with using note tags and all of the problems they bring.  It's just too much work.

    Spoiler: Yuck!
    [/quote]

    Not any longer, though!  This plugin completely corrects the major problem with using the MV 1.5 plugin parameter format by converting them from a gnarly mess of string data into a nice, easy to use JSON object like they were intended to be.  With this plugin and one line of code, you'll get a cleanly formatted object with all of the data properly typed.  Strings remain strings, numbers remain numbers, arrays stay arrays, objects are still objects and arrays of objects come out as arrays of objects.  It's a beautiful thing, really. Brings a tear of joy to your eye.

    Spoiler: That's much better![quote]


    Features

    • Just one feature, converts plugin parameters into an easy to use JSON object.
    • Allows you to get complex with plugin parameters while also making it easy to retrieve this data.
    • Makes it easy to save this data along with the game data.

    How to Use

    Place this plugin above any other plugins that use it.

    Just define a variable to store the plugin parameters and then pass it and the plugin parameters to the convert function.

                    Code:       
    1. var variable = {};
    2. convertPluginParams(paramerters, variable);
    复制代码


    Example:
                    Code:       
    1. var $pluginParams = {};
    2. convertPluginParams(PluginManager.parameters('Filename of your plugin without the .js'), $pluginParams);
    复制代码


    That's it!  All of your plugin parameters, no matter how complex, can now be accessed in the variable you provided.  Couldn't get much easier than that!

    In addition to easily reading in plugin parameters, there's a couple of other things you can do with this.  Now that your plugin parameters are all neatly tucked away in a JSON object, they are super simple to change in-game now. Say you have a parameter that sorts Quests either ascending or descending. You can give your players the option to change this to their liking in the game.  If you allow these parameters to be changed in-game, though, you probably want to save these changes so that they aren't lost when the player closes the game, comes back later and the reloads their game.  That's really easy to do now.

    The example below assumes that there is a plugin parameter named saveParamObject (or Save Param Object if camel-case is turned on).  It aliases setupNewGame, makeSaveContents and extractSaveContents to handle resetting parameters on new game, saving them and loading them so that any changes can be preserved.  I now include these options by default in every plugin I make.

                    Code:       
    1. // Refresh plugin parameters on new game
    2. var alias_DataManager_setupNewGame = DataManager.setupNewGame;
    3. DataManager.setupNewGame = function () {
    4.     alias_DataManager_setupNewGame.call(this);
    5.     convertPluginParams(PluginManager.parameters('Filename'), $pluginParams);
    6. }
    7. // Save File
    8. var alias_DataManager_MakeSaveContents = DataManager.makeSaveContents;
    9. DataManager.makeSaveContents = function() {
    10.     var contents = alias_DataManager_MakeSaveContents.call(this);
    11.     if ($pluginParams.saveParamObject === true) {
    12.         contents.pluginParams = $pluginParams;
    13.     }
    14.     return contents;
    15. }
    16. // Load File
    17. var alias_DataManager_ExtractSaveContents = DataManager.extractSaveContents;
    18. DataManager.extractSaveContents = function(contents) {
    19.     alias_DataManager_ExtractSaveContents.call(this, contents);
    20.     if ($pluginParams.saveParamObject === true) {
    21.         $pluginParams = contents.pluginParams;
    22.     }
    23. }
    复制代码



    Camel-case Properties - This option will convert your plugin's parameter names into more usable property names.  By default, the property names come over as the @param used in the plugin editor and will often contain white space so you'll end up with something like Class Id.  This forces you to use these property names with the less desirable bracket notation, something like $params['Class Id'].  Who wants to do that?  This option will ditch the spaces and lowercase the first letter so that you can reference the property as $params.classId which is much cleaner.

    There is an option to define your parameter labels with @text and then use @param to make your property name anything you want (like classId). This is actually a better option and if you set up your plugin this way, leave this option off.


    Terms of Use

    MIT License

    Copyright (c) 2018 Stephen Sandford (Frogboy) <https://frogboymv.github.io/>

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


    Change Log

    • Version 1.0 - Initial release

    Download

    https://github.com/FrogboyMV/MiscPlugins

    Demo project also available if you want an easy way to see this in action.


    本贴来自国际rpgmaker官方论坛作者:Frogboy处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/pretty-plugin-parameters-death-to-the-note-tag.99683/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-22 08:36 , Processed in 0.116614 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表