deepnight / ldtk

Modern, lightweight and efficient 2D level editor
https://ldtk.io
MIT License
3.44k stars 192 forks source link

Rework or provide examples for custom commands #933

Closed GuvBubbs closed 10 months ago

GuvBubbs commented 1 year ago

Custom Commands

You can now define custom commands to be executed at various moments (when the project is loaded, saved etc.). These commands can be used for whatever your own production pipeline requires. Here are some typical examples:

After saving, run a script that parses the JSON and extract all the texts for future localization.
When pressing CTRL-R, run your game.
After saving, parse the project JSON and check if all levels are properly connected, from your game logic perspective.

For obvious security reasons, LDtk will always ask you first if you trust the project and want to allow commands from it.

Despite many efforts, I've not been able to run custom commands on PC.

When I run this command in the command prompt. pdc "C:\Playdate Dev\Comet SDK\Comet\source" "C:\Playdate Dev\Comet SDK\Comet\build\Comet"

It build my game from source and dumps it in the correct folder.

The same command in LDtk gives this error. image

Running from an EXE or batch file also doesn't work. If i add cmd to the start I get this, and it looks like its thinking, but shows no progress. image

When I raised this on discord, @deepnight said...

image

I'm looking to speed up my iteration time so I would love for this to be fixed or for me to be told where i'm going wrong.

Regards

Cammin commented 1 year ago

I am able to make this work by specifying just a file in LDtk for the command to run.
The batch file was in the same path as the LDtk project.
I imagine that then, the batch file could try to execute something else that's more complex.
I imagine that this would also work for running an .exe file, but I have not tried that.

image
image

And then when I ctrl+r:
image

Maybe my test was too simple. It's possible some more complex things don't work, but hopefully they just do

Cammin commented 1 year ago

I can confirm that running applications also works! And the working directory works also. Unfortunately, it only supplies the working directory, and there is no ldtk file path as an environment variable or command line arg.
image

@deepnight This would be a great thing to add to the custom commands: Supply the file name (or whole path) of the LDtk file that's currently open. Because currently my app is unaware of the file context if, for example, there are multiple LDtk files in the same directory.

GuvBubbs commented 10 months ago

Confirmed this is working.

Forgive the long delay.