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,
initblocks, single inheritance, and interfaces. - Special Class Types: Transpilation of
data class,enum class, andobjectdeclarations. - 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.
- Collections:
- Operator Overloading: Full support for overloading arithmetic, comparison, and indexing operators (
get/set), as well asinvokeanditerator. - Infix Functions: Supports both standard and user-defined
infixfunctions. - Advanced Control Flow:
if/whenas expressions,forloops with ranges (..,until,downTo,step), andcontinuesupport via Luagoto. - 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
@Dota2Classand@NativeNameannotations.