Once the macros are loaded you will need to run initXpTables once on the lib token.Lib:libDnD35Pathfinder wrote:/// AM Update \\\
Code: Select all
@@ @tabTable @PROPS@ fontColor=black ; autoExecute=true ; fontSize=11pt ; sortBy=500 ; color=aqua ; playerEditable=false ; applyToSelected=false ; group=AM Updates ; tooltip= ; minWidth=94 ; <!-- tabTable(rawData,headers,rowReference) rawData - tab deliminated table where all the last column data is filled in (error if not) headers - Use the first line as a header making the inside dimension an object where the key is the column name A value of 0 is no header, a value of 1 includes the header and a value of 2 makes the internal object just a string prop. rowReference - Use the first data item as a row header. This makes the outside dimension an object where the key is the first data item This item is still included in the data object. Convert tab deliminated text to a two dimensional json object. --> [H: rawData = arg(0)] [H, if(argCount() >= 2): headers = arg(1); headers = 0] [H, if(argCount() >= 3): rowRef = arg(2); rowRef = 0] [H: TAB = decode("%09")] [H: EOL = decode("%0A")] [H: rawDataObj = json.fromList(rawData,EOL)] [H, if(rowRef): returnData = "{}"; "[]"] [H, foreach(line,rawDataObj), code: { [H: index = roll.count] [H: lineData = json.fromList(line,TAB)] [H: firstData = json.get(lineData,0)] [H, if(index == 0 && headers), code: { [H: propList = json.fromList(line,TAB)] };{}] [H, if(headers && index >= 1), code: { [H: lineObj = "{}"] [H, foreach(item,lineData): lineObj = json.set(lineObj,json.get(propList,roll.count),item)] };{ [H: lineObj = lineData] }] [H, if(headers == 2): lineObj = json.toStrProp(lineObj)] [H, if(rowRef && index >= 1): returnData = json.set(returnData,firstData,lineObj)] [H, if(! rowRef && index >= 1): returnData = json.append(returnData,lineObj)] }] [H: macro.return = returnData] !! @@ @getMonsterXp @PROPS@ fontColor=black ; autoExecute=true ; fontSize=11pt ; sortBy=500 ; color=aqua ; playerEditable=false ; applyToSelected=true ; group=AM Updates ; tooltip= ; minWidth=94 ; <!-- getMonsterXp(cr): xp --> [H: monsterCr = round(100 * arg(0))/100] [H: monsterXpTable = getLibProperty("monsterXp")] [H: monsterXp = json.get(json.get(monsterXpTable,monsterCr),"monster.xp")] [H: macro.return = monsterXp] !! @@ @getCharXpGold @PROPS@ fontColor=black ; autoExecute=true ; fontSize=11pt ; sortBy=500 ; color=aqua ; playerEditable=false ; applyToSelected=false ; group=AM Updates ; tooltip= ; minWidth=94 ; <!-- getCharXpGold(progression,level): XP or gold value progression - fast,medium,slow,gold are the options for returning the respective xp or gold value from advancement table level - From 1 to 20. Level 1 is a homebrew value. --> [H: progression = lower(arg(0))] [H: charLevel = arg(1)] [H: propName = "xp."+progression] [H: charAdvancementTable = getLibProperty("charAdvancement")] [H: levelAdvancement = json.get(charAdvancementTable,charLevel)] [H: macro.return = json.get(levelAdvancement,propName)] !! @@ @initXpTables @PROPS@ fontColor=black ; autoExecute=true ; fontSize=11pt ; sortBy=500 ; color=aqua ; playerEditable=false ; applyToSelected=false ; group=AM Updates ; tooltip= ; minWidth=94 ; [H: charAdvancement = 'xp.level xp.slow xp.medium xp.fast xp.gold 1 0 0 0 500 2 3000 2000 1300 1000 3 7500 5000 3300 3000 4 14000 9000 6000 6000 5 23000 15000 10000 10500 6 35000 23000 15000 16000 7 53000 35000 23000 23500 8 77000 51000 34000 33000 9 115000 75000 50000 46000 10 160000 105000 71000 62000 11 235000 155000 105000 82000 12 330000 220000 145000 108000 13 475000 315000 210000 140000 14 665000 445000 295000 185000 15 955000 635000 425000 240000 16 1350000 890000 600000 315000 17 1900000 1300000 850000 410000 18 2700000 1800000 1200000 530000 19 3850000 2550000 1700000 685000 20 5350000 3600000 2400000 880000'] [H: charAdvancement.table = am.tabTable(charAdvancement,1,1)] [H: setLibProperty("charAdvancement",charAdvancement.table)] [H: monsterXp = 'monster.cr monster.xp 0.13 50 0.17 65 0.25 100 0.33 135 0.50 200 1 400 2 600 3 800 4 1200 5 1600 6 2400 7 3200 8 4800 9 6400 10 9600 11 12800 12 19200 13 25600 14 38400 15 51200 16 76800 17 102400 18 153600 19 204800 20 307200 21 409600 22 614400 23 819200 24 1228800 25 1638400 26 2457600 27 3276800 28 4915200 29 6553600 30 9830400'] [H: monsterXp.table = am.tabTable(monsterXp,1,1)] [H: setLibProperty("monsterXp",monsterXp.table)] !!
Add this to onCampaignLoad
Code: Select all
...
[H: defineFunction("am.tabTable","tabTable@"+thisLib,1)]
[H: defineFunction("am.getMonsterXp","getMonsterXp@"+thisLib,1)]
[H: defineFunction("am.getCharXpGold","getCharXpGold@"+thisLib,1)]
...
Add this to the Pathfinder token type:
Code: Select all
*sheet.monsterXp (XP Award):[R, if(isNPC()): am.getMonsterXp(eval( "" + getStrProp(getProperty("Levels"),"ECL")));""]
Code: Select all
[H: abort(input("input.progression|Fast,Medium,Slow|Chose XP Progression|LIST|value=string","input.level|1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20|Chose Level|LIST|value=string"))]
[H: thisLevel = am.getCharXpGold(input.progression,input.level)]
[H: nextLevel = am.getCharXpGold(input.progression,min(20,input.level+1))]
[H: startGold = am.getCharXpGold("gold",input.level)]
[R: strformat("Level: %{thisLevel}/%{nextLevel}; Gold: %{startGold}")]