vnen / godot-tiled-importer

Plugin for Godot Engine to import Tiled Map Editor tilemaps and tilesets
MIT License
834 stars 87 forks source link

Add ability to load maps at runtime #71

Open darkhog opened 6 years ago

darkhog commented 6 years ago

The thing you've made is really great, but I'd like to be able to load maps at runtime (to enable modding), preferably with an API to put resulting stuff under specific node. I'd like also to be able to get all objects in a map as an array that I can then manually iterate through and spawn items and enemies based on object's properties and names.

vnen commented 6 years ago

The thing you've made is really great,

Thanks!

I'd like to be able to load maps at runtime (to enable modding),

This is quite outside the scope of the plugin. It relies on Godot's import system which is only available in-editor, so it won't work on the exported game.

What you can do is manually call the build function with a source path and a dictionary of options:

https://github.com/vnen/godot-tiled-importer/blob/50895eeb0065ce70e3e3b124c6f91f8339350640/addons/vnen.tiled_importer/tiled_map_reader.gd#L64-L66

This function will return the same scene the importer saves (essentially just a root node with the children attached to it). Except it won't run the post-import script. You can iterate this tree with a script and further change it, eventually adding it as children of your game's tree. For this you shouldn't need any API beyond what's provided by Godot itself.

The only thing I can help is by tweaking the build function to be less editor-dependent (though on the top of my head I can't think of anything editor-related there). I can also try to optimize it if it's too slow, but I assume you won't run it every frame anyway.

Another thing you have to consider is that this plugin doesn't do much of input validation, since it's targeted to game developers and rely on Godot's import system. If you want to receive final user input, you have to double-check the validation and also provide useful error messages.

jjhaggar commented 6 years ago

Thank you very much for this plugin @vnen! :D Also, I'm very interested on loading maps at runtime, so please @darkhog , if you make some progress on it could you share it here? :)

darkhog commented 6 years ago

If I could make it on my own, this issue wouldn't even exist! Have a nice day, Dariusz "Darkhog" G. Jagielski

              Dnia 21 marca 2018 09:47 jjhaggar <notifications@github.com> napisał(a):

               Thank you very much for this plugin  github.com @vnen ! :D  

Also, I'm very interested on loading maps at runtime, so please github.com @darkhog , if you make some progress on it could you share it here? :)

— You are receiving this because you were mentioned. Reply to this email directly, github.com view it on GitHub , or github.com mute the thread .

vnen commented 6 years ago

I think I've said enough to help you use this plugin to import maps at runtime. If that's not enough I can try to clarify further and if you stumble upon a problem I can try to help you solve it. Other than that I'm not sure what you expect.