Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Damage display: Difference between revisions

From bg3.wiki
m Prototype support for "weapon" special damage value
m Test of cargo query for weapon
Line 249: Line 249:
-- weapons table for the specific damage values
-- weapons table for the specific damage values
local function weapon_parse(args, weapon_name)
local function weapon_parse(args, weapon_name)
-- TEMP: This will be replaced with a proper cargo query
-- Fields stored in the weapons table. These are liable to change.
local weapon = {
local fields = [[
["damage"] = "1d6 + 2",
name,
["damage_type"] = "Piercing",
damage,
["extra_damage"] = "1d6",
damage_type,
["extra_damage_type"] = "Necrotic",
extra_damage,
}
extra_damage_type,
 
extra_damage_2,
for _, damage_field in ipairs({"damage", "extra_damage", "extra_damage_2"}) do
extra_damage_2_type,
if weapon[damage_field] then
melee_or_ranged
damage_parse(args, weapon[damage_field], weapon[damage_field .. "_type"], "")
]]
local query = mw.ext.cargo.query('weapons', fields, {
where = "name=\"" .. weapon_name .. "\""
})
if #query > 0 then
weapon = query[1]
for _, damage_field in ipairs({"damage", "extra_damage", "extra_damage_2"}) do
if weapon[damage_field] then
damage_parse(args, weapon[damage_field], weapon[damage_field .. "_type"], "")
end
end
end
end
end