Using External Libraries in Armory

In this quick tutorial, we are going to look at how to use external Haxe libraries in your Armory game. The process is fairly simple but not really intuitive.  First, you need to acquire a library. In this demonstration, I am going to use the haxe-strings library. Find the GitHub link of the repository.  Next in your project directory, create a folder called Libraries. In a terminal change into the newly created library and clone your repository using the command:

git clone path/to/

Now we need to let Armory/Kha know that we want to use this newly added library. In order to do this, we add a text data file in Blender. Switch to a Text Editor window:

Text Editor Window

Now click the New button:

New Window - Text Editor

Name the text block, like so:

Text Block

Now enter the following text:


Next, we need to tell Armory about our extension to the khafile. In the Scene settings panel, locate the Modules section and add your text block to the Khafile section, like so:

Scene Settings Panel - Using External Libraries in Armory

This tells Armory/Kha about our added library, this text will be added to the auto-generated khafile.js, used by the kha build engine. Now we can use the external library in our Haxe code, like so:

package arm;
using hx.strings.Strings;

class MyTrait extends iron.Trait {
  public function new() {
    var set = new hx.strings.collection.StringSet();
    set.add("Hello World");
    set.add("Goodbye World");

Please note that for some reason Kode Studio may have trouble finding your code until you do a first build, and even after that may give you some false warnings about your using statement not being found. I am honestly not sure why but it seems like a bug.

Like what you see?...pass it on!

Scroll to Top