Anonymous
×
Create a new article
Write your page title here:
We currently have 496 articles on WIKI - Idle Pixel. Type your article name above or click on one of the titles below and start writing!



WIKI - Idle Pixel
Revision as of 18:48, 19 January 2025 by Dounford (talk | contribs)

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

u = require("Module:Util")
 
local p = {}
 
function p.floor(number)
    return number - number % 1
end

function p.formatName(name)
	return name:gsub(' ', ''):gsub('%(', ''):gsub('%)', '')
end
 
function p.loot_table(frame)
    result = [[<div class="loot-table" style="display:inline"]] .. (frame.args['name'] and (frame.args['name'] ~= '') and (' title="'.. frame.args['name'] .. '"') or '') .. [[>
{{{!}} class="article-table" style="width:52%"
! Item
! Amount Dropped
! Rarity
]] .. frame.args[1] .. [[
{{!}}}
</div>]]
    if string.match(result, '*') then
        result = result .. [[
 
''* Can only be obtained once.'']]
    end
    return result
end

function p.loot_table2(name,loot)
    result = [[{{{!}} class="article-table" style="width:45%"
! colspan="4" |]] .. '[[File:' .. p.formatName(name) .. 'Monster.png' .. '{{!}}30px{{!}}link=]]' .. [['''Loot Table''']] .. '[[File:' .. p.formatName(name) .. 'Monster.png' .. [=[{{!}}30px{{!}}link=]]
{{!}}-
{{{!}} class="article-table"
! Item
! Item Name
! Amount Dropped
! Rarity
]=] 

	for _, l in ipairs(loot) do
		result = result .. p.loot_table_row2(l)
	end

	result = result .. [[
{{!}}}
{{!}}}
''* Can only be obtained once.''
]]
	return result
end

function p.loot_table_row2(loot)

	return [[{{!}}- class="]] .. u.r(loot[4]) .. [["
{{!}}]] .. '[[File:' .. p.formatName(loot[1]) .. [[.png{{!}}40px{{!}}link=]] .. loot[1] .. ']]' .. [[

{{!}}]] .. '[[' .. loot[1] .. ']]' .. [[

{{!}}]] .. (loot[2] == loot[3] and u.c(loot[2]) or (u.c(loot[2]) .. ' - ' .. u.c(loot[3]))) .. [[

{{!}}]] .. (loot[4] == 1 and 'Always' or ('1/' .. loot[4])) .. (loot[5] and loot[5] ~= '' and '*' or '') .. [[

]]

end
 
function p.loot_table_row(frame)
    return [[{{!}}- class="]] .. u.r(frame.args[3]) .. [["
{{!}}]] .. '[[' .. [[File: ]] .. (frame.args['image'] or frame.args[1]:gsub(' ', ''):gsub('%(', ''):gsub('%)', '')) .. [[.png{{!}}40px{{!}}link=]] .. frame.args[1] .. ']]' .. [[
 
{{!}}]] .. frame.args[2] .. [[
 
{{!}}data-base="]] .. frame.args[3] .. [["{{!}}1/]] .. frame.args[3] .. (frame.args[4] and frame.args[4] ~= '' and '*' or '') .. [[
 
]]
end
 
p.lt = p.loot_table
p.ltr = p.loot_table_row
p.ltr2 = p.loot_table_row2
p.lt2 = p.loot_table2
 
return p