Difference between revisions of "Module:Sprite Damage"

From ALttP Speedrunning Wiki
Jump to: navigation, search
Line 10: Line 10:
  
 
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 21: Line 27:
 
local w = args.weapon
 
local w = args.weapon
  
m = sprite_table[m]
+
return p._getDamageForId(m, w)
local d = m[w]
 
 
 
return damage_table[w][d]
 
 
end
 
end
  
 
return p
 
return p

Revision as of 14:08, 15 December 2018

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')

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

return p