extends Control func example(): var nbt = NBT.new() # Create an example NBT file from scratch WITHOUT the helper class: var data = {} # set the root compound tag: data[""] = {} # put a compound inside. this will store the data data[""]["type"] = NBT.TAG_Compound data[""]["data"] = {} # add some different data types inside: # each one of these is shown done a little differently. data[""]["data"]["string example"] = { "type":NBT.TAG_String, "data":"this is the srings contents" } #short example: data[""]["data"]["short example"] = {} data[""]["data"]["short example"]["type"] = NBT.TAG_Short data[""]["data"]["short example"]["data"] = -1 # string list helper command example: data[""]["data"]["names"] = { "type":NBT.TAG_List, "valuetype":NBT.TAG_String, "data": [ {"type":NBT.TAG_String,"data":"Steve"}, {"type":NBT.TAG_String,"data":"Alex"}, {"type":NBT.TAG_String,"data":"Herobrine"}, {"type":NBT.TAG_String,"data":"Bob"}, {"type":NBT.TAG_String,"data":"John"}, ] } nbt.save_file("user://fromscratch.nbt",data) # Create an example NBT file from scratch WITH the helper class: data = { "example":NBTHelper.compund({ "byte":NBTHelper.byte(69), "short":NBTHelper.short(420), "int":NBTHelper.int(1337666), "long":NBTHelper.long(999999999999999), "float":NBTHelper.float(420.69), "double":NBTHelper.double(0.694201337), "bytearray":NBTHelper.byte_array([0,1,2,3,255,254,253,252]), "string":NBTHelper.string("Hello, world."), "list":NBTHelper.list([ NBTHelper.compund({ "name":NBTHelper.string("Steve"), "age":NBTHelper.byte(34), }), NBTHelper.compund({ "name":NBTHelper.string("Alex"), "age":NBTHelper.byte(29), }), ],NBT.TAG_Compound), "intarray":NBTHelper.int_array([69,420,666,1337]), "longarray":NBTHelper.long_array([694206661337,8888888888888888,6666666666666666]), "quickliststring":NBTHelper.quick_list(["hello","how are you?"],NBT.TAG_String), "quicklistfloat":NBTHelper.quick_list([0,0.125,0.25,0.5,1.0,1.5],NBT.TAG_Float), }) } nbt.save_file("user://helperexample.nbt",data) $Output.text = "Example NBTs saved in user folder" var s = SNBT.new() $Output.text = s.to_snbt(data) func _on_schem_pressed(): # this creates a simple sponge schematic with a block of your choice # does not use helper class var data = { "Schematic":{ "type":NBT.TAG_Compound, "data":{ "BlockData":{ "type":NBT.TAG_Byte_Array, "data":PoolByteArray([ 1,0,0,0,1, 0,1,0,1,0, 0,0,1,0,0, 0,1,0,1,0, 1,0,0,0,1, ]) # A 5 by 5 "X" shape }, "DataVersion":{ "type":NBT.TAG_Int, "data":2975 }, "Height":{ "type":NBT.TAG_Short, "data":1 }, "Length":{ "type":NBT.TAG_Short, "data":5 }, "Width":{ "type":NBT.TAG_Short, "data":5 }, "PaletteMax":{ "type":NBT.TAG_Int, "data":2 }, "Version":{ "type":NBT.TAG_Int, "data":2 }, "Palette":{ "type":NBT.TAG_Compound, "data":{ "minecraft:air":{ "type":3, "data":0 }, $BID.text:{ "type":NBT.TAG_Int, "data":1 }, } }, } } } var nbt = NBT.new() nbt.save_file("user://example.schem",data) $Output.text = "Schem saved made out of %s"%[$BID.text]