Skip to content

Node module to encode and decode Defold files

License

Notifications You must be signed in to change notification settings

Insality/defold-parser

Repository files navigation

Github-sponsors Ko-Fi BuyMeACoffee

CI/CD npm

Defold Parser - node module to encode and decode Defold files.

Install

To install defold-parser use npm.

npm install --save defold-parser

For update defold-parser you can use

npm update --save defold-parser

Usage

Add require line to your .js script:

const defold_parser = require("defold-parser")

All available API is:

// Parse any Defold file (go, gui, collection, particlefx, etc)
let object = defold_parser.load_from_file([path_to_defold_file])

// Save object to the Defold format
defold_parser.save_to_file([path_to_file], [object])

// You can pass text string directly
let object = defold_parser.decode_object([defold_text_string])

// And get Defold encoded text directly too
let defold_text_string = defold_parser.encode_object([js_object])

Every Defold parsed struct is array, even for single fields. To access any field you should access it on first array index. For example:

let parsed_collection = defold_parser.load_from_file("./tests/files/collection.collection")
let instance = parsed_collection.embedded_instances[0]

assert(instance.id[0] == "tile")
assert(inner_component.id[0] = "sprite")
assert(inner_component.type[0] = "sprite")

To know, which fields you wanna edit, see the file struct you parsing or just use console.log in development 😄

License

Issues and suggestions

If you have any issues, questions or suggestions please create an issue or contact me: insality@gmail.com

❤️ Support project ❤️

Please support me if you like this project! It will help me keep engaged to update this project.

Github-sponsors Ko-Fi BuyMeACoffee

About

Node module to encode and decode Defold files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published