Module:Sandbox/Soreness: Difference between revisions

From Growtopia
Jump to navigationJump to search
>Sorenesss
No edit summary
>Sorenesss
mNo edit summary
Line 28: Line 28:
local d = getItemData(md5.md5(name))
local d = getItemData(md5.md5(name))
local contains = setContains(d[3])
local contains = setContains(d[3])
local DEBUG = {}
if not contains then
if not contains then
addToSet(f, d[3])
addToSet(f, d[3])
table.insert(sc,"'''Rarity "..d[3]..":'''<br>")
table.insert(sc,"'''Rarity "..d[3]..":'''<br>")
table.insert(DEBUG, "'''Rarity "..d[3]..":''' added")
else
else
for i=1,#sc,1
for i=1,#sc,1
Line 36: Line 38:
if sc[i][0] == "'''Rarity "..d[3]..":'''<br>" then
if sc[i][0] == "'''Rarity "..d[3]..":'''<br>" then
table.insert(s[d[i]],"[["..name.."]]")
table.insert(s[d[i]],"[["..name.."]]")
table.insert(DEBUG, s[d[i]].." added")
end
end
table.insert(DEBUG, "Not found. sc[+1]")
end
end
table.insert(DEBUG, "Not found in list")
end
end
return table.concat(DEBUG)
end
end



Revision as of 15:29, 27 April 2022

Documentation for this module may be created at Module:Sandbox/Soreness/doc

local p = {}

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 addToSet(set, key)
    set[key] = true
end

local function removeFromSet(set, key)
    set[key] = nil
end

local function setContains(key)
    return not f[key] == nil
end

function p.addtoList(frame)
	local name = frame.args["name"] or mw.title.getCurrentTitle().text
	local d = getItemData(md5.md5(name))
	local contains = setContains(d[3])
	local DEBUG = {}
	if not contains then
		addToSet(f, d[3])
		table.insert(sc,"'''Rarity "..d[3]..":'''<br>")
		table.insert(DEBUG, "'''Rarity "..d[3]..":''' added")
	else
		for i=1,#sc,1
		do
			if sc[i][0] == "'''Rarity "..d[3]..":'''<br>" then
				table.insert(s[d[i]],"[["..name.."]]")
				table.insert(DEBUG, s[d[i]].." added")
			end
			table.insert(DEBUG, "Not found. sc[+1]")
		end
		table.insert(DEBUG, "Not found in list")
	end
	return table.concat(DEBUG)
end

function p.ListRaritys()
	for i=1, #sc, 1
	do
		for j=1,#sc[j], 1
		do
			table.insert(printset, sc[i][j])	
		end
	end
	return table.concat(printset)
end

return p