« Introduction au Lua/Fonctions Table » : différence entre les versions

Contenu supprimé Contenu ajouté
Leutha (discussion | contributions)
Aucun résumé des modifications
Update
Ligne 1 :
{{:Lua/Sidebar}}
This page will contain an explanation of the Lua [[mw:Extension:Scribunto/Lua_reference_manual#Table_library|Table function library]]. The following code will be used as part of the examples.
Lua modules based on the Scribunto/Lua extension are stored in resource pages using the Module: namespace. Each module uses a table to hold functions and variables, and that containing table is returned at the end of the module code.<ref>http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual</ref> This lesson will show you how to use the Lua [[mw:Extension:Scribunto/Lua_reference_manual#Table_library|Table library]] in your scripts.
__TOC__
 
== Prerequisites ==
This lesson assumes you have already completed the [[Lua/Tables| Tables]] lesson.
 
== Create a Lua Script that Uses the Table Library ==
To create a Lua script that uses the Table library:
# Navigate to [[Module:Sandbox]].
# Clear all existing code.
#: It's a sandbox. Everyone is free to play in the sandbox. But if you find another user is actively editing the sandbox at the same time, you may also use Module:Sandbox/Username, where Username is your Wikiversity username.
# Add the following code and save the page:
 
 
<blockquote><pre>
Ligne 40 ⟶ 53 :
return p
</pre></blockquote>
 
== Test Your Lua Script ==
To test your Lua script:
# Navigate to either the [[Module_talk:Sandbox]] page, the [[Wikiversity:Sandbox]] page, or your own user or sandbox page.
# Add the following code and save the page:
<blockquote><pre>
</pre></blockquote>
 
The result should be similar to:
<blockquote>
</blockquote>
 
== Understand Your Lua Script ==
To understand your Lua script:
 
== Conclusion ==
Congratulations! You've now created, tested, and understood a Lua script that uses the Table library. Return to the main [[Lua]] page to learn about other Lua code libraries.
 
== See Also ==
* [[Lua/Tables | Lua Tables]]
 
== References ==
{{reflist}}
 
[[Category: Lua]]
[[Category: Lessons]]
[[Category: Completed resources]]