Editing
Module:Weapon upgrade table
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local m_types = require('Module:TypesLib') local m_args = require('Module:ArgsLib') local data = mw.loadData('Module:Weapon_upgrade_table/data') ----------------------------------------------------------------------------- -- Utility ----------------------------------------------------------------------------- local u = {} function u.comma_separate(value) return tostring(math.floor(value)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse() end ----------------------------------------------------------------------------- -- Builder ----------------------------------------------------------------------------- local b = {} function b.build_header(t_args) local _table = mw.html.create('table'):addClass('wikitable'):attr('style', 'text-align:center'):done() local tr = _table:tag('tr'):done() local rowspan = 1 if type(t_args.damage_headings) == 'table' and #t_args.damage_headings > 0 then rowspan = 2 end tr :tag('th'):attr('rowspan', rowspan):wikitext('Level'):done() :tag('th'):attr('colspan', #t_args.damage_values):wikitext('Damage'):done() :tag('th'):attr('colspan', data.cost_length):attr('rowspan', rowspan):wikitext('Cost'):done() :done() if type(t_args.damage_headings) == 'table' and #t_args.damage_headings > 0 then local tr2 = _table:tag('tr') for i=1, #t_args.damage_headings do tr2:tag('th'):wikitext(t_args.damage_headings[i]):done() end end return _table end function b.build_icon(image, page, amount) return mw.html.create('span'):addClass('row-center'):attr('style', 'gap:2px'):wikitext(string.format('[[File:%s|link=%s|30x30px]][[%s|%s]]', image, page, page, amount)) end function b.build_colored_text(t, value) return mw.html.create('span'):attr('style', string.format('color:var(--color-%s)', t)):wikitext(value) end function b.build_rows(t_args, container) local metal = {} local metal_amount for i = 0, data.upgrade_cap do local tr = container:tag('tr') tr :tag('th'):wikitext('+' .. i):done() -- Damage cells local damage_scaling = 1 + (data.damage_increment * i) for j = 1, #t_args.damage_values do local t = t_args.damage_types and t_args.damage_types[j] or nil local val = t_args.damage_values[j] * damage_scaling local prefix = t_args.damage_prefixes and t_args.damage_prefixes[j] or '' local suffix = t_args.damage_suffixes and t_args.damage_suffixes[j] or '' local td = tr:tag('td') if t then td:wikitext(prefix):node(b.build_colored_text(t, val)):wikitext(suffix):done() else td:wikitext(prefix .. val .. suffix):done():done() end end -- If base value, blank cells if (i == 0) then tr:tag('td'):attr('colspan', data.cost_length):wikitext('N/A'):done() else -- Cost cells -- Metal metal = data.costs.metal[i] or metal tr:tag('td'):node(b.build_icon(metal.image, metal.page, metal.amount)):done() if (metal.increment ~= nil) then metal.amount = metal.amount + metal.increment end -- Lumenite if (t_args.is_special) then tr:tag('td'):node(b.build_icon(data.costs.lumenite.image, data.costs.lumenite.page, data.costs.lumenite.amount[i])):done() end -- Scrap tr:tag('td'):node(b.build_icon(data.costs.scrap.image, data.costs.scrap.page, u.comma_separate(data.costs.scrap.base + (data.costs.scrap.increment * (i - 1))))):done() end end end ----------------------------------------------------------------------------- -- Public ----------------------------------------------------------------------------- local p = {} function p.main(frame) local t_args = frame:getParent().args return p._main(t_args) end function p._main(t_args) t_args.is_special = m_types.to_bool(t_args.is_special) if (t_args.is_special) then data = data.special else data = data.standard end t_args.damage_values = m_args.merge_numbered_args(t_args, 'base_damage') t_args.damage_headings = m_args.merge_numbered_args(t_args, 'heading', #t_args.damage_values) if (t_args.damage_headings and #t_args.damage_headings ~= #t_args.damage_values) then error('No matching damage_heading for each damage_value.') end t_args.damage_types = m_args.merge_numbered_args(t_args, 'damage_type', #t_args.damage_values) t_args.damage_prefixes = m_args.merge_numbered_args(t_args, 'prefix', #t_args.damage_values) t_args.damage_suffixes = m_args.merge_numbered_args(t_args, 'suffix', #t_args.damage_values) local container = b.build_header(t_args) b.build_rows(t_args, container) return container end return p
Summary:
Please note that all contributions to The Remnant 2 Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
RW:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Weapon upgrade table/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Purge cache
Search
Discord
Discord
Navigation
Main page
Recent changes
Random page
Links
Homepage
FTA Homepage
Gunfire Games
Community resources
Game updates
Remnant 2 Toolkit
Tools
What links here
Related changes
Special pages
Page information
Page values