tool extends Node export(bool) var save = false export(String) var predNamee = "test" export(String, FILE) var fileNamee = "res://preds/test.conf" onready var field = get_node("..") var filee = File.new() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): field = get_parent() if save: save = false savee(fileNamee,predNamee) func savee(fname,namee): field = get_parent() var datat = {} datat['name'] = namee datat['type'] = "pred" datat['char-position'] = field.get_node("pred").position datat['char-sprite'] = field.get_node("pred/Sprite").texture.get_data().save_png_to_buffer() datat['char-shape'] = field.get_node("pred/CollisionShape2D").shape datat['char-collectorposition'] = field.get_node("pred/Collector/Collision").position datat['char-collectorshape'] = field.get_node("pred/Collector/Collision").shape datat['structure'] = field.get_node("structure").tile_data datat['invwalls'] = field.get_node("invwalls").tile_data var cams = {} var statics = {} for node in field.get_children(): if node is Camera2D: cams[node.name] = {} cams[node.name]["position"] = node.position cams[node.name]["limit_top"] = node.limit_top cams[node.name]["limit_bottom"] = node.limit_bottom cams[node.name]["limit_left"] = node.limit_left cams[node.name]["limit_right"] = node.limit_right elif node is StaticBody2D: statics[node.name] = {} statics[node.name]["position"] = node.position statics[node.name]["sprites"] = {} statics[node.name]["collisions"] = {} for i in node.get_children(): if i is Sprite: statics[node.name]["sprites"][i.name] = {} statics[node.name]["sprites"][i.name]["position"] = i.position #statics[node.name]["sprites"][i.name]["res"] = i.texture.get_data().save_png_to_buffer() statics[node.name]["sprites"][i.name]["z"] = i.z_index elif i is CollisionPolygon2D: statics[node.name]["collisions"][i.name] = {} statics[node.name]["collisions"][i.name]["shape"] = i.polygon #data.set_value("data","cameras",cams) #data.set_value("data","statics",statics) datat["cameras"] = cams datat["statics"] = statics filee.open(fname+"b",filee.WRITE) #filee.store_string(var2str(datat)) filee.store_var(datat,false) filee.close() filee.open_compressed(fname+"testgz",filee.WRITE,filee.COMPRESSION_GZIP) filee.store_var(datat,false) filee.close() filee.open_compressed(fname+"testlz",filee.WRITE,filee.COMPRESSION_FASTLZ) filee.store_var(datat,false) filee.close() filee.open_compressed(fname+"testzs",filee.WRITE,filee.COMPRESSION_ZSTD) filee.store_var(datat,false) filee.close() filee.open(fname+"test",filee.WRITE) filee.store_var(datat,false) filee.close() filee.open(fname+"test",filee.READ) var testsets = filee.get_var(false) filee.close() print(to_json(testsets))