Skip to content
ktox logo lua language logo

ktox-lua: Kotlin → Lua transpiler.

ktox-lua allows you to write Kotlin code and transpile it to Lua, enabling the use of Kotlin's powerful language features (like classes, null safety, and scope functions) in environments where Lua is the primary scripting language (e.g., Dota 2, Roblox, or other embedded systems).

Key Features

  • Classes and Inheritance: Full support for Kotlin classes, constructors, init blocks, single inheritance, and interfaces.
  • Special Class Types: Transpilation of data class, enum class, and object declarations.
  • Null Safety: Transpiles Kotlin's null-safety operators (?., ?:, !!) and smart casts (is, !is) into robust Lua checks.
  • Comprehensive Standard Library: Includes Lua implementations for dozens of Kotlin standard library functions:
    • Collections: map, filter, fold, reduce, groupBy, associateBy, zip, flatten, and more.
    • Scope Functions: let, run, with, apply, also, takeIf, takeUnless.
    • Math & Time: Random, UUID, and basic datetime support.
  • Operator Overloading: Full support for overloading arithmetic, comparison, and indexing operators (get/set), as well as invoke and iterator.
  • Infix Functions: Supports both standard and user-defined infix functions.
  • Advanced Control Flow: if/when as expressions, for loops with ranges (.., until, downTo, step), and continue support via Lua goto.
  • Source Maps: Full source mapping support for easier debugging of transpiled Lua code back to Kotlin source.
  • Dota 2 Integration: Specific features for Dota 2 VScript development, such as @Dota2Class and @NativeName annotations.