Module:Loot tables

From Veloren Wiki

Documentation for this module may be created at Module:Loot tables/doc

local lootTable = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{title='Template:Loot tables.json'})

local p = {}

p.getLootTable = function(frame)
	local npc = frame.args[1]
	local color = ''
	local txt = frame:expandTemplate{ title = 'LootHeader' }
	for i=1, #lootTable, 1 do
		if lootTable[i][1] == npc then
			if lootTable[i][2] >= 24.9999 then
				color = 'green'
			elseif lootTable[i][2] >= 9.9999 then
				color = 'yellow'
			elseif lootTable[i][2] >= 2.49999 then
				color = 'orange'
			elseif lootTable[i][2] <= 2.5 then
				color = 'red'
			end
			txt = txt .. frame:expandTemplate{ title = 'LootRow', args = { itemname = lootTable[i][3], quantity = lootTable[i][4],color = color, rarity = lootTable[i][2] .. '%'   } }
		end
	end
	txt = txt .. frame:expandTemplate{ title = 'LootEnd' }
	return txt
end

p.getSourceTable = function(frame)
	local item = frame.args[1]
	local txt = frame:expandTemplate{ title = 'SourceHeader' }
	for i=1, #lootTable, 1 do
		if lootTable[i][3] == item then
			if lootTable[i][2] >= 24.9999 then
				color = 'green'
			elseif lootTable[i][2] >= 9.9999 then
				color = 'yellow'
			elseif lootTable[i][2] >= 2.49999 then
				color = 'orange'
			elseif lootTable[i][2] <= 2.5 then
				color = 'red'
			end
			txt = txt .. frame:expandTemplate{ title = 'SourceRow', args = { npcname = lootTable[i][1], color = color, quantity = lootTable[i][4], rarity = lootTable[i][2] .. '%'   } }
		end
	end
	txt = txt .. frame:expandTemplate{ title = 'LootEnd' }
	return txt
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.