Editor Scripts 🔥: Alpha Release

This all seems like a great start from quickly playing with it. It feels powerful yet minimalist as well.

My personal requests:

  • viewport interaction (manipulators custom drawing in the viewport). Want to draw splines directly in it.
  • custom property panels.
2 Likes

I managed to get it to work, but I have no idea what I did :expressionless: . Going to play around with it some more.

1 Like

Huh, used to work for me, although I’m not on Windows and we probably expect forward slashes, while lua on Windows asks backward slashes…

1 Like

Ah, darn I thought I tried that. Sure enough, a forward slash instead of a dot works.

Yayy !! It’s so good to have editor scripts :sparkling_heart:

2 Likes

I have finally had some time to play around with this! My experience is that though even a lot of things are missing you can still do a quite a bit with some help from python.

The things that would enable me to do a lot more right now is (in order):

I would like to be able to get a “name id” of a selected embedded game object #2790. This would enable me to do a lot of things, because this would mean I could find the item in a text file and then do whatever I want with it.

Ability to query both open file and selection #2784. I was able to make a script that adds all selected images to an existing atlas that was also selected. It would be a nicer if I could add the images to the currently open atlas.

A way to get user input #2786, this would make it so that I can create files with names decided by the user. One of the scripts I made creates a “monarch scene” (collection, gui_script, and gui) but it requires that you have already made a gui scene, it would be nicer if I could popup a dialog asking for the name and then create all 3 items.

A not as important one is that directories should also be resources 2787. This would enable me to right click on a folder and “batch” do things with it instead of having to open the folder and then selected everything in it.


I was able to do a lot of things with the help of python and DefTree: A python module for editing Defold files. I would totally recommend it when doing things like this (until we get something like it for lua), it was super quick to get a script that did fairly complex things up and running. Small disclaimer I made deftree.

If someone wants to see the different scripts they are in this repository

12 Likes

Starting my contributions!

Create sound components based on right clicking wav or ogg files in the Assets view. You can select multiple and create them all at once based on the path and filename of each. It does the same as the standard .sound component field wise. Pure Lua so does not have any warnings.

I’m not sure if it’s possible but if I could get user input then I could let them define the default group which would be useful.

12 Likes

It’s really powerful now that extensions/libraries can provide editor extension scripts to simplify setup of extension/library concepts or structures. I need to go through my libraries and see if there’s some workflows that could be simplified by also providing an editor script.

4 Likes

It would be useful if anyone with some free time and understanding of what editor scripts are currently capable of / likely to become capable of went through the issues https://github.com/defold/editor2-issues/issues and compiled a list of those which could probably be solved with editor scripts.

There needs to be a standard way to enable/disable selected editor scripts included from dependencies.

Copying my reply here as well:

Instead of exposing a bunch of commands, you can expose a bunch of functions each returning a command, so users of your library can have their own get_commands calling into you.

3 Likes

That seems not very user friendly for general editor quality of life stuff? Maybe that kind of file should be an editor file with check boxes somehow.

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.

editor-script-components

Adds functionality for creating a new resource depending on selected component(s).

$.wav               => $.sound  
$.ogg               => $.sound  
$.json and $.atlas  => $.spinescene
$.spinescene        => $.spinemodel  

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.

editor-script-distribute

Adds menu buttons under Edit for distributing gui nodes.
Notes: This is in pure Lua! Can currently not get parent of a node, therefore it only works on nodes without parents. Can currently not access pivot so it assumes all pivots are Center.

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