(Created page with "local p = {} function p.neededstations( f ) local args = f:getParent().args local stations = {["Campfire"] = false, ["Mortar And Pestle"] = false, ["Refining Forge"] = fal...") |
No edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
function p.neededstations( f ) |
function p.neededstations( f ) |
||
local args = f:getParent().args |
local args = f:getParent().args |
||
− | local stations = {[" |
+ | local stations = {["Fabricator"] = false, ["Mortar and Pestle"] = false, ["Smelter"] = false, ["Petroleum Slime Incubator"] = false, ["Workbench"] = false} |
local dependencies = { |
local dependencies = { |
||
− | [" |
+ | ["Fabricator"] = { |
− | " |
+ | "Electronics", |
⚫ | |||
− | "Cooked Prime Meat", |
||
⚫ | |||
− | }, |
||
− | ["Mortar And Pestle"] = { |
||
⚫ | |||
− | "Narcotic", |
||
− | "Gunpowder", |
||
− | "Stimulant", |
||
− | "Cementing Paste", |
||
⚫ | |||
"Polymer", |
"Polymer", |
||
− | " |
+ | "Steel Boots" |
− | "Propellant" |
||
}, |
}, |
||
− | [" |
+ | ["Mortar and Pestle"] = { |
− | " |
+ | "Bone Ash", |
− | " |
+ | "Sleepy Potion" |
− | + | }, |
|
− | + | ["Smelter"] = { |
|
⚫ | |||
⚫ | |||
"Glass", |
"Glass", |
||
"Iron Ingot", |
"Iron Ingot", |
||
− | " |
+ | "Silver Ingot" |
− | }, |
||
− | ["Preserving Bin"] = { |
||
− | "Cooked Meat Jerky", |
||
− | "Prime Meat Jerky" |
||
− | }, |
||
− | ["Smithy"] = { |
||
− | "Tranquilizer Dart" |
||
− | }, |
||
− | ["Fabricator"] = { |
||
− | "Electronics", |
||
− | "Polymer" |
||
− | }, |
||
− | ["Chemistry Bench"] = { |
||
− | "Absorbent Substrate" |
||
− | }, |
||
− | --Primitive Plus |
||
− | ["Apiary"] = { |
||
− | "Honey", |
||
− | "Beeswax" |
||
− | }, |
||
− | ["Cauldron"] = { |
||
− | "Natural Yeast", |
||
− | "Cashew Milk" |
||
− | }, |
||
− | ["Cement Mixer"] = { |
||
− | "Fresh Cement" |
||
− | }, |
||
− | ["Cooking Table"] = { |
||
− | "Fresh Dough" |
||
− | }, |
||
− | ["Handmill"] = { |
||
− | "Clay (Primitive+)", |
||
− | "Sack of Flour", |
||
− | "Salt" |
||
− | }, |
||
− | ["Lumber Station"] = { |
||
− | "Wood Plank" |
||
}, |
}, |
||
− | [" |
+ | ["Petroleum Slime Incubator"] = { |
− | " |
+ | "Petroleum Barrel" |
− | "Dried Tea Bags", |
||
− | "Dried Wheat" |
||
}, |
}, |
||
− | [" |
+ | ["Workbench"] = { |
− | " |
+ | "Glass Window", |
⚫ | |||
⚫ | |||
+ | "Petroleum Barrel" |
||
}, |
}, |
||
+ | |||
− | ["Tanning Rack"] = { |
||
− | "Leather" |
||
− | } |
||
} |
} |
||
Latest revision as of 17:46, 22 April 2018
Displays a list of needed crafting stations needed to craft the given resources.
Parameter[]
craftedin
: station that is needed to craft the item- Resources as list, separated by |
Usage[]
{{RequiredCraftingStations|<resources>}} {{RequiredCraftingStations|craftedin=<station>|<resources>}}
Example[]
{{RequiredCraftingStations|Narcotic|Metal Ingot}}
{{RequiredCraftingStations|craftedin=Fabricator|Narcotic|Metal Ingot}}
The above documentation is transcluded from Module:RequiredCraftingStations/doc. (edit | history)
local p = {}
function p.neededstations( f )
local args = f:getParent().args
local stations = {["Fabricator"] = false, ["Mortar and Pestle"] = false, ["Smelter"] = false, ["Petroleum Slime Incubator"] = false, ["Workbench"] = false}
local dependencies = {
["Fabricator"] = {
"Electronics",
"Polymer",
"Steel Boots"
},
["Mortar and Pestle"] = {
"Bone Ash",
"Sleepy Potion"
},
["Smelter"] = {
"Charcoal",
"Copper Ingot",
"Glass",
"Iron Ingot",
"Silver Ingot"
},
["Petroleum Slime Incubator"] = {
"Petroleum Barrel"
},
["Workbench"] = {
"Glass Window",
"Iron Boots",
"Iron Foundation",
"Petroleum Barrel"
},
}
-- check if item itself needs a station to be crafted in. if yes, set to true
if args.craftedin ~= nil and stations[args.craftedin] ~= nil then
stations[args.craftedin] = true
end
-- get iconsize
local iconsize = '20px'
if args.iconsize ~= nil then
iconsize = args.iconsize
end
-- test all given resources and set station to true if needed and station is not already on true
for _,res in ipairs(args) do
if res ~= '' then
for station,_ in pairs(dependencies) do
if not stations[station] and p.inTable(dependencies[station], res) then
stations[station] = true
end
end
end
end
local returnTable = {}
for station, needed in pairs(stations) do
if needed then
table.insert(returnTable,'[[File:'..station..'.png|'..iconsize..']] [['..station..']]')
end
end
return table.concat(returnTable,'<br/>')
end
function p.inTable(tbl, item)
for _, value in pairs(tbl) do
if string.lower(value) == string.lower(item) then return true end
end
return false
end
return p