summaryrefslogtreecommitdiff
path: root/html/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'html/index.html')
-rw-r--r--html/index.html143
1 files changed, 143 insertions, 0 deletions
diff --git a/html/index.html b/html/index.html
new file mode 100644
index 0000000..3e1576c
--- /dev/null
+++ b/html/index.html
@@ -0,0 +1,143 @@
1<html lang=en>
2 <head>
3 <link rel="stylesheet" href="/milligram.min.css"/>
4 <link rel="stylesheet" href="/tokyo-night-light.css"/>
5 <script src="/highlight.min.js"></script>
6 <script>hljs.highlightAll();</script>
7 </head>
8 <body><main class="wrapper">
9 <nav class="navigation">TODO</nav>
10 <header class="header"><section class="container">
11 <h1 class="title">Lua4Win</h1>
12 </section></header>
13 <section class="container">
14 <p>Lua4Win is a distribution the Lua programming language for Windows.</p>
15 <a class="button" href="https://cicd.lua4.win/archive/lua4win-dist-lua/latest/lua4win.msi">Download</a>
16 </section>
17 <section class="container">
18 <h3 class="title">Rational</h3>
19 <p>Unlike alternative distributions, Lua4Win comes with the Luarocks package manager and is a "batteries-not-included" distribution of Lua. Binary packages are built in the cloud and can be 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 can be done piecemeal instead of requireing new copies of the whole distribution every time a bug gets fixed.</p>
20 </section>
21 <section class="container">
22 <h3 class="title">Usage</h3>
23 <p>After installing, you can launch <code>cmd.exe</code> and run <code>$ lua</code> to get started.</p>
24 <pre><code class="language-none">$ lua
25LuaJIT 2.0.ROLLING -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
26JIT: ON CMOV SSE2 SSE3 SSE4.1 AMD fold cse dce fwd dse narrow loop abc sink fuse
27> print("Hello, world!")
28Hello, world!
29></code></pre>
30 <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>
31 <div class="row">
32 <div class="column">
33 note.lua
34 </div>
35 </div>
36 <div class="row">
37 <div class="column">
38 <pre><code class="language-lua">-- Create a note file with today's date in %APPDATA%
39local args = {...} -- extra arguments passed to the program
40-- Generate a filename
41local notes_folder = os.getenv("APPDATA")
42local today = os.date("%Y-%m-%d")
43local note_name = table.concat(args,"-"):gsub("[%W]","-")
44local note_filename = string.format("%s\note-%s-%s.txt",notes_folder,today,note_name)
45-- Create the file
46local fd = assert(io.open(note_filename,"w"))
47assert(fd:close())
48-- Open it in notepad
49os.execute("notepad.exe " .. note_filename)</code></pre>
50 </div>
51 <div class="column">
52 <pre><code class="language-bash">$ lua note.lua my first note</code></pre>
53 </div>
54 </div>
55 <p>Run <code>lua --help</code> for more options for the command line tool, and the <a href="https://www.lua.org/manual/5.1/manual.html">Lua Manual</a> for extensive documentation of the Lua programming language. Also note <a href="https://luajit.org/extensions.html">LuaJIT's extensions</a></p>
56 </section>
57 <section class="container">
58 <h3 class="title">Installing Superpowers</h3>
59 <p>You can use modules that implement more than the standard lua libraries by running the <code>$ luarocks install &gt;module name&lt; </code> command to download and install modules.</p>
60 <div class="row">
61 <div class="column">
62 color.lua
63 </div>
64 </div>
65 <div class="row">
66 <div class="column">
67 <pre><code class="language-lua">local eansi = require("eansi")
68eansi.enable = true
69print(eansi.toansi("green") .. "> implying you need modules" .. eansi(""))</code></pre>
70 </div>
71 <div class="column">
72 <pre><code class="language-bash">$ luarocks install eansi
73
74$ lua color.lua</code></pre>
75 </div>
76 </div>
77 <p> Run <code>luarocks --help</code> for more options on the command line tool, and the <a href="https://github.com/luarocks/luarocks/wiki/Using-LuaRocks">Luarocks wiki</a> for more extensive documentation.</p>
78 </section>
79 <section class="container">
80 <h3 class="title">Sister languages</h3>
81 <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>
82 <h4 class="title">Moonscript</h4>
83 <div class="row">
84 <div class="column column-offset-33">
85 example.moon
86 </div>
87 </div>
88 <div class="row">
89 <div class="column">
90<pre><code class="language-bash">$ luarocks install moonscript</code></pre>
91 </div>
92 <div class="column">
93<pre><code class="language-moonscript">class World
94 greet: => print("Hello, world!")
95
96with World!
97 \greet!</code></pre>
98 </div>
99 <div class="column">
100<pre><code class="language-bash">$ moonscript example.moon
101Hello, world!</code></pre>
102 </div>
103 </div>
104 <br/>
105 <h4 class="title">Teal</h4>
106 <div class="row">
107 <div class="column column-offset-33">
108 keys.tl
109 </div>
110 </div>
111 <div class="row">
112 <div class="column">
113 <pre><code class="language-bash">$ luarocks install tl</code></pre>
114 </div>
115 <div class="column">
116 <pre><code class="language-teal">local function keys<K,V>(xs: {K:V}):{K}
117 local ks = {}
118 for k, v in pairs(xs) do
119 table.insert(ks, k)
120 end
121 return ks
122end
123
124local s: {number:string} = keys({ a = 1, b = 2 })
125print(table.concat(s))
126</code></pre>
127 </div>
128 <div class="column">
129 <pre><code class="language-bash">$ tl keys.tl
130ab</code></pre>
131 </div>
132 </div>
133 </section>
134 <section class="container">
135 <h3 class="title">Advanced Usage</h3>
136 <p>Lua4Win allows you to install system-wide packages with the <pre><code>--tree system</code></pre> flag, these packages will be located at <pre><code>[INSTALLDIR]/luarocks</code></pre>. You may need to be running as an administratior to install to this location.</p>
137 <p>Lua4Win's luarocks config lives at <pre><code>[INSTALLDIR]/config/config-5.1.lua</code></pre></p>
138 <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 operate with Lua4Win-distributed Lua.</p>
139 <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 seperate, usually in a repo <pre><code>*-packaging</code></pre></p>
140
141 </body>
142</html>
143