Anonymous
×
Create a new article
Write your page title here:
We currently have 496 articles on WIKI - Idle Pixel. Type your article name above or click on one of the titles below and start writing!



WIKI - Idle Pixel

Module:Crafting: Difference between revisions

No edit summary
No edit summary
Line 6: Line 6:


function p.furnace()
function p.furnace()
    recipes = {}
    for i, e in ipairs(db) do
if e[6] == 1 then
local itemIndex = i
if not recipes[itemIndex] then
recipes[itemIndex] = {
item = e[1],
itemImage = e[2],
level = e[3],
description = e[7],
xp = e[4],
materials = {}
}
end
for _, f in ipairs(e[5]) do
table.insert(recipes[itemIndex].materials, f)
end
end
    end
return p.table(recipes)
end


function p.oven()
     recipes = {}
     recipes = {}
     for i, e in ipairs(db) do
     for i, e in ipairs(db) do
if e[6] == 1 then
if e[6] == 2 then
local itemIndex = i
local itemIndex = i
if not recipes[itemIndex] then
if not recipes[itemIndex] then

Revision as of 16:39, 16 April 2024

This module uses the data from Module:Crafting_DB to create a exhibition of all the craftable items of the game

{{#invoke:Lua|crafting}}

Lua error in Module:Lua at line 100: attempt to call field 'craftingTable' (a nil value).


u = require("Module:Util")
db = require("Module:Crafting_DB")
inspect = require("Module:InspectLua")

local p = {}

function p.furnace()
    recipes = {}
    for i, e in ipairs(db) do
		if e[6] == 1 then
			local itemIndex = i
			if not recipes[itemIndex] then
				recipes[itemIndex] = {
					item = e[1],
					itemImage = e[2],
					level = e[3],
					description = e[7],
					xp = e[4],
					materials = {}
				}
			end
			for _, f in ipairs(e[5]) do
				table.insert(recipes[itemIndex].materials, f)
			end
		end
    end
	return p.table(recipes)
end

function p.oven()
    recipes = {}
    for i, e in ipairs(db) do
		if e[6] == 2 then
			local itemIndex = i
			if not recipes[itemIndex] then
				recipes[itemIndex] = {
					item = e[1],
					itemImage = e[2],
					level = e[3],
					description = e[7],
					xp = e[4],
					materials = {}
				}
			end
			for _, f in ipairs(e[5]) do
				table.insert(recipes[itemIndex].materials, f)
			end
		end
    end
	return p.table(recipes)
end

function p.table(recipes)
    result = [[

{| class="wikitable sortable"

! colspan="2" style="width: 30%" |Item

! Level Needed

! style="width: 20%" |Materials

! style="width: 25%" |Description

!XP
]]

    for _, e in pairs(recipes) do
		local materialStr = ''
		for i, m in ipairs(e.materials) do
			materialStr = materialStr .. m[2] .. " " .. '[[' .. m[1] .. ']]'
			if i < #m then
				materialStr = materialStr .. "\n"
			end
		end

        result = result .. [[

|-
|]] .. '[[File: ' .. e.itemImage .. '.png|35px|link=' .. e.item .. ']]' .. [[

|]] .. '[[' .. e.item .. ']]' .. [[

|]] .. e.level .. '[[File:CraftingSigil.png|20px|link=]]' .. [[
 
|]] .. materialStr .. [[

|]] .. e.description .. [[

|]] .. e.xp .. 'xp' .. [[
 
]]
    end
    return result .. [[
|}
]]
end
return p