User:Econterms/Lua practice

From Wikipedia, the free encyclopedia
Lua training at Wikimania 2019

Example 1[edit]

Hello world.

If the module didn't have the p. syntax, we'd get an error about a "nil value" and an "export table" because of something about the Wikimedia implementation of Lua which is called Scribuntu. Arrays and lists are "tables" in Lua. All arguments to Lua and return values from Lua are strings.

Example 2[edit]

Example 2a: Hello from Lua to my friend "Peter".

Example 2b: Hello from Lua to my friend Jimbo.
(Note functionality would be different for name="" or name=)

In this example we use a MediaWiki variable, the present page title: Hello from Lua to my friend Econterms/Lua practice.

Example 3[edit]

Converting from 10.5 Celsius: It's 50.9 Fahrenheit

Example 4[edit]

Shows a loop: Times table
3
6
9
12
15
18
21
24
27
30