Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/defold/extension-teal

Defold transpilation support for Teal
https://github.com/defold/extension-teal

defold defold-extension defold-library

Last synced: 3 days ago
JSON representation

Defold transpilation support for Teal

Awesome Lists containing this project

README

        

# Teal

[Teal](https://github.com/teal-language/tl) is a typed dialect of Lua. To get familiar with Teal, please have a look at
[Teal Tutorial](https://github.com/teal-language/tl/blob/master/docs/tutorial.md).

# Using teal in your project (Defold 1.8.1+)

1. Add a dependency on a latest release of this extension: https://github.com/defold/extension-teal/tags

image
2. Fetch Libraries (`Project → Fetch Libraries`)
3. Create `tlconfig.lua` file in the project root with the following content:
```lua
return {
gen_target = "5.1",
gen_compat = "off",
include = {"**/*.tl"}
}
```
4. Create `.tl` files — those can be required from scripts and lua modules as if they were `.lua` files

# Examples

## Hello world

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:

1. Create a file in the `main` folder and name it `greeter.tl`, then write the following code:
```lua
-- 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
```
2. Create `main.script` file in the `main` directory, set it's content to this:
```lua
-- 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
```
3. In `main.collection` file, add a `main.script` Script as a component to some game object.
4. 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!
```

# Developing this extension

If you modify teal executable, re-assemble the bin zips:
```shell
./make-binaries.sh
```

If you modify extension code (Java), recompile the jar before commit:
```shell
./build_plugin.sh
```