Module:GetCreatureStats

local p = {} local cargo = mw.ext.cargo

function p.main(frame) local creaturetable = p.createtable(frame)

return frame:expandTemplate{title = 'CharaSim', args = { title = creaturetable['dispname'], hp = creaturetable['hp'], av = creaturetable['av'], dv = creaturetable['dv']}} end

function p.createtable(frame) --[ If creature is specified, cargo query any unfilled stats] local creature = frame.args.creature or '' local resulttable = {} if creature ~= '' then local result = cargo.query('Characters', '_pageName=Page, Title, Level, HP, AV, DV, MA, Strength, Agility, Toughness, Agility, Willpower, Ego', {where = '_pageNamespace="0" AND _pageName="' .. creature .. '"'}) if not next(result) then error ("There was no creature named " .. creature .. "!") end resulttable = result[1] end local creaturetable = { ['dispname'] = resulttable['Title'] or '', ['lv'] = (frame.args.lv ~= '' and frame.args.lv or resulttable['Level']) or '0', ['hp'] = (frame.args.hp ~= '' and frame.args.hp or resulttable['HP']) or '0', ['av'] = (frame.args.av ~= '' and frame.args.av or resulttable['AV']) or '0', ['dv'] = (frame.args.dv ~= '' and frame.args.dv or resulttable['DV']) or '0' }

return creaturetable end return p