Module:AnimalData/doc: Difference between revisions

From Eco - English Wiki
[unchecked revision][checked revision]
No edit summary
No edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''DO NOT Manually change Data as this is directly taken from the game.'''
{{DataModule}}


This file is a Datafile that is used to Automate information throughout the Eco Wiki using various Modules.
== Usage ==
<syntaxhighlight lang="lua">
-- Load data only once per page. (Do no use require())
local AnimalData = mw.loadData("Module:AnimalData")


The Module:AnimalData is currently used in:
-- Assert that some data was received, otherwise throw an error.
[[Module:Infobox_Animal]], See [[Template:Infobox_Animal]] for more details.
assert(AnimalData.animals, "Failed to load data from Module:AnimalData!")


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

Latest revision as of 11:45, 16 April 2026

Warning about use

[edit source]

To prevent multiple call of data array, you must use the function: local AnimalData = mw.loadData("Module:AnimalData/doc")

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