roblox-hx

A tool for compiling Haxe source code into lua to be used in roblox games.
https://github.com/Davvex87/roblox-hx/

To install, run:

haxelib install roblox-hx 1.3.0 

See using Haxelib in Haxelib documentation for more information.

README.md

Roblox-HX

Haxe License Version

A powerful Haxe toolchain that enables Roblox game developers to write their games using the Haxe programming language and compile them to Lua for use in Roblox Studio. Leveraging Haxe's built-in Lua transpiler, roblox-hx provides 100% language feature coverage with type safety and modern development tooling.

โœจ Features

  • Full Haxe Language Support: Utilizes reflaxe.lua for the most complete and efficient lua output possible
  • Type Safety: Catch errors at compile-time with Haxe's powerful type system
  • Rich API Coverage: Comprehensive externs for Roblox services and data types
  • Project Templates: Quick-start templates for different project types
  • Rojo Integration: Seamless integration with Rojo project management
  • Macro Compatible: Leverage the power of Haxe macros for task automation and compile-time type manipulation
  • Cross-Platform: Works on Windows, macOS, and Linux

๐Ÿš€ Quick Start

Prerequisites

Installation

haxelib --global install roblox-hx
haxelib --global run roblox-hx setup
roblox-hx version

Creating Your First Project

roblox-hx create

Note, you must run the create command inside an empty folder or pass the path of an empty folder as the first argument. You can bypass this restriction by providing the flag -f.

Building

roblox-hx compile

๐Ÿ“š Available Commands

CommandDescription
roblox-hx create [path]Create a new project with templates
roblox-hx compileBuild Haxe source to Lua
roblox-hx cleanRemove build leftovers
roblox-hx setupAppend library to binaries for quick access
roblox-hx versionDisplay version information
roblox-hx helpShow available commands

๐ŸŽฏ API Coverage

Roblox-HX provides comprehensive externs for Roblox's entire API. Due to certain limitations with Haxe's static typing system, some API has been truncated behind Dynamic types, use type casting or wrappers to get around. All Lua and Roblox's globals get automatically imported into your Haxe code so you dont have to worry about complex imports.

๐Ÿ“– Example Usage

Basic Client Script

// src/client/Client.hx
package client;

import rblx.instances.Part;

class Client
{
    @:topLevelCall
    public static function main()
    {
        var player = Services.players.localPlayer;
        trace("Hello, " + player.name + "!");

        // Create a part
        var part:Part = new Part();
        part.position = new Vector3(0, 10, 0);
        part.brickColor = BrickColor.red();
        part.parent = workspace;
    }
}

Server Script with Events

// src/server/Server.hx
package server;

import rblx.instances.Tool;
import rblx.instances.Player;

class Server
{
    @:topLevelCall
    public static function main()
    {
        Services.players.playerAdded.connect(Server.onPlayerAdded);
    }

    private static function onPlayerAdded(player:Player):Void
    {
        trace("Player joined: " + player.name);

        // Give player a starting tool
        var tool:Tool = new Tool();
        tool.name = "Sword";
        tool.parent = player.findFirstChildWhichIsA("Backpack");
    }
}

Shared Data Class

// src/shared/Data.hx
package shared;

class GameConfig
{
    public static final MAX_PLAYERS = 20;
    public static final SPAWN_POSITION = new Vector3(0, 5, 0);
    public static final GAME_DURATION = 300; // seconds
    
    public static function getWelcomeMessage():String
    {
        return "Welcome to the game!";
    }
}

๐Ÿ—บ๏ธ Roadmap

Check out our roadmap to see what's coming next:

  • [x] Service wrapper
  • [ ] Dynamic types from string (mostly for the first argument of findFirstChildWhichIsA)
  • [ ] Utility wrappers
  • [ ] Better Luau externs support
  • [ ] Rich library support
  • [ ] Built-in project management tool
  • [ ] Comprehensive documentation wiki (gh-pages)

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and test thoroughly
  4. Submit a pull request with a clear description

๐Ÿ—๏ธ Building from Source

If you want to contribute or modify roblox-hx:

# Clone with submodules and setup haxelib dev environment
git clone https://github.com/Davvex87/roblox-hx.git --recurse-submodules
cd ./roblox-hx
haxelib --global dev roblox-hx .

# Install dependencies
haxelib --global install hmm
hmm install

# Build the neko executable
haxe ./build.hxml

# Generate API externs (if needed)
cd api-generator
haxe ./build.hxml
neko ./run.n

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

  • ๐Ÿ“– Wiki (Coming soon)
  • ๐Ÿ› Issues - Report bugs and request features
  • ๐Ÿ’ฌ Discussions - (Coming soon)
Contributors
Davvex87
Version
1.3.0
Published
8 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code โ€” and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

โŒ‚