Module:InfoCardUtils: Difference between revisions
From Eco - English Wiki
| [checked revision] | [checked revision] |
No edit summary |
No edit summary |
||
| Line 109: | Line 109: | ||
TableRow = TableRow .. '<td>' .. Calories .. ' </td>' | TableRow = TableRow .. '<td>' .. Calories .. ' </td>' | ||
TableRow = TableRow .. '<td>' .. Density .. ' </td>' | TableRow = TableRow .. '<td>' .. Density .. ' </td>' | ||
TableRow = TableRow .. '<td>' .. SP .. ' </td>' | |||
TableRow = TableRow .. '</tr>' | |||
WikiText = WikiText .. TableRow | WikiText = WikiText .. TableRow | ||
end | end | ||
Revision as of 19:07, 9 March 2026
Documentation for this module may be created at Module:InfoCardUtils/doc
local Utils = require('Module:Utils')
local IconUtils = require('Module:IconUtils')
local RecipeUtils = require('Module:RecipeUtils')
local WorldObjectData = mw.loadData( "Module:WorldObjectData" )
local Lang = Utils.getLanguageName()
local p = {}
function p.WorldObjectModule(ItemName)
local WorldObject = WorldObjectData.WorldObjects[ItemName]
local WikiText = ''
if WorldObject.CraftingComponent == 'True' then WikiText = WikiText .. p.CraftingComponentModule(ItemName) end
if WorldObject.ForSaleComponent == 'True' then WikiText = WikiText .. p.ForSaleComponentModule(ItemName) end
if WorldObject.HousingComponent == 'True' then WikiText = WikiText .. p.HousingComponentModule(ItemName) end
if WorldObject.BedComponent == 'True' then WikiText = WikiText .. p.BedComponentModule(ItemName) end
if WorldObject.MintComponent == 'True' then WikiText = WikiText .. p.MintComponentModule(ItemName) end
return WikiText
end
function p.CraftingComponentModule(ItemName)
local WikiText = ''
local CraftingTableRecipes = RecipeUtils.CraftingTableRecipes(ItemName)
if (CraftingTableRecipes ~= "") then
WikiText = WikiText .. '<h3>Crafting</h3>'
WikiText = WikiText .. RecipeUtils.CraftTable(CraftingTableRecipes);
end
return WikiText
end
function p.ForSaleComponentModule(ItemName)
local WikiText = ''
WikiText = WikiText .. '<h3>For Sale</h3>'
return WikiText
end
function p.HousingComponentModule(ItemName)
local WikiText = ''
return WikiText
end
function p.BedComponentModule(ItemName)
local WikiText = ''
WikiText = WikiText .. '<h3>Bed</h3>'
return WikiText
end
function p.MintComponentModule(ItemName)
local WikiText = ''
WikiText = WikiText .. '<h3>Mint</h3>'
return WikiText
end
function p.FoodDetailsModule(ItemName)
local WikiText = ''
local FoodData = mw.loadData( "Module:FoodData" )
local FoodItem = FoodData.foods[ItemName]
WikiText = WikiText .. '<h3>Food</h3>'
WikiText = WikiText .. '<p>' .. Utils.Translate("Calories") .. ': ' .. FoodItem.Calories .. '</p>'
WikiText = WikiText .. '<p>' .. Utils.Translate("Protein") .. ': ' .. FoodItem.Protein .. '</p>'
WikiText = WikiText .. '<p>' .. Utils.Translate("Carbs") .. ': ' .. FoodItem.Carbs .. '</p>'
WikiText = WikiText .. '<p>' .. Utils.Translate("Fat") .. ': ' .. FoodItem.Fat .. '</p>'
WikiText = WikiText .. '<p>' .. Utils.Translate("Vitamins") .. ': ' .. FoodItem.Vitamins .. '</p>'
WikiText = WikiText .. '<p>' .. Utils.Translate("Shelf Life") .. ': ' .. Utils.FoodsShelfLife(FoodItem.ShelfLife) .. '</p>'
return WikiText
end
function p.FoodListDetails()
local WikiText = ''
local TableHeader = ''
local FoodData = mw.loadData( "Module:FoodData" )
local FoodList = FoodData.foods
-- Create the header of the table
TableHeader = '<table class="table table-striped table-bordered sortable"><tr class="thead-dark">'
TableHeader = TableHeader .. '<th>Food</th>'
TableHeader = TableHeader .. '<th>Carbs</th>'
TableHeader = TableHeader .. '<th>Protein</th>'
TableHeader = TableHeader .. '<th>Fat</th>'
TableHeader = TableHeader .. '<th>Vitamins</th>'
TableHeader = TableHeader .. '<th>Nutrition</th>'
TableHeader = TableHeader .. '<th>Shelf Life</th>'
TableHeader = TableHeader .. '<th>Calories</th>'
TableHeader = TableHeader .. '<th>Density</th>'
TableHeader = TableHeader .. '<th>SP value</th>'
WikiText = TableHeader
for FoodName,FoodData in pairs(FoodList) do
local TableRow = ''
local Nutrition = FoodData.Carbs + FoodData.Protein + FoodData.Fat + FoodData.Vitamins
local Calories = FoodData.Calories
local Density = 0
local ShelfLife = FoodData.ShelfLife / 86400
local SP = Nutrition * Calories
TableRow = TableRow .. '<tr>'
TableRow = TableRow .. '<td>' .. FoodName .. ' </td>'
TableRow = TableRow .. '<td>' .. FoodData.Carbs .. ' </td>'
TableRow = TableRow .. '<td>' .. FoodData.Protein .. ' </td>'
TableRow = TableRow .. '<td>' .. FoodData.Fat .. ' </td>'
TableRow = TableRow .. '<td>' .. FoodData.Vitamins .. ' </td>'
TableRow = TableRow .. '<td>' .. Nutrition .. ' </td>'
TableRow = TableRow .. '<td>' .. ShelfLife .. ' </td>'
TableRow = TableRow .. '<td>' .. Calories .. ' </td>'
TableRow = TableRow .. '<td>' .. Density .. ' </td>'
TableRow = TableRow .. '<td>' .. SP .. ' </td>'
TableRow = TableRow .. '</tr>'
WikiText = WikiText .. TableRow
end
WikiText = WikiText .. ' </table>'
return WikiText
end
return p