Folder structure

Is there any way to split my haxe traits files into multiple subfolders. For example having one folder called scene1 that contains all the traits for scene1, another one for scene2 and so on, rather than having all the .hx files hanging from the “arm” folder? A proper folder structure is essential for the maintainability of any serious project and games created with armory should be no exception

3 Likes

Currently I’m pretty sure that there is no way to do that yet. It shouldn’t be complicated to add, though. If there isn’t a GitHub issue for it yet, you could create one.

Thank you @zicklag for your reply.

I could not find any examples for doing this in the armory examples or templates, but I just found a way of doing it in armorpaint, purely code-wise by dinamically assigning the traits in the main scene trait. Having a “FlyCamera” haxe class file under a “trait” subfolder you could do this:

iron.App.notifyOnInit(function() {
    ...
    iron.Scene.active.root.addTrait(new arm.trait.FlyCamera());
    ...
});

I guess that there is no blender-compatible way of doing this though, in a more visual manner. You kind of lose the visual connection between object and trait if you go this way.

1 Like

Within the Haxe language it is possible to do this, but I don’t think that the Armory GUI supports it yet. Good idea, though.

As a part of my modding PR I added a new trait type called “External” that lets you specify the class path to the trait to add and bypasses the Haxe script search. That would work for this use-case:

image

image

If you want to try and apply that change I can get you the files so you can get the update. This would just be a temporary fix for it: I think that it should be able to search traits in nested folders as a long term solution.

2 Likes

Hi @zicklag, it seems like @DiegoBM has already created a pull request with that implementation (without external button and it searches on nested folders) early this morning, which is pending approval. I’ve tried it already and it seems to work well. Here the details:

4 Likes

I have implemented subfolder division in Blender by using haxe package syntax (folder.ClassName), for your consideration. It is better explained in the pull request. If anybody is interested can check out if it makes sense for you or not.

4 Likes

Thats cool, but script doesn’t need to be in arm folder, you can use script from outside of arm folder.
If you follow this tutorial -> https://devga.me/tutorials/armory3d/using-external-libraries-in-armory/ and add project.addParameter(anotherScriptFolder.ScriptNameInAnotherfolder); in khafile.js, then you will be able to run the script from another file outside of arm folder, the only catch is you will not be able to select it from blender, but it will still works, I haven’t tried it in armory yet but i knew this by experience in rasteringwithiron, and should work pretty well in armory, see no doubt

You are correct @BlackGoku36, as @Blenderpein mentioned above you can access any source file directly from source, that’s definitely not a problem. This feature though is about implementing folder division directly from Blender while at the same time keeping that nice link between object and trait that @lubos originally implemented for the Blender interface. For that, I based my work on @lubos’ original decision to host source files under the arm package, therefore I also considered “arm” the main package for the game’s sources.

3 Likes

It’s merged now, hooray to @DiegoBM for a cleaner way to manage traits. :slight_smile:

4 Likes

Thank you very much @lubos, this is an awesome project :slight_smile:

3 Likes

I still can’t believe that I brought this up just 1 day ago and it’s already implemented! You guys are an awesome community!! Thank you @DiegoBM for this :smiley:

2 Likes

Yeah i know, was just saying, anyway thats cool :+1:

1 Like

You’re welcome @Blenderpein, lets put our shared effort to put armory in the crowning place it deserves :slight_smile:

2 Likes