Module:Sandbox/Soreness: Difference between revisions

From Growtopia
Jump to navigationJump to search
>Sorenesss
mNo edit summary
>Sorenesss
mNo edit summary
 
(151 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local raritylist = {}


function p.ListRaritys()
local md5 = require('Module:Md5')
local c = {}
local sc= {}
--[[local s = {}
local f = {}
for i=363, 364, 1
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 setDoesntContains(set, key)
    return set[key] == nil
end
 
local function addtoList(strname)
local rarity = getItemData(md5.md5(strname))[3]
if rarity==999 then
elseif setDoesntContains(f, rarity) then
addToSet(f, rarity)
table.insert(sc, {rarity})
table.insert(sc[#sc],"<br>'''Rarity "..rarity..": '''")
table.insert(sc[#sc],"[["..strname.."]]")
--table.insert(dpl,"{{#dpl:category = Rarity_"..rarity.."}}")
else
for i=1,#sc,1
do
if sc[i][1] == rarity then
doesntContain=true
for j=3, #sc, 1
do
if sc[i][j] == "[["..strname.."]]" then
doesntContain=false
end
end
if doesntContain then
table.insert(sc[i],"[["..strname.."]]")
end
end
end
end
end
 
function raritylist.list()
local x=1
local a = getItemName()
--table.insert(DEBUG, "1st contains: "..a[1].."\n")
for x=2, (a[1]+1),1
do
addtoList(a[x])
--table.insert(DEBUG, "add: "..a[x].." with hash: "..md5.md5(a[x]).." and rarity: "..getItemData(md5.md5(a[x]))[3])
x=x+1
end
----------------------------------All items listed in array-------------------------------------
table.sort(sc, function(a, b) return a[1] < b[1] end);
table.insert(printset, "'''Items by Rarity'''<br>".."''Last updated:'' "..(os.date("%B %d, %Y")))
for i=1, #sc, 1
do
do
local copy = {}--]]
table.remove(sc[i], 1)
--copy = table.unpack("[".."[Category:Rarity "..i.."]]")  
table.insert(printset, sc[i][1])
--[[if not copy == nil then
table.remove(sc[i], 1)
table.insert(s,"'''Rarity "..i..":'''<br>")
table.sort(sc[i], function(a, b) return b:lower() > a:lower() end);
--
table.insert(printset, sc[i][1])
while not next(copy) == nil
for j=2,#sc[i], 1
do
do
table.insert(s, next(copy))
table.insert(printset, ", "..sc[i][j])
end
--
end
end
end
end
return table.concat(s);--]]
local x = table.concat(printset)
return table.concat(table.unpack(c, "[".."[Category:Rarity ".."363".."]]"))
return x
end
end


return p
return raritylist

Latest revision as of 19:06, 9 May 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 setDoesntContains(set, key)
    return set[key] == nil
end

local function addtoList(strname)
	local rarity = getItemData(md5.md5(strname))[3]
	if rarity==999 then
	elseif setDoesntContains(f, rarity) then
		addToSet(f, rarity)
		table.insert(sc, {rarity})
		table.insert(sc[#sc],"<br>'''Rarity "..rarity..": '''")
		table.insert(sc[#sc],"[["..strname.."]]")
		--table.insert(dpl,"{{#dpl:category = Rarity_"..rarity.."}}")
	else
		for i=1,#sc,1
		do
			if sc[i][1] == rarity then
				doesntContain=true
				for j=3, #sc, 1
				do
					if sc[i][j] == "[["..strname.."]]" then
						doesntContain=false
					end
				end
				if doesntContain then
					table.insert(sc[i],"[["..strname.."]]")
				end
			end
		end
	end
end

function raritylist.list()
	local x=1
	local a = getItemName()
	--table.insert(DEBUG, "1st contains: "..a[1].."\n")
	for x=2, (a[1]+1),1
	do
		addtoList(a[x])
		--table.insert(DEBUG, "add: "..a[x].." with hash: "..md5.md5(a[x]).." and rarity: "..getItemData(md5.md5(a[x]))[3])
		x=x+1
	end
	----------------------------------All items listed in array-------------------------------------
	table.sort(sc, function(a, b) return a[1] < b[1] end);
	table.insert(printset, "'''Items by Rarity'''<br>".."''Last updated:'' "..(os.date("%B %d, %Y")))
	for i=1, #sc, 1
	do
		table.remove(sc[i], 1)
		table.insert(printset, sc[i][1])
		table.remove(sc[i], 1)
		table.sort(sc[i], function(a, b) return b:lower() > a:lower() end);
		table.insert(printset, sc[i][1])
		for j=2,#sc[i], 1
		do
			table.insert(printset, ", "..sc[i][j])	
		end
	end
	local x = table.concat(printset)
	return x
end

return raritylist