Using Dependencies
Lua has a community which made a lot of modules for general tasks. You can use them in your Lua scripts.
Modules are hosted and managed using Luarocks. You don't need to setup this tool manually.
Supported Modules
Lua modules should:
- support Lua 5.3
- be pure Lua modules
#
Adding Dependencies to Manifest FileExtend our lua
section with dependencies
:
Dependencies is a list of Luarocks packages. They are described in luarocks format. It looks like:
Version Management
It's strongly recommended to specify versions of your dependencies. Read more about dependencies' contraints here.
#
Using Dependencieslustache is a template engine. Imagine that serial_number
consists of two parts: high and low bits. We could concatenate them using Lua ..
operator, but for education we will use template engine.
- First of all we need require
lustache
module. - Then we can use it to combine
serial_number
.
The essence of the changes in the main.lua
:
Show the whole main.lua
#
Using Existing RockspecIf you are an experienced Lua developer, then you probably already use rockspec. In that case you can use your rockspec file and dependencies will be gotten from relevant section. Example of communication_module
section:
#
Upload BlueprintNow you are ready to upload updated blueprint.