Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Control
- """
- This project is a literal json generator. it creates .json files with the given names.
- its ment to help minecraft devs or devs for other games.
- ill be setting this up to be an all purpose all file type generation program
- Current plans: Generate jsons and logs
- Future: Generate .txt, .png, .gltf(Based off of an in app 3D custom editor im working on.)
- and basically anything else that devs may need or need placeholders for.
- """
- var popup
- #var HasSave = false
- onready var NewName
- onready var PATH = "user://jsons/"
- onready var thing_to_save = {
- "parent": "minecraft:item/generated",
- "textures": {
- "layer0": "minecraft:item/"+str(NewName)
- }
- }
- onready var BG = $BG
- onready var FILE = $V/H6/FileFile
- onready var CUSTOMIZATION = $V/H6/Customization
- onready var HELPCREDITS = $V/H6/HelpAndCredits
- onready var PREFIX = $V/H2/PREFIX_Edit
- onready var NAME = $V/H3/NAME_Edit
- onready var SUFFIX = $V/H4/SUFFIX_Edit
- onready var AllNames:Array = []
- var Count = 0
- func csv_to_array(csv):
- var array = []
- var item = ""
- for i in csv:
- if i == " ":
- continue
- if i == ",":
- array.append(item)
- item = ""
- else:
- item += str(i)
- array.append(item)
- return array
- func _ready():
- var dir = Directory.new()
- dir.open("user://")
- dir.make_dir("jsons")
- var NewDir = "user://jsons"
- var prefix_csv = $V/H2/PREFIX_Edit.text.replace(" ","_").replace("\n",",").replace(",,",",")
- var adjective_csv = $V/H3/NAME_Edit.text.replace(" ","_").replace("\n",",").replace(",,",",")
- var suffix_csv = $V/H4/SUFFIX_Edit.text.replace(" ","_").replace("\n",",").replace(",,",",")
- var prefix = csv_to_array(prefix_csv)
- var adjective = csv_to_array(adjective_csv)
- var suffix = csv_to_array(suffix_csv)
- for p in prefix:
- for a in adjective:
- for s in suffix:
- NewName = p+"_"+a+"_"+s
- Save(PATH,NewName,thing_to_save)
- print(NewName)
- func _on_Start_confirmed() -> void:
- Configs.HasSave = true
- func Save(PATH : String,NewName, thing_to_save):
- var file = File.new()
- file.open(PATH+NewName+".json", File.WRITE)
- file.store_var(to_json(thing_to_save))
- file.close()
- #Load needs some work
- func Load (PATH:String) -> Dictionary:
- var file = File.new()
- file.open(PATH, File.READ)
- var theDict = file.get_var()
- file.close()
- return theDict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement