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
Project → Fetch Libraries
)tlconfig.lua
file in the project root with the following content:
return {
gen_target = "5.1",
gen_compat = "off",
include = {"**/*.tl"}
}
.tl
files — those can be required from scripts and lua modules as if they were .lua
files 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 main
folder and name it greeter.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.script
file in the main
directory, 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
main.collection
file, add a main.script
Script as a component to some game object.DEBUG:SCRIPT: Hello, Teal!
If you modify teal executable, re-assemble the bin zips:
./make-binaries.sh
If you modify extension code (Java), recompile the jar before commit:
./build_plugin.sh