Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Lua
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Syntax === The classic [["Hello, World!" program]] can be written as follows, with or without parentheses:<ref>{{cite web |url=https://www.lua.org/pil/1.html |title=Programming in Lua : 1}}</ref>{{efn|Syntactic sugar, a table construct or literal string following an identifier is a valid function call.<ref>{{cite web |url=https://www.lua.org/manual/5.0/manual.html#2.5.7 |title=Lua 5.0 Reference Manual, 2.5.7, Function Calls}}</ref>}} <syntaxhighlight lang="lua"> print("Hello, World!") </syntaxhighlight> <syntaxhighlight lang="lua"> print "Hello, World!" </syntaxhighlight> The declaration of a variable, without a value. <syntaxhighlight lang="lua"> local variable </syntaxhighlight> The declaration of a variable with a value of 10. <syntaxhighlight lang="lua"> local students = 10 </syntaxhighlight> A [[Comment (computer programming)|comment]] in Lua starts with a double-hyphen and runs to the end of the line, similar to [[Ada (programming language)|Ada]], [[Eiffel (programming language)|Eiffel]], [[Haskell]], [[SQL]] and [[VHDL]]. Multi-line strings and comments are marked with double square brackets. <syntaxhighlight lang="lua"> -- Single line comment --[[ Multi-line comment --]] </syntaxhighlight> {{anchor|Factorial example}}The [[factorial]] function is implemented in this example:<!-- referred to elsewhere in this article --> <syntaxhighlight lang="lua"> function factorial(n) local x = 1 for i = 2, n do x = x * i end return x end </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Lua
(section)
Add topic