Module:Détails des ressources/détails

De Satisfactory Wiki
Aller à la navigation Aller à la recherche
Template-info.svg Documentation

Returns formatted data from 'crafting_recipes' table for Module:Détails des ressources

Erreur Lua : Erreur : table crafting_recipes non trouvée..


local util_cargo = require('Module:CargoUtil')
local recipeUsage = require([[Module:RecipeUsage]])

local p = {}
function p.main(frame)
	local query = {
		tables = 'crafting_recipes',
		fields = recipeUsage.argList,
		where = 'productCount IS NOT NULL AND quantity1 IS NOT NULL and product IS NOT NULL and (product2 IS NULL or product2 <> "Bidon vide") and (alternateRecipe IS NULL or alternateRecipe = 0)',
                orderBy = 'alternateRecipe',
		limit = 9999
	}
	local recipes = {}
	local result = util_cargo.queryAndCast(query)
	for _, row in ipairs(result) do
		if recipes[row.product] == nil then
			local breakdown = {}
			for i = 1, 10 do
				local key = row['ingredient' .. i]
				if key then
					breakdown[key] = row['quantity' .. i] and tonumber(row['quantity' .. i]) / tonumber(row.productCount)
				end
			end
			recipes[row.product] = breakdown
		end
	end
	return recipes
end
return p.main()