Editing Module:FoodDetails
From Eco - English Wiki
Your changes will be displayed to readers once an authorized user accepts them. (help)
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 5: | Line 5: | ||
-- import the required modules | -- import the required modules | ||
local itemData = | local itemData = require( "Module:ItemData" ) | ||
local recipeData = | local recipeData = require( "Module:CraftingRecipes" ) | ||
local plantData = | local plantData = require( "Module:PlantData" ) | ||
-- assign modules for use | -- assign modules for use | ||
Line 29: | Line 29: | ||
header = header .. "<th>Skill Needed</th> \n " | header = header .. "<th>Skill Needed</th> \n " | ||
header = header .. "<th>Skill Level</th> \n " | header = header .. "<th>Skill Level</th> \n " | ||
header = header .. "<th data-sort-type=\"number\"> | header = header .. "<th data-sort-type=\"number\">Minutes Crafting</th> \n " | ||
header = header .. "</tr> \n " | header = header .. "</tr> \n " | ||
Line 57: | Line 57: | ||
local skill = '' | local skill = '' | ||
local skill_level = '' | local skill_level = '' | ||
local | local ctime = '' | ||
local recipe = '' | local recipe = '' | ||
local plant = '' | local plant = '' | ||
if recipes[item] ~= nil then | if recipes[item] ~= nil then | ||
recipe = recipes[item] -- implies food item is created via a recipe with the item's name | recipe = recipes[item] -- implies food item is created via a recipe with the item's name | ||
else | |||
for key,val in pairs(recipes) do | |||
for numx = 1, #val.products do | |||
if val.products[numx][1] == item then | |||
recipe = val -- implies food item is created via a differently named recipe (issue: selects the first found recipe) | |||
end | |||
end | |||
end | |||
end | end | ||
if recipe ~= '' then | if recipe ~= '' then | ||
created = recipe.craftStn | created = recipe.craftStn[1] | ||
if recipe.skillNeeds[1] == nil then | if recipe.skillNeeds[1] == nil then | ||
skill = "none" -- implies a basic recipe like Campfire Beans | skill = "none" -- implies a basic recipe like Campfire Beans | ||
Line 82: | Line 80: | ||
skill_level = tonumber(recipe.skillNeeds[1][2]) | skill_level = tonumber(recipe.skillNeeds[1][2]) | ||
end | end | ||
ctime = tonumber(recipe.ctime) | |||
if | if ctime == 0 then | ||
ctime = '?' -- it looks like many foods have erroneous 0 ctime, so these are explicitly marked suspect | |||
end | end | ||
else | else | ||
Line 100: | Line 98: | ||
created = "none" --implies a plant gathered like beets or huckleberry, even if the plant can be destroyed with a tool | created = "none" --implies a plant gathered like beets or huckleberry, even if the plant can be destroyed with a tool | ||
end | end | ||
ctime = 0 | |||
else | else | ||
--implies food item not created via a recipe or a plant | --implies food item not created via a recipe or a plant | ||
Line 106: | Line 104: | ||
skill = "-" | skill = "-" | ||
skill_level = "-" | skill_level = "-" | ||
ctime = "-" | |||
end | end | ||
end | end | ||
Line 128: | Line 126: | ||
-- print crafting minutes. | -- print crafting minutes. | ||
row = row .. "<td>" .. | row = row .. "<td>" .. ctime .. "</td> \n" | ||
row = row .. "</tr>" | row = row .. "</tr>" | ||
Line 136: | Line 134: | ||
--print(tostring(skill)) | --print(tostring(skill)) | ||
--print(tostring(skill_level)) | --print(tostring(skill_level)) | ||
--print(tostring( | --print(tostring(ctime)) | ||
--print("") | --print("") | ||