DNT (Dahesor’s NBT Transformer)
本库提供了一些操作SNBT的使用工具。
-
function dnt:concat:
从storage dnt:ram in读取一个字符串列表,按顺序拼接后输出到storage dnt:ram out(即concat)。
本拼接会正确地处理转义字符。例如\,',或"等均会被正确拼接。 -
function dnt:concat_splited:
本函数是concat函数的组成部分。它在in中接受一个处理好的字符列表并拼接它们。这个列表中所有的转义字符均被孤立了出来。- 函数
concat会先重新构造列表…… - [
"Hello"," single ' quote"," and \\ back slash"] - 为
concat_splited函数接受的形式: - [
"Hello single ","'"," quote and ","\\"," back slash"] - 然后由
concat_splited将其拼接: "Hello single ' quote and \\ back slash"
- 函数
-
function dnt:remove_newline:
与function dnt:concat,相同,但是拼接时会移除所有的\n字符。制作本函数的目的是去除用户在对话框多行文本输入中的换行。 -
function dnt:get_snbt:
读取storage dnt:ram in中输入的任意NBT结构,以字符串形式输出它的SNBT结构,存储进storage dnt:ram out。 -
function dnt:to_json:
读取storage dnt:ram in中存储的NBT复合标签或列表,将其转换为等价的JSON结构,以字符串的形式存储进storage dnt:ram out。所有转义,\n,奇怪的键名等都会正确处理。1b和0b会转换为true和false。
本函数会挨个字符读取输入项的SNBT字符串。如果要转换太长的NBT,你可能要调整maxCommandChainLength。
制作本函数的初始目的是为了大别墅的试炼刷怪笼NBT配置导出JSON功能。
转换示例:
输入:
{equipment:{mainhand:{id:"diamond",components:{"minecraft:item_name":{text:"what\"\"''ha>?",italic:true},"!attribute_modifiers":{},custom_data:{'Cool"\'\\Name':Yeah...}}}}}
输出:
{"equipment":{"mainhand":{"components":{"!attribute_modifiers":{},"custom_data":{"Cool\"'\\Name":"Yeah..."},"minecraft:item_name":{"italic":true,"text":"what\"\"''ha>?"}},"id":"diamond"}}}
function dnt:version:
返回数据包的版本。同时设置dnt:ram sys.pong__为true以便其他数据包检测本库安装。
Unlicense license
本库使用Unlicense许可证。
Github: https://github.com/Dahesor/DNT-Dahesor-NBT-Transformer
没有评论