[SOLVED] Scripting/coding with Blender's script editor?

Not sure if this should go in here or general, and I couldn’t find a topic here on it, but what would it take for Blender’s built-in script editor to handle at least basic Haxe scripting for Armory projects?
I know it supports syntax highlighting for Python, but (being a non-coder) I’m not sure what it would be missing besides quality highlighting for Haxe.

Hello. @ timodriaan made a good explanation a while back on this topic.

Note: Kode Studio is currently no longer developed, so it may be best to ignore that reason reference.

1 Like

Thank you for the link. He spelled out what I suspected, but I was surprised he said it would still technically work. Using a dedicated editor makes sense for when you’re doing almost nothing but coding for long periods of time, but being able to take advantage of the integrated workflow would be useful for solo devs or when doing smaller projects.

The issues I can see being solved through either the Armory3D addon or a separate addon are:
*No syntax hightlighting for Haxe
*No autocompletion

But, the “No other editor plugins for Haxe” point is one I don’t understand the impacts of, since I have no experience coding in Haxe or VSCode(ium). My first thought is that it would be comparitively very impractical to implement it in Blender’s text/script editor, versus the points above.

Also, “There is no editor “project” which lets you quickly see all files or search in them” is something I’m not quite sure how comparable the script list the text editor offers is to the afforementioned “project” component to VSC.

Anyway, I think it would likely be worth it to have those first two features (even the first, to begin with) for light coding. It would probably also help tutorials be easier, since newcomers wouldn’t have to install much extra stuff. And it would help it to be more integrated like some other game engine SDKs.
How hard to you think adding the syntax highlighting would be? Autocomplete sounds a lot harder, since I don’t think the text editor offers that even for Python, currently. But that could be a good project for some other addon developer for Blender (rather than Armory, specifically).

The unfortunate thing is that Blender’s Text Editor syntax highlighting file is embedded into its source. Because of this, to my knowledge, we cannot add Haxe syntax highlighting without modifying Blender’s source and distributing it as a fork, like with UPBGE.

Syntax highlighting source: https://github.com/blender/blender/tree/master/source/blender/editors/space_text
Good explanation: https://blender.stackexchange.com/a/146587

I’m not sure if we’re thinking of the same VSCode element, but VSCode does allow workspaces, which are defined project paths that allow you to quickly view, select, modify, rename, etc. quickly.

Haxe is a high-level language, like Python is. That means it’s already a “easy to learn” language (it’s still rather complex, I agree, especially for begineers).

The SDK contains a lot of extra files so that users can easily export to almost any platform without extra downloading.

1 Like

Exactly, and even if it was possible I think that it wouldn’t be worth the work for Armory. Blender’s editor really is just a simple text editor, nothing more. For more one would use an actual IDE (even though VSCode also isn’t technically an IDE by default).

There is the Kha Extension Pack for example that contains plugins for many different projects in the Kha ecosystem. It will recognize your khafile.js, add auto-completion, adds build configurations to build from within VSCode and adds the necessary Haxe plugins to allow debugging etc. So yes, you’re right that it would be really impractical if not completely impossible to implement all this in Blender.

A little addition to the workspaces thing: you don’t even need to use workspaces for the Kha plugins to work, as long as you have opened a project folder with a khafile.js it will provide all the things you need. As @ RPaladin wrote, it’s different to Blender in the way that you can search through all project files very easily (“Ctrl + Shift + F”), you can directly jump to the definition of some function or variable for example with “Ctrl + left click” on said function/variable and so on, even if the sources aren’t part of the folder you’ve opened (for example the SDK sources are outside of your project’s folder). Compilation errors and warnings are displayed in the lines in which they occur, and the list goes on and on. So there is a lot of cool stuff that makes your life much easier that doesn’t exist in Blender :slight_smile:

2 Likes

Ah, okay. That puts this out of Armory completely. Maybe I’ll raise this issue in more “proper” Blender circles to allow external highlighting lists to be used, just in case there are other projects that may want that feature (IDK).

No, we’re not, because I had no frame of reference to begin with. Haha… Mainly, I was thinking of scripting in regards to game logic programming, versus doing intensive project coding for Armory.

Yeah, I meant not having to download and install a separate code editor, plugins for it, and get it set up in Blender. People wanting to follow an easy tutorual for simple text scripting would be able to just do it with the Text Editor built in (in my hypothetical scenario).

Thanks for actually doing research into the syntax highlighting! That was more than I was expecting.

2 Likes

That’s exactly the use case I was thinking: light scripting/coding/programming. Instead of having to open a separate studio, someone could hammer out some stuff for a basic game project or (another ideal) make new logic nodes. But, for something like modifying the renderer or developing a new feature, you could use a full-blown coding studio (like VSC).

After reading those features, yes, that is completely beyond the scope of what I was envisioning someone doing inside of Blender.

For sure. I guess my focus is less on Blender Supremacy and more on Blender Sufficiency. Like with the Blender vs ZBrush debate, most people agree that ZBrush is preferred when the only thing you’re doing is sculpting, but if you are doing more, then Blender is better. But, even then, if you don’t have ZBrush, Blender is going to meet most of your needs just fine.

With Armory, we already have a lot of separation, especially with the viewport player being broken for now, as well as the UI editing tool, Armor Paint, and also the text-based coding. It’s less that I have anything particularly against these tools, themselves (I think Armor Paint is a good idea and Lubos seems to be doing a good job delivering on it), and more that there’s a lot that’s going against the premise, or “promised” design philosophy, of Armory3D+Blender delivering on an (almost) entirely integrated workflow environment and SDK, or “zero-distance pipeline” as I call it.

I’d still like to see it become viable to do some scripting in Blender’s built-in editor, someday, mainly for this reason. It’s not a 1:1 replacement for the Blender Game Engine like UPBGE largely is, but being able to reclaim the advantages that the BGE offered is, in my mind, an etremely worthy goal.

Well, that’s my rant. Maybe once the Blender guys have finished migrating to and setting everything up on Gitea, I’ll poke around and see if an opportunity comes up to suggest making it easier to use custom syntax highlighting lists. Actually, maybe Right-Click Select might be a better place to start? Hmm…

1 Like