Module:AnimalData/doc: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
(→‎Documentation: Improve documentation, add usage example, add to new category "Eco Data File".)
Line 1: Line 1:
==Documentation==
== Documentation ==
<big style="color:red;">'''DO NOT manually change this page!'''</big>
{{No manual edits}}


This file is a Datafile that is used to Automate information throughout the Eco Wiki using various Modules.
This module is a data file that is used to automate information throughout the Eco Wiki using various [//wiki.play.eco/en/Special:AllPages?from=&to=&namespace=828 Lua Modules].


The Module:AnimalData is currently used in:
The data file is currently used in at least the following modules:
*[[Module:Infobox_Animal]], See [[Template:Infobox_Animal]] for more details.
* [[Module:Infobox_Animal]]: see [[Template:Infobox_Animal]] for more details.
* [[Module:List_Animals]]: see [[Template:AnimalList]] for more details.
* [[Module:List_Fish]]: see [[Template:FishList]] for more details.


If you would like to see more information generated on a Data page request it on the ECO Contribution Wiki Discord, https://discord.gg/ynCVtN5.
If you would like to see more information generated on a data page request it on the [https://discord.gg/ynCVtN5 Eco Contribution Wiki Discord].
 
To use this data (Lua table) in your module:‎<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>
[[Category:Eco Data File]]

Revision as of 23:39, 24 February 2022

Documentation


This module is a data file that is used to automate information throughout the Eco Wiki using various Lua Modules.

The data file is currently used in at least the following modules:

If you would like to see more information generated on a data page request it on the Eco Contribution Wiki Discord.

To use this data (Lua table) in your module:‎

-- 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