site/wiki/pages/lua.md

52 lines
2.0 KiB
Markdown
Raw Permalink Normal View History

2019-01-07 14:12:07 +00:00
---
author: ~evn
2019-01-08 00:41:19 +00:00
published: true
title: lua
2022-06-14 23:12:00 +00:00
description: set up tools to write lua code
category:
2022-09-29 18:53:09 +00:00
- guides
- tecnical
---
2019-01-07 14:12:07 +00:00
This page will explain how to set up your tilde.team account for
[Lua](https://www.lua.org/) programming.
## Luarocks
[Luarocks](https://luarocks.org/) is a package manager for the Lua, similar to
Python's PIP, Perl's PPM, and other programming languages' package mangers. To
download and install a package from the Luarocks repository type the following
2019-01-07 14:12:07 +00:00
into a terminal:
`luarocks install [package-name] --local`
where [package-name]
is the name of the package you want to install (without square brackets). The
'--local' argument is necessary to install the package to your user folder
rather than the default path of '/usr/local/', which tilde.team users do not
2019-01-07 14:12:07 +00:00
have write access to.
Lua uses the environment variables 'LUA_PATH' and 'LUA_CPATH' to find installed
packages. By default, these paths do not include the paths that Luarocks installs
package to, so the Lua interpreter will not be able to find installed packages.
2019-01-07 14:12:07 +00:00
The `luarocks path` command can be used to modify the LUA_PATH and LUA_CPATH
environment variables to include the paths that Luarocks installs packages to.
The following command will modify the environment variables appropriately:
2019-01-07 14:12:07 +00:00
`eval $(luarocks path --bin)`
Add this to your ~/.bashrc file to make these environment variables always
include the necessary paths.
2019-01-07 14:12:07 +00:00
The version of Luarocks installed on tilde.team is configured for use with Lua
version 5.1, so packages installed with Luarocks will not be usable with lua
2019-01-07 14:12:07 +00:00
5.2.
## Lua Versions
Tilde.team has two versions of the Lua interpreter installed; version 5.1 and
version 5.2. When you type `lua` into a terminal it will run version 5.2 by
2019-01-07 14:12:07 +00:00
default. To run Lua version 5.1 simply type `lua5.1`.
2019-01-07 14:12:07 +00:00
To set the default Lua interpreter to version 5.1 set a bash alias with the
following command:
2019-01-07 14:12:07 +00:00
`alias lua="/usr/bin/lua5.1"`
Add this to your ~/.bashrc file to always use version 5.1 as the default Lua
interpreter.