Die Dokumentation für dieses Modul kann unter Modul:VoidByReward/Doku erstellt werden
--WARFRAME Wiki Sorted Void Drop Table By Rewards
--http://warframe.wikia.com/
--Originally written by User:NoBrainz
--Heavily modified by User:Falterfire <-- The person to message if something goes wrong
--Pulls from Module:Void/data
--Data in Void:data is structure as
local tierCol = 1 -- [1] = Tier (ex "Lith")
local nameCol = 2 -- [2] = Name (ex "A1 Common*") (* means vaulted)
local itemCol = 3 -- [3] = Item (ex "VASTO")
local partCol = 4 -- [4] = Part (ex "RECEIVER")
local p = {}
local VoidData = mw.loadData( 'Module:Void/data' )
local Void = require( "Module:Void" )
local script = require( "Module:Icon" )
local Shared = require( "Module:Shared" )
-- Converts item names in data to proper names
-- So for example 'LATRON' becomes 'Latron Prime'
function p.getItemName(itemStr)
caseItem = string.gsub(itemStr, "(%a)([%w_']*)", Shared.titleCase)
if(itemStr ~= "FORMA") then
caseItem = caseItem.." Prime"
end
return caseItem
end
-- Converts part names in data to proper casing
function p.getPartName(partStr)
return string.gsub(partStr, "(%a)([%w_']*)", Shared.titleCase)
end
function p.byReward(frame)
local data = {}
-- collect data
for _, relic in pairs(VoidData["Relics"]) do
for i, drop in pairs(relic.Drops) do
local newObj = {Tier = relic.Tier, Name = relic.Name, Rarity = drop.Rarity, IsVaulted = relic.IsVaulted == 1}
if (data[drop.Item] == nil) then
data[drop.Item] = {}
end
if(data[drop.Item][drop.Part] == nil) then
data[drop.Item][drop.Part] = {}
end
table.insert(data[drop.Item][drop.Part], newObj)
end
end
local fullStr = "{|class=\"bigmodtable\" style=\"line-height:13px;\""
for item, parts in Shared.skpairs(data) do
fullStr = fullStr.."\n|-\n"
fullStr = fullStr.."|rowspan=\""..Shared.tableCount(parts).."\"|"
local image = script._Prime(item, nil, "200x100")
fullStr = fullStr..image.."<br/>"
local itemName = p.getItemName(item)
fullStr = fullStr.."[["..itemName.."]]"
local firstRow = true
for part, drops in Shared.skpairs(parts) do
if(firstRow) then
firstRow = false
else
fullStr = fullStr.."\n|-"
end
fullStr = fullStr.."\n|"..script.Deutsch(p.getPartName(part)).."\n|"
for i, drop in pairs(drops) do
if(i > 1) then
fullStr = fullStr.."<br/>"
end
fullStr = fullStr..drop.Tier.." "..drop.Name.." "..drop.Rarity
if(drop.IsVaulted) then
fullStr = fullStr.." ([[Prime Vault|V]])"
end
end
end
end
fullStr = fullStr.."\n|}"
return fullStr
end
--New function written by User:Falterfire
--For Void Relics/ByRewards/SimpleTable
function p.simpleRewardTable(frame)
local data = {}
--Collect data for each relic
for _, relic in pairs(VoidData["Relics"]) do
local vault = "Nein"
if(relic.IsVaulted == 1) then
vault = "Ja"
end
--For each relic, need each drop
for i, drop in pairs(relic.Drops) do
--Custom objects are great
local thisObj = {Item = drop.Item, Part = script.Deutsch(drop.Part), Tier = relic.Tier,
Name = relic.Name, Rarity = script.Deutsch(drop.Rarity), IsVaulted = vault}
table.insert(data, thisObj)
end
end
local new function sorter(r1, r2)
if(r1.Item == r2.Item) then
if(r1.Part == r2.Part) then
return r1.IsVaulted < r2.IsVaulted
else
return r1.Part < r2.Part
end
else
return r1.Item < r2.Item
end
end
table.sort(data, sorter)
local rewards = {}
-- Just manually sending back all table data
-- Because this is easier than trying to format just rows
local strTable = "{| class=\"article-table sortable\""
strTable = strTable.."\n|-"
strTable = strTable.."\n! scope=\"col\"|Objekt"
strTable = strTable.."\n! scope=\"col\"|Teil"
strTable = strTable.."\n! scope=\"col\"|Tier"
strTable = strTable.."\n! scope=\"col\"|Name"
strTable = strTable.."\n! scope=\"col\"|Seltenheit"
strTable = strTable.."\n! scope=\"col\"|Vault?"
for i, Row in pairs(data) do
local rowStr = "\n|- \n|"
local ItemName = "[["..p.getItemName(Row.Item).."]]"
local PartName = script.Deutsch(p.getPartName(Row.Part))
rowStr = rowStr..ItemName.."||"..PartName.."||"..Row.Tier.."||"..Row.Name
rowStr = rowStr.."||"..Row.Rarity.."||"..Row.IsVaulted
strTable = strTable..rowStr
end
--Add final closing bracket and send it back
strTable = strTable.."\n|}"
return strTable
end
function p.vaultedRelicsTable(frame)
--Function by User:Falterfire
--Finds all currently vaulted relics and auto-generates a table
--Just hardcoding in the four types
--Fine as long as somebody knows how to fix this if DE introduces 5th rarity
local data = {["Lith"] = {}, ["Meso"] = {}, ["Neo"] = {}, ["Axi"] = {}}
-- collect data
for _,relic in pairs(VoidData["Relics"]) do
local tier = relic.Tier
if(relic.IsVaulted == 1) then
table.insert(data[tier], relic)
end
end
--Setting up the table properly
tableStr = "{| class=\"article-table\""
tableStr = tableStr.."\n! scope=\"col\" style=\"width:25%;\" | Lith"
tableStr = tableStr.."\n! scope=\"col\" style=\"width:25%;\" | Meso"
tableStr = tableStr.."\n! scope=\"col\" style=\"width:25%;\" | Neo"
tableStr = tableStr.."\n! scope=\"col\" style=\"width:25%;\" | Axi"
tableStr = tableStr.."\n|-"
--Loop through each tier
--And add all the relics for each one
for tier in Shared.relicLoop() do
tableStr = tableStr.."\n|"
for i, relic in pairs(data[tier]) do
tableStr = tableStr.."\n*"..relic.Tier.." "..relic.Name
end
end
--then just close out the table
tableStr = tableStr.."\n|}"
--and send it back
return tableStr
end
function p.byRelic(frame)
--Added by User:Falterfire
--First, setting up the table columns.
tableStr = "{| class=\"article-table sortable\""
tableStr = tableStr.."\n! Tier"
tableStr = tableStr.."\n! Typ"
tableStr = tableStr.."\n! Gewöhnliche Belohnung"
tableStr = tableStr.."\n! Ungewöhnliche Belohnung"
tableStr = tableStr.."\n! Seltene Belohnung"
--Now the fun part: Building each table row
for i, relic in pairs(VoidData["Relics"]) do
--First, new row indicator
tableStr = tableStr.."\n|-"
--Tier & Relic are easy
tableStr = tableStr.."\n| "..relic.Tier
tableStr = tableStr.."\n| "..relic.Name
local commonStr = "\n| "
local uncommonStr = "\n| "
local rareStr = "\n| "
for j, drop in pairs(relic.Drops) do
local itemName = p.getItemName(drop.Item)
local partName = script.Deutsch(p.getPartName(drop.Part))
if(drop.Rarity == "Common") then
commonStr = commonStr.."\n* [["..itemName.."|"..itemName.." "..partName.."]]"
elseif(drop.Rarity == "Uncommon") then
uncommonStr = uncommonStr.."\n* [["..itemName.."|"..itemName.." "..partName.."]]"
else
rareStr = rareStr.."\n* [["..itemName.."|"..itemName.." "..partName.."]]"
end
end
tableStr = tableStr..commonStr..uncommonStr..rareStr
end
--Close out the table
tableStr = tableStr.."\n|}"
--And send it back
return tableStr
end
function p.byRarity(frame)
--Added by User:Falterfire
--Twoooo Grakata. Or arguments. Whichever.
local platform = frame.args ~= nil and frame.args[1] or "PC"
local checkTier = frame.args ~= nil and frame.args[2] or "Lith"
local data = {["Common"] = {}, ["Uncommon"] = {}, ["Rare"] = {}}
-- collect data
for _,relic in pairs(VoidData["Relics"]) do
local tier = relic.Tier
local name = relic.Name
--So first make sure this row is the right tier
if(tier == checkTier) then
for _, drop in pairs(relic.Drops) do
local rarity = drop.Rarity
local item = drop.Item
local part = drop.Part
if(data[rarity][item.."|"..part] == null) then
data[rarity][item.."|"..part] = 1
end
end
end
end
--Now we can actually format the table
--Starting with all the column headers
tableStr = "{| class=\"article-table\""
tableStr = tableStr.."\n! style=\"width:33%;text-align:center;\" | Gewöhnlich"
tableStr = tableStr.."\n! style=\"width:33%;text-align:center;\" | Ungewöhnlich"
tableStr = tableStr.."\n! style=\"width:33%;text-align:center;\" | Selten"
--Then go through each rarity
tableStr = tableStr.."\n|-"
tableStr = tableStr.."\n|"
--Each rarity is the same steps:
--1. Loop through each item in that rarity
for itemStr, trash in Shared.skpairs(data["Common"]) do
--2. Get the item & part
sp1, trash = string.find(itemStr, "|")
itemName = p.getItemName(string.sub(itemStr, 1, sp1 - 1))
partName = script.Deutsch(p.getPartName(string.sub(itemStr, sp1 + 1)))
--3. Add the appropriate link to the table
tableStr = tableStr.."\n* [["..itemName.."|"..itemName.." "..partName.."]]"
end
tableStr = tableStr.."\n|"
for itemStr, trash in Shared.skpairs(data["Uncommon"]) do
sp1, trash = string.find(itemStr, "|")
itemName = p.getItemName(string.sub(itemStr, 1, sp1 - 1))
partName = script.Deutsch(p.getPartName(string.sub(itemStr, sp1 + 1)))
tableStr = tableStr.."\n* [["..itemName.."|"..itemName.." "..partName.."]]"
end
tableStr = tableStr.."\n|"
for itemStr, trash in Shared.skpairs(data["Rare"]) do
sp1, trash = string.find(itemStr, "|")
itemName = p.getItemName(string.sub(itemStr, 1, sp1 - 1))
partName = script.Deutsch(p.getPartName(string.sub(itemStr, sp1 + 1)))
tableStr = tableStr.."\n* [["..itemName.."|"..itemName.." "..partName.."]]"
end
--Finally, add the end of the table
tableStr = tableStr.."\n|}"
--and send it back
return tableStr--, debugStr
end
return p