1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="index,follow">
<meta name="author" content="Alexander Pickering">
<meta name="description" content="Lua4Win - A distribution of the Lua programming language">
<title>Lua4Win</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
<link rel="stylesheet" href="/milligram.min.css"/>
<link rel="stylesheet" href="/tokyo-night-light.css"/>
<script src="/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body><main class="wrapper">
<nav class="navigation">
<section class="container">
<h1 class="title">Lua4Win</h1>
<p>Lua4Win is a distribution the Lua programming language for Windows.</p>
<ul>
<li><a href="#install">Install</a></li>
<li><a href="#rational">Rational</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#luarocks">Luarocks</a></li>
<li><a href="#languages">Sister Languages</a></li>
<li><a href="#advanced">Advanced Usage</a></li>
</ul>
</section>
</nav>
<section class="container" id="install">
<h3 class="title">Install</h3>
<p>You can install it by using the .msi file here.</p>
<a class="button" href="https://cicd.lua4.win/archive/lua4win-dist-lua/latest/lua4win.msi">Download</a>
</section>
<section class="container" id="rational">
<h3 class="title">Rational</h3>
<p>Lua4Win is a distribution of the Lua programming language for Windows. Lua4Win comes with the Luarocks package manager and is a "batteries-not-included" distribution of Lua. Binary packages are built remotely and are downloaded as-needed. The Lua4Win installer contains a copy of <a href="https://luajit.org">LuaJIT</a>, <a href="https://luarocks.org">Luarocks</a>, <a href="https://www.busybox.net">Busybox</a>, and <a href="https://7zip.org">7zip</a>; which allows it to come in at a slim 2MB. Updates and bugfixes to libraries can be done piecemeal instead of requiring new copies of the whole distribution every time a bug gets fixed.</p>
</section>
<section class="container" id="usage">
<h3 class="title">Usage</h3>
<p>After installing, you can launch <code>cmd.exe</code> and run <code>$ lua</code> to get started.</p>
<pre><code class="language-none">$ lua
LuaJIT 2.0.ROLLING -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 AMD fold cse dce fwd dse narrow loop abc sink fuse
> print("Hello, world!")
Hello, world!
></code></pre>
<p>You can use <code>CTRL+C</code> to escape the read-evaluate-print-loop. You can also write Lua programs with your favorite text editor and run them with <code>$ lua filename.lua</code>
<div class="container">
<div class="row">
<div class="column">
note.lua
<pre><code class="language-lua">-- Create a note file with today's date in %APPDATA%
local args = {...} -- extra arguments passed to the program
-- Generate a filename
local note_f = os.getenv("APPDATA")
local today = os.date("%Y-%m-%d")
local note_name = table.concat(args,"-"):gsub("[%W]","-")
local filename = ("%s\note-%s-%s.txt"):format(note_f,today,note_name)
-- Create the file
local fd = assert(io.open(filename,"w"))
assert(fd:close())
-- Open it in notepad
os.execute("notepad.exe " .. filename)</code></pre>
</div>
<div class="column">
<pre><code class="language-bash">$ lua note.lua my first note</code></pre>
</div>
</div>
</div>
<p>Run <code>lua --help</code> for more options for the command line tool, and see the <a href="https://www.lua.org/manual/5.1/manual.html">Lua Manual</a> for extensive documentation of the Lua programming language and standard libraries. Also note <a href="https://luajit.org/extensions.html">LuaJIT's extensions</a></p>
</section>
<section class="container" id="luarocks">
<h3 class="title">Installing Superpowers</h3>
<p>You can use modules that implement more than the standard lua libraries by running the <code>$ luarocks install >module name< </code> command to download and install modules.</p>
<div class="row">
<div class="column">
<pre><code class="language-bash">$ luarocks install easni</code></pre>
</div>
<div class="column">
color.lua
<pre><code class="language-lua">local ansi = require("eansi")
ansi.enable = true
local green = ansi.toansi("green")
print(green .. "> implying you need modules")</code></pre>
</div>
<div class="column">
<pre><code class="language-bash">$ lua color.lua</code></pre>
</div>
</div>
<p> Run <code class="language-bash">$ luarocks --help</code> for more options on the command line tool, and see the <a href="https://github.com/luarocks/luarocks/wiki/Using-LuaRocks">Luarocks wiki</a> for more extensive documentation.</p>
</section>
<section class="container" id="languages">
<h3 class="title">Sister languages</h3>
<p>Lua4Win makes it easy to download other programming languages that are distributed through the <code>luarocks</code> package manager. Simply <code>luarocks install</code> them like you would any other package.</p>
<h4 class="title">Moonscript</h4>
<div class="row">
<div class="column">
<pre><code class="language-bash">$ luarocks install moonscript</code></pre>
</div>
<div class="column">
example.moon
<pre><code class="language-moonscript">class Person
name: "Alex"
greet: => print("Hello, " .. @name)
class World extends Person
name: "World"
with World!
\greet!
</code></pre>
</div>
<div class="column">
<pre><code class="language-bash">$ moon example.moon
Hello, World!</code></pre>
</div>
</div>
<br/>
<h4 class="title">Teal</h4>
<div class="row">
<div class="column">
<pre><code class="language-bash">$ luarocks install tl</code></pre>
</div>
<div class="column">
keys.tl
<pre><code class="language-teal">local function keys<K,V>(xs: {K:V}):{K}
local ks = {}
for k, _ in pairs(xs) do
table.insert(ks, k)
end
return ks
end
local s: {integer:string} = keys({ a = 1, b = 2 })
print(table.concat(s))
</code></pre>
</div>
<div class="column">
<pre><code class="language-bash">$ tl run keys.tl
ab</code></pre>
</div>
</div>
</section>
<section class="container" id="advanced">
<h3 class="title">Advanced Usage</h3>
<p>By default, Lua4Win will install packages in a user-local location, at <code>%APPDATA%/luarocks</code>. You can instead choose to install system-wide packages for all users with the <code class="language-none">--tree system</code> flag, these packages will be located at <code>[INSTALLDIR]/luarocks</code>. You may need to be running as an administrator to install to this location.</p>
<p>Lua4Win's luarocks configuration lives at <code class="language-none">[INSTALLDIR]/config/config-5.1.lua</code>, and is a regular Lua file you can modify.</p>
<p>All of Lua4Win's binary packages are built using mingw64. If you intend to build your own modules they must be built with mingw64 if you want them to interoperate with Lua4Win-distributed Lua.</p>
<p>Some of Lua4Win's packages needed patching or modification, source code is generally mirrored at <a href="https://git.lua4.win">git.lua4.win</a>, and packaging code is kept separate- usually in a <code>*-packaging</code> repo.</p>
</section>
</main></body>
</html>
|