A JS-Like Scripting Language for a Game Written in Haxe?

Viewed 492

I am developing a game in Haxe/Kha.

All I need is a scripting language that I can use for the game. It has to support things like variables and loops. I am making a JRPG where I have a lot of interact-ables (think loot chests, NPC's, etc.) so I want to script that instead of hard coding it in.

I hope to implement it in a JS-like language. I want to have 1 file per map, and for it to take this kind of format.

5, 10 {
    movement(WALK_RANDOM);
    function interact() {
        textBox("Hello World!");
        giveItem(RUBBER_DUCK);
    }
}

where the 5 and 10 are the x and y of the interact-able.

When I run this what I actually want to do is (in Haxe)

Interactable int = new Interactable(5,10);
int.movement = WALK_RANDOM;
int.interact = function () {textBox("Hello World!"); giveItem(RUBBER_DUCK);} // Can you even do this sort of thing in Haxe?

There would be one script file per map, and many of those interact-able clauses in that file.

TL;DR: I want to use a JS-style (perhaps actually JS?) scripting language to place stuff in my game. How should I put that into my game though, which is written in Haxe?

As you might have seen, I am genuinely lost and have no clue myself what I actually want to do. If there are any questions or parts I could elaborate on, please do point them out.

1 Answers
Related