Difference between revisions of "Module:Sprite Damage"
From ALttP Speedrunning Wiki
(9 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
local damage_table = mw.loadData('Module:Sprite Damage/weapon table') | local damage_table = mw.loadData('Module:Sprite Damage/weapon table') | ||
local sprite_table = mw.loadData('Module:Sprite Damage/sprites table') | local sprite_table = mw.loadData('Module:Sprite Damage/sprites table') | ||
+ | local bump_table = mw.loadData('Module:Sprite Damage/bump table') | ||
function p.main(frame) | function p.main(frame) | ||
Line 10: | Line 11: | ||
return p._main(args) | return p._main(args) | ||
+ | end | ||
+ | |||
+ | function p._getDamageForId(m, w) | ||
+ | local d = sprite_table[m][w] | ||
+ | |||
+ | return damage_table[w][d] | ||
end | end | ||
Line 16: | Line 23: | ||
local m = args.id | local m = args.id | ||
− | local | + | m = m:gsub('0x', '') |
+ | m = tonumber(m, 16) | ||
+ | |||
+ | local w = args.weapon | ||
+ | |||
+ | return p._getDamageForId(m, w) | ||
+ | end | ||
+ | |||
+ | function p.getHPForId(frame) | ||
+ | local args = frame:getParent().args | ||
+ | |||
+ | local m = args.id | ||
+ | m = m:gsub('0x', '') | ||
+ | m = tonumber(m, 16) | ||
+ | |||
+ | return p._getHPForId(m, w) | ||
+ | end | ||
+ | |||
+ | function p._getHPForId(m) | ||
+ | return sprite_table[m].hp | ||
+ | end | ||
+ | |||
+ | local mails = { GREEN = 1, BLUE = 2, RED = 3 } | ||
− | m = | + | function p._getBumpForId(s, m) |
− | + | if type(m) == 'string' then | |
+ | m = m:upper() | ||
+ | end | ||
− | return | + | return bump_table[sprite_table[s].bump][(mails[m] or m) or 1] |
end | end | ||
return p | return p |
Latest revision as of 11:50, 6 June 2019
Documentation for this module may be created at Damage/doc&action=edit&redlink=1 Module:Sprite Damage/doc
local p = {} local damage_table = mw.loadData('Module:Sprite Damage/weapon table') local sprite_table = mw.loadData('Module:Sprite Damage/sprites table') local bump_table = mw.loadData('Module:Sprite Damage/bump table') function p.main(frame) local args = frame:getParent().args args[1] = args[1] or 'A' return p._main(args) end function p._getDamageForId(m, w) local d = sprite_table[m][w] return damage_table[w][d] end function p.getDamageForId(frame) local args = frame:getParent().args local m = args.id m = m:gsub('0x', '') m = tonumber(m, 16) local w = args.weapon return p._getDamageForId(m, w) end function p.getHPForId(frame) local args = frame:getParent().args local m = args.id m = m:gsub('0x', '') m = tonumber(m, 16) return p._getHPForId(m, w) end function p._getHPForId(m) return sprite_table[m].hp end local mails = { GREEN = 1, BLUE = 2, RED = 3 } function p._getBumpForId(s, m) if type(m) == 'string' then m = m:upper() end return bump_table[sprite_table[s].bump][(mails[m] or m) or 1] end return p