How to create a simple Lua extension?

#1

Feeling very silly, because I read it months before somewhere and was very easy. Now I can’t find it in docs or forum, all I get is about native extensions.

Was something about declaring some of my folders as extension somehow. Then share the project on github. That’s simple what I want to do, to share some Lua modules between my projects and to the public.

Regards

0 Likes

#2

Look at this project as an example

An important thing to do is include a game.project in the root with the folders you want to include when the project’s zip is added as a dependency.

[library]
include_dirs = defmath

Then in the Lua module the general pattern is

local M = {}

...

return M

For example https://github.com/subsoap/defmath/blob/master/defmath/defmath.lua

1 Like

#3

Perfect! That’s what I needed. And perfect example.

The right keyword to search is Library instead of Extension, that was my confusion. Was there all the time :smiley: : https://defold.com/manuals/libraries/

Thank you!

2 Likes