- Joined
- Nov 7, 2014
- Messages
- 571
Teal is a typed dialect of Lua. It allows one to annotate Lua declarations with types that are then checked by the 'tl' compiler.
The attached Teal script converts Jass declarations to Teal declarations. You probably want to run it on your 'common.j' / 'blizzard.j' files, like so:
It generates declarations like these (common.j was used as input):
The type declarations are only necessary to make the compiler happy, they don't generate any Lua code. In order for the 'tl' compiler to find these declarations you need to create a 'tlconfig.lua' file:
Running the 'tl' compiler without installing LuaRocks
You need to download the following files:
Then you can run 'tl' like so:
You need a Lua interpreter somewhere in your path though.
The attached Teal script converts Jass declarations to Teal declarations. You probably want to run it on your 'common.j' / 'blizzard.j' files, like so:
Code:
tl run gen-tds-from-jass.tl path/to/file.j > output-file.d.tl -- if you don't redirect, it writes to stdout
It generates declarations like these (common.j was used as input):
Code:
global agent = record end
...
global ConvertRace: function(i: number): race
...
global FALSE <const>: boolean
...
global CreateUnit: function(id: player, unitid: number, x: number, y: number, face: number): unit
The type declarations are only necessary to make the compiler happy, they don't generate any Lua code. In order for the 'tl' compiler to find these declarations you need to create a 'tlconfig.lua' file:
Code:
return {
include = {
'directory/with/teal-type-declarations/',
},
preload_modules = {
'commonj', -- real file name is 'commonj.d.tl'
}
}
Running the 'tl' compiler without installing LuaRocks
You need to download the following files:
Code:
tl - from the Teal repository
tl.lua - from the Teal repository
argparse.lua - from https://github.com/mpeterv/argparse -- dependency for 'tl'
Then you can run 'tl' like so:
Code:
lua tl -h
You need a Lua interpreter somewhere in your path though.