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)
No edit summary
Sorenesss (talk | contribs)
No edit summary
Line 3: Line 3:
local md5 = require('Module:Md5')
local md5 = require('Module:Md5')


local s = {{}}
local s = {}
local f = {}
local f = {}


Line 27: Line 27:
if not setConatains(f, d[3]) then
if not setConatains(f, d[3]) then
addToSet(f, d[3])
addToSet(f, d[3])
table.setn(s,s.getn()+1)
table.setn(s[d[3]],0)
table.insert(s[d[3]],"'''Rarity "..i..":'''<br>")
table.insert(s[d[3]],"'''Rarity "..i..":'''<br>")
end
end
table.setn(s[d[3]],s[d[3]].getn()+1)
table.insert(s[d[3]],"[["..name.."]]")
table.insert(s[d[3]],"[["..name.."]]")
end
end
Line 34: Line 37:
function p.ListRaritys(name)
function p.ListRaritys(name)
local printset = {}
local printset = {}
for i=0, s.getn(), 1
for i=0, table.getn(s), 1
do
do
for j=0,s[i].getn(), 1
for j=0,table.getn(s[i]), 1
do
do
table.insert(printset, s[i][j])
table.insert(printset, s[i][j])

Revision as of 12:30, 27 April 2022

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

local p = {}

local md5 = require('Module:Md5')

local s = {}
local f = {}

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(set, key)
    return set[key] ~= nil
end

function p.addtoList(name)
	local d = getItemData(md5.md5(name))
	if not setConatains(f, d[3]) then
		addToSet(f, d[3])
		table.setn(s,s.getn()+1)
		table.setn(s[d[3]],0)
		table.insert(s[d[3]],"'''Rarity "..i..":'''<br>")
	end
	table.setn(s[d[3]],s[d[3]].getn()+1)
	table.insert(s[d[3]],"[["..name.."]]")
end

function p.ListRaritys(name)
	local printset = {}
	for i=0, table.getn(s), 1
	do
		for j=0,table.getn(s[i]), 1
		do
			table.insert(printset, s[i][j])	
		end
	end
	return table.concat(printset)
end

return p