Teal is a typed dialect of Lua. To get familiar with Teal, please have a look at Teal Tutorial.
-
Add a dependency on a latest release of this extension: https://github.com/defold/extension-teal/tags
-
Fetch Libraries (
Project → Fetch Libraries) -
Create
tlconfig.luafile in the project root with the following content:return { gen_target = "5.1", gen_compat = "off", include = {"**/*.tl"} }
-
Create
.tlfiles — those can be required from scripts and lua modules as if they were.luafiles
With Teal extension added to the project dependency list and /tlconfig.lua file in the project root, we can start using
teal. Assuming you are using an empty project template to try it out, here is how you can start using it:
- Create a file in the
mainfolder and name itgreeter.tl, then write the following code:-- this is Teal, note the type annotations: local template: string = "Hello, %s!" local M = {} function M.greet(s: string): string return template:format(s) end return M
- Create
main.scriptfile in themaindirectory, set it's content to this:-- we are importing the Teal file as if it was Lua local greeter = require("main.greeter") function init(self) -- use the Teal module print(greeter.greet("Teal")) end
- In
main.collectionfile, add amain.scriptScript as a component to some game object. - Run the game. The build process will compile and type check all Teal code, and you will
see the following line in the output:
DEBUG:SCRIPT: Hello, Teal!
If you modify teal executable, re-assemble the bin zips:
./make-binaries.shIf you modify extension code (Java), recompile the jar before commit:
./build_plugin.sh