Module:Sandbox/Soreness: Difference between revisions
From Growtopia Wiki
More actions
mNo edit summary |
mNo edit summary |
||
| Line 25: | Line 25: | ||
end | end | ||
local function setContains(key) | local function setContains(set, key) | ||
return not | return not set[key] == nil | ||
end | end | ||
| Line 32: | Line 32: | ||
local name = frame.args[1] or mw.title.getCurrentTitle().text | local name = frame.args[1] or mw.title.getCurrentTitle().text | ||
local d = getItemData(md5.md5(name)) | local d = getItemData(md5.md5(name)) | ||
local contains = setContains(d[3]) | local contains = setContains(f, d[3]) | ||
--local DEBUG = {} | --local DEBUG = {} | ||
if not contains then | if not contains then | ||
| Line 54: | Line 54: | ||
local DEBUG = {} | local DEBUG = {} | ||
local a = getItemName() | local a = getItemName() | ||
local contains = setContains(a, x).toString() | |||
table.insert(DEBUG, "1st: "..a[x]) | table.insert(DEBUG, "1st: "..a[x]) | ||
table.insert(DEBUG, "1st | table.insert(DEBUG, "1st contains: "..contains) | ||
while (a[x]~=nil) | while (a[x]~=nil) | ||
do | do | ||
Revision as of 17:52, 27 April 2022
Documentation for this module may be created at Module:Sandbox/Soreness/doc
local raritylist = {}
local md5 = require('Module:Md5')
local sc= {}
local f = {}
local printset = {}
local function getItemData(hash)
local a = mw.loadData('Module:Item/Data')
return a[hash] or {-1, -1}
end
local function getItemName()
local a = mw.loadData('Module:Sandbox/Soreness/Data')
return a
end
local function addToSet(set, key)
set[key] = true
end
local function removeFromSet(set, key)
set[key] = nil
end
local function setContains(set, key)
return not set[key] == nil
end
function raritylist.addtoList(frame)
local name = frame.args[1] or mw.title.getCurrentTitle().text
local d = getItemData(md5.md5(name))
local contains = setContains(f, d[3])
--local DEBUG = {}
if not contains then
addToSet(f, d[3])
table.insert(sc,{"'''Rarity "..d[3]..": '''"})
--table.insert(DEBUG, "'''Rarity "..d[3]..":''' added <br>")
--table.insert(DEBUG, "'''Length:"..#sc.." <br>")
--table.insert(DEBUG, "'''Value:"..sc[1][1].." <br>")
for i=1,#sc,1
do
if sc[i][1] == "'''Rarity "..d[3]..": '''" then
table.insert(sc[i],"[["..name.."]]")
end
end
--table.insert(DEBUG, "Not found in list")
end
end
function raritylist.list()
local x=1
local DEBUG = {}
local a = getItemName()
local contains = setContains(a, x).toString()
table.insert(DEBUG, "1st: "..a[x])
table.insert(DEBUG, "1st contains: "..contains)
while (a[x]~=nil)
do
addtoList(a[x])
table.insert(DEBUG, "add: "..x)
x=x+1
end
----------------------------------All items listed in array-------------------------------------
for i=1, #sc, 1
do
for j=1,#sc[i], 1
do
table.insert(printset, sc[i][j])
end
end
return table.concat(DEBUG)
end
return raritylist