ldtk icon indicating copy to clipboard operation
ldtk copied to clipboard

[Feature Request] External project pre/postprocessors

Open Gamer-XP opened this issue 2 years ago • 4 comments

General

LDTK got a command system to call code, but it's a bit limited in what I can do with it. I'd like to expand it a bit.

Premise

I want to use LDTK for my GM game, but I still need GM's room editor because there are some features that can't be reproduced with external files (object creation code for example). Plus I got a lot of different entities in the project and it's quite a hassle to try to sync them with LDTK project, especially because I can't use original project sprites inside of LDTK (LDTK require all sprites to be tilesets - I can't use existing differently-sized entity sprites directly).

Details

  1. When project files are changed externally - LDTK should suggest to reload them.
  2. May add "Run Before Load" command. You read main JSON file, see if you got such commands. If you do - drop current loaded stuff, run the command, restart loading project ignoring those commands this time. You don't need to parse whole JSON file too - just commands area. Not sure if HAXE's parse works like this though.
  3. Add extra hotkeys besides Ctrl+R. Maybe you can customize which button to use too. Currently I may want 3 types of commands to use: to import from GM, to export to GM, to start playtesting
  4. Add environment variables you can put as command line arguments: current level name, project path, level path, etc.

Was written before I've found about existing command settings. Suggests using bat files for processing:

At first I thought of writing some way to open GM files with LDTK, but it seems hard to do without knowing Haxe well. So, as an alternative, I got more universal suggestion:

You can put .bat/.sh files with specific names in the same folder as LDTK project file. When you try to open the project file, before that, it calls "on_before_load.bat", then opens the project. When you save the project - it calls "on_after_save.bat". Basically, the purpose is to implement automatic project file synchronization using external application.

My thoughts are like this:

  1. Before project loads, I check GM project file, then modify LDTK project file to add all new entiries/tilesets/rooms that were added in the GM
  2. When saving LDTK project - I do opposite and convert all changes made with LDTK to GM.
  3. I still want both GM and LDTK projects separately because there are some data that can't be converted. If they are separated - I can sync them manually using external tool.

This pipeline, in theory, can be used for any other project type. I don't know that well how .bat files work in Mac and Linux, but, according to similar feature in GM, they have .sh files that does the same thing.

Gamer-XP avatar Sep 25 '23 11:09 Gamer-XP

I've found in-project settings for similar thing. Still didn't test if it will work like I want. When tested, I'll close this issue if it works the way I need, or will report here if this issue is still actual.

Gamer-XP avatar Oct 11 '23 10:10 Gamer-XP

Ok, there if 1 thing that will be required either way, but it is missing now: LDTK should suggest reloading the project if it was changed externally. In case of changed made OnLoad - it should just reload them right away.

Gamer-XP avatar Oct 12 '23 04:10 Gamer-XP

Ok, I've finished base for my LDTK <-> GM tool, connected it with LDTK project. When saving it works just fine - changes are applied to GM project, GM sees the changes and suggests to reload levels. For importing stuff from GM, I added my app's call on Run After Loading. It gets called, but I need to restart LDTK for changes to apply (which also get it called once more).

Ignoring .bat file approach, I think best way will be: Add "Run Befre Loading" option. You read main JSON file, see if you got such commands. If you do - drop current loaded stuff, run the command, restart loading project ignoring those commands this time. You don't need to parse whole JSON file too - just command area. Not sure if HAXE's parse works like this though.

Gamer-XP avatar Oct 25 '23 11:10 Gamer-XP

One more thing about commands: Can you also add some extra hotkey commands, in addition to Ctrl+R? Also, for command line arguments, could be good if you can receive name of the level you're currently editing - so you can make a playtest command that way.

Gamer-XP avatar Oct 31 '23 11:10 Gamer-XP