localp={}localframe=mw.getCurrentFrame()localdata=require("Module:Datatable")localdataPerks=require("Module:Datatable/Perks")localutils=require("Module:Utils")localbar="|"-- code for |localnl="\n"localntl="|-"-- new table linelocalstrings={perkValuesNotFound="The Values for the perk wasn't found",unitNotFound="The Unit value wasn't found"}functiongetUnusedPerksCount()localresult=0for_,perkinipairs(perks)doifperk.unused==truethenresult=result+1endendreturnresultendfunctiongetCommonPerksCount()localresult=0for_,perkinipairs(perks)doifperk.character==nilandperk.unused~=truethenresult=result+1endendreturnresultendlocal_unusedPerksCount=getUnusedPerksCount()local_commonPerksCount=getCommonPerksCount()local_uniquePerksCount=table.getn(perks)-_unusedPerksCount-_commonPerksCountlocal_nonUniquePerksCount=_unusedPerksCount+_commonPerksCountp._nonUniquePerksCount=_nonUniquePerksCountp._allPerksCount=table.getn(perks)functionp.getPerksCount()--active in gamereturn_uniquePerksCount+_commonPerksCountendfunctionResolveIntParam(param)iftype(param)=="table"andparam.args[1]~=nilthenreturntonumber(param.args[1])elsereturnparamendendfunctionResolveStringParam(param)iftype(param)=="table"andparam.args[1]~=nilthenreturntostring(param.args[1])elseifparam==nilthenreturnmw.title.getCurrentTitle().textelsereturnparamendendfunctiongetUnitById(id)mw.log(id)for_,unitinipairs(units)doifunit.id==idthenreturnunit.valueendendreturnunitNotFoundend--Function that actually returns string that will replace the placeholderfunctionpl(id,tripplet)tripplet=tonumber(tripplet)for_,perkinipairs(perks)doifperk.id==idthenlocalindex=1+((tripplet-1)*3)--tripplet is an offset, +1 is indexing from 1 in LUA, * 3 is because every values are grouped by 3 values/tiersreturn"'''"..utils.clr(perk.values[index],perk.baseLevel).."'''/'''"..utils.clr(perk.values[index+1],perk.baseLevel+1).."'''/'''"..utils.clr(perk.values[index+2],perk.baseLevel+2).." "..getUnitById(perk.units[tripplet]).."'''"--Units, Tripplet is an index in 'units' listendendreturn"'''"..strings.perkValuesNotFound.."'''"end--Function replaces "#pl(x)" string with tripplet value of according number in bracketsfunctionsubValues(perkDesc)localresultlocalregexString="#pl%((%d)%)"-- looking and extracting number from "#pl(x)"forminperkDesc.desc[1][1]:gmatch(regexString)do--TODO the first index shouldn't be hardcoded due to history log (if the description will be copied, then it won't be the first)mw.log(mw.dumpObject(m))result=perkDesc.desc[1][1]:gsub(regexString,pl(perkDesc.id,m))mw.log(result)end--mw.log("PL: " .. pl)returnresultendfunctionp.GetPerkById(id)for_,perkinipairs(perks)doifperk.id==idthenreturnperkendendendfunctionp.getPerkDescription(id)id=ResolveIntParam(id)for_,perkDescinipairs(perkDescription)doifperkDesc.id==idthenmw.log(subValues(perkDesc))returnsubValues(perkDesc)endendendfunctionp.getPerkTeachableDescription(id)id=ResolveIntParam(id)for_,perkDescinipairs(perkDescription)doifperkDesc.id==idthenmw.log(perkDesc.teachDesc[1])returnperkDesc.teachDesc[1]endendendfunctionp.getPerkDescriptionByName(name)name=ResolveStringParam(name)for_,perkinipairs(perks)doifperk.name==namethenreturnp.getPerkDescription(perk.id)endendendfunctionp.getPerkOwnerByPerk(perk)ifperk.character==nilthenreturn"Perk is not unique to any character, thus no name provided"endifperk.charType=='S'thenreturnutils.getCharacterById(perk.character,survivors)elseifperk.charType=='K'thenreturnutils.getCharacterById(perk.character,killers)elsereturn"Unknown Character"endendfunctionp.getPerksOwnerNameByPerk(perk)--Namereturnp.getPerkOwnerByPerk(perk).nameendfunctionp.getPortraitOfPerkOwnerByPerk(perk)returnperk.charType..string.format("%02d",p.getPerkOwnerByPerk(perk).id)..'_charSelect_portrait.png'endreturnp