Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Sandbox/Soreness: Difference between revisions

From Growtopia Wiki
Sorenesss (talk | contribs)
mNo edit summary
Sorenesss (talk | contribs)
mNo edit summary
Line 36: Line 36:
addToSet(f, rarity)
addToSet(f, rarity)
table.insert(sc,{"'''Rarity "..rarity..": '''"})
table.insert(sc,{"'''Rarity "..rarity..": '''"})
table.insert(DEBUG, "'''Rarity "..rarity..":''' added <br>")
table.insert(DEBUG, "'''Length:"..#sc.." <br>")
table.insert(DEBUG, "'''Value:"..sc[#sc][1].." <br>")
for i=1,#sc,1
for i=1,#sc,1
do
do
Line 45: Line 42:
end
end
end
end
table.insert(DEBUG, "Not found in list")
end
end
end
end

Revision as of 13:12, 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 setContains(set, key)
    return not set[key] == nil
end

local function addtoList(strname)
	local rarity = getItemData(md5.md5(strname))[3]
	local contains = setContains(f, rarity)
	--local DEBUG = {}
	if not contains then
		addToSet(f, rarity)
		table.insert(sc,{"'''Rarity "..rarity..": '''"})
		for i=1,#sc,1
		do
			if sc[i][1] == "'''Rarity "..d[3]..": '''" then
				table.insert(sc[i],"[["..name.."]]")
			end
		end
	end
end

function raritylist.list()
	local x=1
	local DEBUG = {}
	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-------------------------------------
	--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