Editor Scripts 🔥: Alpha Release

If it’s similar functionality that logically belongs, I think it should be in the same library.
If it’s not, then they should probably be in separate libraries.

Having checkboxes for each and every script and command, does not seem very user friendly either imho.
Is there an IDE that does this today?

In my experience, if you compare with other IDE’s that allow you to install packages (e.v Sublime, VSCode), they have two features we have yet to support: keyboard short cuts and nested menus.

Using these you can opt to put stuff under your package menu (e.g. “Tools -> Packages -> MyScripts -> …”

Or, you could simply not register commands to any menu, but let the user bind commands to actual short cuts.

Are there any other ways that other IDE’s have solved it?

5 Likes

Blender does. It also has built in search for assets of various kinds. Of course best experience is what we want so maybe some uber lists would be best so people subscribe to one opinionated list that they like, and general quality of life editor scripts are avoided being put into general purpose extensions.

2 Likes

Even though it requires a bit more work for maintaining and would make it a bit harder to find them it is probably better. Most users will probably not want all extensions anyway, so this would end up as the most clean way.

2 Likes

I mean, there’s ofc a sliding scale here, I think in this case I might be biased towards working with native code, whereas I’m not usually as strict when it comes to script code :slight_smile:

2 Likes

We would love to be able to contribute directly to the editor too. I don’t mind getting better with Clojure (or whatever is necessary to work on it). :slight_smile:

11 Likes

No use trying to add these as dependencies for now, but they will work if you simply copy paste the extensions into your project.


I ended up moving the scripts into their own repositories

editor-script-atlas

Adds functionality for creating new atlases and adding images to already existing atlases.
Notes: Uses Python 3.5+ (3.7 recommended) and DefTree.

editor-script-components

Adds functionality for creating a new resource depending on selected component(s).
Notes: Uses Python 3.5+ (3.7 recommended) and DefTree.

editor-script-cleanup

Adds functionality for helping you clean up your project.
Notes: Uses Python 3.5+ (3.7 recommended) and DefTree.

editor-script-monarch

(now part of monarch)
Notes: This is in pure lua!
Adds functionality to create a monarch scene from a gui file.

editor-script-check-dependencies-versions

Not the best at naming

Notes: Does not work against github enterprice, requires python installed.

Print the status of your dependencies as an easy way to see if they are up to date or not. This one is written in python 2.7 therefore it should work on macOS out of the box (and with a python install on windows).
Example output:

Project 'defold-clipboard' is up to date.

Project 'defold-lfs' is out dated, latest version is
  https://github.com/britzl/defold-lfs/archive/1.0.1.zip
  
Project 'extension-gps' is up to date.

editor-script-align

Adds menu buttons under Edit for aligning gui nodes.
Notes: This is in pure Lua! Can currently not get parent of a node, therefore it only works on nodes without parents. Only take Z rotation into account. Can currently not access pivot so it assumes all pivots are Center.
https://imgur.com/tS9fbAD

14 Likes

Great job with all of them.

2 Likes

Following your lead, I’ll keep the other repo for my all in one opinionated grouping.

editor-script-create-sound-component

Allows for creating Defold sound components directly for one or more files from Assets view for wav/ogg

https://github.com/subsoap/editor-script-create-sound-component/archive/master.zip

8 Likes

editor-script-play-sound

Adds a right click context menu for .sound .wav and .ogg files to play them with ffplay. ffplay is a required dependency and must be added to your path.

You can get ffplay from downloading FFmpeg and adding its bin to your path https://ffmpeg.zeranoe.com/builds/ search Google for help if you get stuck!

Problems: files can sometimes be locked with Java when playing!?, you can’t stop audio playing once it begins, you can’t play multiple sounds at once, and must wait for previous sounds to finish, you can’t set the audio level so make sure your system level is low enough

Hopefully some day soon Defold gets built in playing of audio to preview in the editor with start/stop buttons.

https://github.com/subsoap/editor-script-play-sound/archive/master.zip


I’d like to make a version which does not depend on ffplay. Is there any cross platform sound player that could be good to be used to play silently (and maybe be able to play only the first second of a sound) and would have win/mac/linux bins under 1mb together?

4 Likes

I’d like to make a right click -> rename file extension editor script, but need to be able to have a user input popup, and be able to select any file.

At the moment, you have to rename file extensions outside of the editor which is annoying.


It appears that when there are bundle errors the current directory is not the root of the project.

So if I have a bundle error like

/example/test.particlefx
	the tile source '/fake.tilesource' can't be found

I get

on_bundle_finished

ERROR:EXT: ./bundle_finished_fail.mp3: No such file or directory

With

function M.on_bundle_finished(opts)
	print("on_bundle_finished")
	if opts.success then
		return {
			{
				action = "shell", 
				command = {"ffplay", "./bundle_finished_success.mp3", "-loglevel", "warning", "-autoexit", "-nodisp"}
			}
		}
	else
		return {
			{
				action = "shell", 
				command = {"ffplay", "./bundle_finished_fail.mp3", "-loglevel", "warning", "-autoexit", "-nodisp"}
			}
		}	
	end
end

But when bundling is successful the directory is correct.

Sample


No more than 3 consecutive replies are allowed. Please edit your previous reply, or wait for someone to reply to you.

Why was this enabled in this forum? It didn’t use to be enabled. Really annoying! Being forced to merge multiple posts on different subjects is stupid! And what about dev journals, devs will no longer be able to journal properly without having the mercy of replies! :anger:


It would be useful to have some actions allow the editor to continue without waiting. For example, with the play sound related scripts it forces waiting for the sound to finish before allowing to play a different sound. And a similar case happens when bundle finished plays a sound - the bundle folder doesn’t appear until the sound is finished.

1 Like

I shall give you the mercy of reply
keep going :wink:

1 Like

Oh, I wasn’t aware of this. That does indeed seem stupid. I’ll take a look.

1 Like

Would it be possible to override existing functionality of menu buttons with editor scripts? I would love to be able to add a confirmation dialog for doing Project->Rebuild since I often accidentally hit it and on big projects I have no choice but to let it finish.

Better yet I remember old editor concepts which had a build button in the top middle of the main UI. I want to be able to add that in.

1 Like

I found the setting but it’s been like that for ages. The rationale behind Discourse having this setting at all is that Discourse is a forum, not a chat. You’re not supposed to hit Reply after every line of text you write… If users need to reply to their own posts they are encouraged to instead edit their original post. While I do agree with this it’s also kinda silly and I’d rather encourage it some other way, instead of having a hard limit in a forum settings page. I have increased the limit for now at least.

3 Likes

Does it not count for threads you’ve made yourself? Because my dev journal threads had many more than 3 posts in a row.

It makes sense in the chat sense, but it’s much cleaner to have individual unrelated posts as their own post and not all merged.

2 Likes

Are you 100% sure file name is correct? Because when bundling is successful it’s correct, and we have some code path for both success/fail bundle, with only difference being success key…

I’ll need to implement os.rename for lua first…

Hmm. We wait until process finishes, I think that’s sensible default. Can you use a script that launches ffplay in another process?

1 Like

D’oh. I had fail and failure. My mistake!

I was having trouble getting sh scripts to work on Windows. I have gitbash installed with .sh associated with it… I’d like something portable that would work on all platforms Defold supports. Are .sh working for anyone on Windows?

ERROR:EXT: Cannot run program "./scripts/test.sh" (in directory "...\subsoap-editor-scripts"): CreateProcess error=2, The system cannot find the file specified

I don’t think they are working, you’ll need different (probably *.bat?) script on windows and check editor.platform to return path to correct platform-specific script

1 Like

I tried linking to a *.bat file too and it shows the same error for me.

Think you need to run it through cmd, something like cmd /c magic.bat

3 Likes