0 votes


I want to use Tiled Map Importer Plugin. It is only available for 2.x now.

How can I refactor the code to get the job done?

func _on_ImportTilemap_confirmed():
var alert = get_node("ErrorAlert")
var valid = validate_options()
if valid != "OK":

var imd = ResourceImportMetadata.new()
imd.set_option("post_script", get_node("MainDialog/PostImportScript/Path").get_text().strip_edges())

for opt_code in options:
    var opt = options[opt_code]
    if opt.type == TreeItem.CELL_MODE_CHECK:
        imd.set_option(opt_code, opt.item.is_checked(1))
    elif opt.type == TreeItem.CELL_MODE_STRING:
        imd.set_option(opt_code, opt.item.get_text(1))
    elif opt.type == TreeItem.CELL_MODE_CUSTOM:
        imd.set_option(opt_code, opt.item.get_metadata(1))

var f = File.new()
imd.set_source_md5(0, f.get_md5(imd.get_source_path(0)))

var err = import_plugin.import(get_node("MainDialog/Target/Path").get_text(), imd)

if err != "OK":
    alert.set_text("Error when importing:\n%s" % [err])

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.