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

[转载发布] bsb notetag parser

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

    连续签到: 2 天

    [LV.7]常住居民III

    4434

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 5 小时前 | 显示全部楼层 |阅读模式
    bsb notetag parser 1.0.0
    briarsweetbriar


    Introduction
    it slices, it dices, it parses notetags.

    Features

    • searches text for single-line, multi-line, and js notetags
    • parses notetags into js primitives (eg strings, numbers, booleans)
    • also parses nested data into arrays and objects
    • adds a new function to game battlers that aggregates all instances of a tag on that battler, searching their character, class, states, and equips

    How to Use
    install plugin as usual by adding it to `/js/plugins/`. you can then access its commands w/ `BSB.NP.<command>`.

    Plugin Commands / Script Calls

    BSB.NP.getMultiLineTags(note, tagName)


    returns an array of all instances of that multi-line tag in the note.

    BSB.NP.getMultiLineTag(note, tagName)

    same as `getMultiLineTags` but only returns the first instance of the tag.

    BSB.NP.getTags(note, tagName)

    returns an array of all instances of that single-line tag in the note.

    BSB.NP.getTag(note, tagName)

    same as `getTags` but only returns the first instance of the tag.

    BSB.NP.getJSTags(note, tagName)

    returns an array of all instances of that js tag in the note.

    BSB.NP.getJSTag(note, tagName)

    same as `getJSTags` but only returns the first instance of the tag.

    battler.getMultiLineTags(tagName)

    returns all instances of a tag on a particular battler. for actors, the tag is searched for on the character, class, equips, and states. for enemies, the tag is searched for on the enemy and states.

                    JavaScript:       
    1. // getMultiLineTags/getMultiLineTag
    2. let note = `
    3.   <Foo>
    4.     boolean: true
    5.     number: 8.88
    6.     string: other value
    7.     array: [1, 2, 3]
    8.     object: { boo: 1 }
    9.     nestedStuff: [{ boo: 1, baz: 2 }, { boo: 3, baz: 99 }]
    10.   </Foo>
    11.   <Foo>
    12.     anotherVal: 123
    13.   </Foo>
    14.   <Bar>
    15.     something: else
    16.   </Bar>
    17. `
    18. BSB.NP.getMultiLineTags(note, "Foo");
    19. => [{
    20. boolean: true,
    21. number: 8.88,
    22. string: 'other value',
    23. array: [1, 2, 3],
    24. object: { boo: 1 },
    25. nestedStuff: [{ boo: 1, baz: 2 }, { boo: 3, baz: 99 }]
    26. }, {
    27.   anotherVal: 123
    28. }]
    29. BSB.NP.getMultiLineTag(note, "Foo");
    30. => {
    31. boolean: true,
    32. number: 8.88,
    33. string: 'other value',
    34. array: [1, 2, 3],
    35. object: { boo: 1 },
    36. nestedStuff: [{ boo: 1, baz: 2 }, { boo: 3, baz: 99 }]
    37. }
    38. // getTags/getTag
    39. BSB.NP.getTags('<Foo: 1, true, bar>', "Foo");
    40. => [[1, true, 'bar']]
    41. BSB.NP.getTags('<Foo: 1, true, bar> <Foo: baz> <Bar>', "Foo");
    42. => [[1, true, 'bar'], ['baz']]
    43. BSB.NP.getTags('<Foo>', "Foo");
    44. => [[]]
    45. BSB.NP.getTags('<Foo>', "Bar");
    46. => []
    47. BSB.NP.getTag('<Foo: 1, true, bar> <Foo: baz> <Bar>', "Foo");
    48. => [1, true, 'bar']
    49. BSB.NP.getTag('<Foo>', "Foo");
    50. => []
    51. BSB.NP.getTag('<Foo>', "Bar");
    52. => undefined
    53. // getJSTags/getJsTag
    54. let jsNote = `
    55. <Foo>
    56.   let a = 'foo bar';
    57.   let b = 'baz';
    58.   console.log([a, b].join(' '));
    59. </Foo>
    60. `
    61. let jsTags = BSB.NP.getJSTags(jsNote, "Foo");
    62. jsTags.forEach((tag) => eval(tag));
    63. => foo bar baz
    64. let jsTag = BSB.NP.getJSTag(jsNote, "Foo");
    65. eval(jsTag);
    66. => foo bar baz
    复制代码


    Download
    https://raw.githubusercontent.com/briarsweetbriar/draw-that-circle-tight/master/js/plugins/BSB_0_NotetagParser.js

    Terms and Credits
    MIT license. feel free to use in commercial games, adult-themed games, whatever. feel free to use it in your own plugins too, including commercial plugins. if you use it in your plugin, please credit me and link to this thread. if you use it in your game, no need to credit.


    本贴来自国际rpgmaker官方论坛作者:briarsweetbriar处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/bsb-notetag-parser.135617/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 12:54 , Processed in 0.062217 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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