[unchecked revision] | [checked revision] |
No edit summary |
m (Add to category "Eco data files".) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Documentation== | == Documentation == | ||
{{Data file module}} | |||
The data file is currently used in at least the following modules: | |||
* [[Module:Infobox_Animal]]: see [[Template:Infobox Animal]] for more details. | |||
* [[Module:Table Animals]]: see [[Template:Animals Table]] for more details. | |||
* [[Module:Table Fish]]: see [[Template:Fish Table]] for more details. | |||
== Usage == | |||
<syntaxhighlight lang="lua"> | |||
-- Load data only once per page. (Do no use require()) | |||
local AnimalData = mw.loadData("Module:AnimalData") | |||
-- Assert that some data was received, otherwise throw an error. | |||
assert(AnimalData.animals, "Failed to load data from Module:AnimalData!") | |||
-- You may then use data from this module in your script. For example: | |||
local agoutiData = AnimalData.animals["Agouti"] | |||
-- Or to iterate over the table, you can do this: | |||
for animalName, data in pairs(AnimalData.animals) do | |||
-- animalName now contains the name of the animal in English. | |||
-- data is the data table for that animal. | |||
end | |||
</syntaxhighlight> | |||
<includeonly>[[Category:Eco data files]]</includeonly> |
Latest revision as of 12:43, 26 February 2022
Documentation[edit source]
DO NOT manually edit this page!
This module is a data file that is used to automate information throughout the Eco Wiki using various Lua Modules. If you would like to see more information generated on a data page request it on the Eco Contribution Wiki Discord server.
The data file is currently used in at least the following modules:
- Module:Infobox_Animal: see Template:Infobox Animal for more details.
- Module:Table Animals: see Template:Animals Table for more details.
- Module:Table Fish: see Template:Fish Table for more details.
Usage[edit source]
-- Load data only once per page. (Do no use require())
local AnimalData = mw.loadData("Module:AnimalData")
-- Assert that some data was received, otherwise throw an error.
assert(AnimalData.animals, "Failed to load data from Module:AnimalData!")
-- You may then use data from this module in your script. For example:
local agoutiData = AnimalData.animals["Agouti"]
-- Or to iterate over the table, you can do this:
for animalName, data in pairs(AnimalData.animals) do
-- animalName now contains the name of the animal in English.
-- data is the data table for that animal.
end