Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[help] is it possible to....

What I am attempting to do is have my character sheet creation program write a macro that pulls the name of the character from the character sheet being created and put that into a macro to make an automated weapon attack roll. this is the macro: /e attacks with @{his/her} @{EquippedWeapon}: ( [[1d20 + @{BAB} + @{Strength} + @{EquippedAttack} - @{PowerAttack} - @{CombatExpertise} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{EquippedDamage} + @{Strength} +?{Additional damage?|0} ]] damage. /w gm @{test|equippedWeapon|max} /w gm @{test|EquippedAttack|max} /w gm @{test|EquippedDamage|max} this is the code that wrote that macro: { name: d20autosheet.attribute["mainWpn"].name + " (lgt)", macro: "/e rolls test 's attack with @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["mainWpn"].name + "}: ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["mainAtt"].name + "} - @{" + d20autosheet.attribute["powerAttack"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{" + d20autosheet.attribute["mainDmg"].name + "} + @{" + d20autosheet.attribute["str"].name + "} +?{Additional damage?|0} ]] damage.\n/w gm @{ test |equippedWeapon|max}\n/w gm @{ test |EquippedAttack|max}\n/w gm @{ test |EquippedDamage|max}" }, what I really need it to do is use the api to get the name of the character and use it to replace test in those places it has been used.
1383691303
Lithl
Pro
Sheet Author
API Scripter
Where's the code that created the character?
ok, gisthub not working, can't link to it, so here goes var d20autosheet = d20autosheet || {}; d20autosheet.dicetype = "1d20"; d20autosheet.attribute = []; d20autosheet.attribute["str"] = { name: "Strength", start: 0, max: 10 }; d20autosheet.attribute["dex"] = { name: "Dexterity", start: 0, max: 10 }; d20autosheet.attribute["con"] = { name: "Constitution", start: 0, max: 10 }; d20autosheet.attribute["int"] = { name: "Intelligence", start: 0, max: 10 }; d20autosheet.attribute["wis"] = { name: "Wisdom", start: 0, max: 10 }; d20autosheet.attribute["cha"] = { name: "Charisma", start: 0, max: 10 }; d20autosheet.attribute["line"] = { name: "------------------", start: "", max: "" }; d20autosheet.attribute["fort"] = { name: "Fortitude", start: 0, max: "" }; d20autosheet.attribute["ref"] = { name: "Reflex", start: 0, max: "" }; d20autosheet.attribute["will"] = { name: "Will", start: 0, max: "" }; d20autosheet.attribute["line2"] = { name: "------------------", start: "", max: "" }; d20autosheet.attribute["lvl"] = { name: "Level", start: 1, max: ""}; d20autosheet.attribute["xp"] = { name: "Experience", start: 0, max: 1000}; d20autosheet.attribute["spd"] = { name: "Speed", start: 30, max: 30}; d20autosheet.attribute["init"] = { name: "Initmod", start: 0, max: "" }; d20autosheet.attribute["bab"] = { name: "BAB", start: 0, max: "" }; d20autosheet.attribute["hp"] = { name: "HP", start: 6, max: 6 }; d20autosheet.attribute["temphp"] = { name: "TempHP", start: 0, max: "" }; d20autosheet.attribute["sp"] = { name: "SpellPoints", start: 0, max: "" }; d20autosheet.attribute["ac"] = { name: "AC", start: 10, max: "" }; d20autosheet.attribute["line3"] = { name: "------------------", start: "", max: "" }; d20autosheet.attribute["mainWpn"] = { name: "EquippedWeapon", start: "", max: "" };// max = 1H or 2H (for 1 or two handed attack) d20autosheet.attribute["mainAtt"] = { name: "EquippedAttack", start: 0, max: "" }; d20autosheet.attribute["mainDmg"] = { name: "EquippedDamage", start: "", max: "" }; d20autosheet.attribute["offHandWpn"] = { name: "OffHandWeapon", start: "", max: "" }; // max = OH (off hand) d20autosheet.attribute["offHandAtt"] = { name: "OffHandAttack", start: 0, max: "" }; d20autosheet.attribute["offHandDmg"] = { name: "OffHandDamage", start: "", max: "" }; d20autosheet.attribute["thrownWpn"] = { name: "ThrownWeapon", start: "", max: "range" }; // max = range d20autosheet.attribute["thrownAtt"] = { name: "ThrownAttack", start: 0, max: "" }; d20autosheet.attribute["thrownDmg"] = { name: "ThrownDamage", start: "", max: "" }; d20autosheet.attribute["rangedWpn"] = { name: "RangedWeapon", start: "", max: "range" }; // max = range d20autosheet.attribute["rangedAtt"] = { name: "RangedAttack", start: 0, max: "" }; d20autosheet.attribute["rangedDmg"] = { name: "RangedDamage", start: "1d2", max: "" }; d20autosheet.attribute["line4"] = { name: "------------------", start: "", max: "" }; d20autosheet.attribute["ac"] = { name: "AC-Total", start: 10, max: "" }; d20autosheet.attribute["sizemod"] = { name: "AC-SizeMod", start: 0, max: "" }; d20autosheet.attribute["armor"] = { name: "AC-Armor", start: 0, max: "" }; d20autosheet.attribute["shield"] = { name: "AC-Shield", start: 0, max: "" }; d20autosheet.attribute["deflection"] = { name: "AC-Deflection", start: 0, max: "" }; d20autosheet.attribute["dodge"] = { name: "AC-Dodge", start: 0, max: "" }; d20autosheet.attribute["miscac"] = { name: "AC-Misc", start: 0, max: "" }; d20autosheet.attribute["maxdex"] = { name: "AC-MaxDex", start: 0, max: "" }; d20autosheet.attribute["maxspd"] = { name: "AC-MaxSpd", start: 0, max: "" }; d20autosheet.attribute["acpenalty"] = { name: "AC-Penalty", start: 0, max: "" }; d20autosheet.attribute["line5"] = { name: "------------------", start: "", max: "" }; d20autosheet.attribute["powerAttack"] = { name: "PowerAttack", start: 0, max: "" }; d20autosheet.attribute["expertise"] = { name: "CombatExpertise", start: 0, max: "" }; d20autosheet.attribute["rapidShot"] = { name: "RapidShot", start: 0, max: "" }; d20autosheet.attribute["his/her"] = { name: "his/her", start: "his", max: ""}; d20autosheet.attribute["he/she"] = { name: "he/she", start: "he", max: "" }; d20autosheet.attribute["line6"] = { name: "------------------", start: "", max: "" }; d20autosheet.attack = [ { name: d20autosheet.attribute["mainWpn"].name + " (lgt)", macro: "/e attacks with @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["mainWpn"].name + "}: ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["mainAtt"].name + "} - @{" + d20autosheet.attribute["powerAttack"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{" + d20autosheet.attribute["mainDmg"].name + "} + @{" + d20autosheet.attribute["str"].name + "} +?{Additional damage?|0} ]] damage.\n@{test|equippedWeapon|max}\n@{test|EquippedAttack|max}\n@{test|EquippedDamage|max}" }, { name: d20autosheet.attribute["mainWpn"].name + " (1H)", macro: "/e attacks with @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["mainWpn"].name + "}: ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["mainAtt"].name + "} - @{" + d20autosheet.attribute["powerAttack"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{" + d20autosheet.attribute["mainDmg"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["powerAttack"].name + "} +?{Additional damage?|0} ]] damage\n/w gm (@{test|EquippedWeapon|max}\n/w gm @{test|EquippedAttack|max}\n/w gm @{test|EquippedDamage|max})" }, { name: d20autosheet.attribute["mainWpn"].name + " (2H)", macro: "/e attacks with @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["mainWpn"].name + "}: ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["mainAtt"].name + "} - @{" + d20autosheet.attribute["powerAttack"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{" + d20autosheet.attribute["mainDmg"].name + "} + ( @{" + d20autosheet.attribute["str"].name + "} * 1.5 ) + ( @{" + d20autosheet.attribute["powerAttack"].name + "} * 2 ) +?{Additional damage?|0} ]] damage\n/w gm @{test|equippedWeapon|max}\n/w gm @{test|EquippedAttack|max}\n/w gm @{test|EquippedDamage|max})" }, { name: d20autosheet.attribute["offHandWpn"].name + " (lgt)", macro: "/e attacks with @{" + d20autosheet.attribute["his/her"].name + "} off-hand @{" + d20autosheet.attribute["offHandWpn"].name + "}: ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["offHandAtt"].name + "} - @{" + d20autosheet.attribute["powerAttack"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{" + d20autosheet.attribute["offHandDmg"].name + "} + ( @{" + d20autosheet.attribute["str"].name + "}*0.5 ) +?{Additional damage?|0} ]] damage\n /w gm (@{test|OffhandWeapon|max}\n/w gm @{test|OffhandAttack|max}\n/w gm @{test|OffhandDamage|max}" }, { name: d20autosheet.attribute["offHandWpn"].name + " (1H)", macro: "/e attacks with @{" + d20autosheet.attribute["his/her"].name + "} off-hand @{" + d20autosheet.attribute["offHandWpn"].name + "}: ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + @{" + d20autosheet.attribute["offHandAtt"].name + "} - @{" + d20autosheet.attribute["powerAttack"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[@{" + d20autosheet.attribute["offHandDmg"].name + "} + ( @{" + d20autosheet.attribute["str"].name + "}*0.5 ) + @{" + d20autosheet.attribute["powerAttack"].name + "} +?{Additional damage?|0} ]] damage.\n/w gm (@{test|OffhandWeapon|max}\n/w gm @{test|OffhandAttack|max}\n/w gm @{test|OffhandDamage|max}" }, { name: d20autosheet.attribute["thrownWpn"].name + " (Lgt)", macro: "/e throws @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["thrownWpn"].name + "}: ( [[ " + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["dex"].name + "} + @{" + d20autosheet.attribute["thrownAtt"].name + "} - @{" + d20autosheet.attribute["rapidShot"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} - ( 2 * floor(?{range to target?|0}/(@{ThrownWeapon|max}+.1))) + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[ @{" + d20autosheet.attribute["thrownDmg"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + ?{Additional damage?|0} ]] damage.\n/w gm Range of weapon = (@{test|ThrownWeapon|max}\n/w gm @{test|ThrownAttack|max}\n/w gm @{test|ThrownDamage|max}" }, { name: d20autosheet.attribute["thrownWpn"].name + " (1H)", macro: "/e throws @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["thrownWpn"].name + "}: ( [[ " + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["dex"].name + "} + @{" + d20autosheet.attribute["thrownAtt"].name + "} - @{" + d20autosheet.attribute["rapidShot"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} - ( 2 * floor(?{range to target?|0}/(@{ThrownWeapon|max}+.1)))- @{" + d20autosheet.attribute["powerAttack"].name + "} + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[ @{" + d20autosheet.attribute["thrownDmg"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + ?{Additional damage?|0} ]] damage\n/w gm Range of weapon = @{test|ThrownWeapon|max}\n/w gm @{test|ThrownAttack|max}\n/w gm @{test|ThrownDamage|max}" }, { name: d20autosheet.attribute["rangedWpn"].name, macro: "/e shoots @{" + d20autosheet.attribute["his/her"].name + "} @{" + d20autosheet.attribute["rangedWpn"].name + "}: ( [[ " + d20autosheet.dicetype + " + @{" + d20autosheet.attribute["bab"].name + "} + @{" + d20autosheet.attribute["dex"].name + "} + @{" + d20autosheet.attribute["rangedAtt"].name + "} - @{" + d20autosheet.attribute["rapidShot"].name + "} - @{" + d20autosheet.attribute["expertise"].name + "} - ( 2 * floor(?{range to target?|0}/(@{RangedWeapon|max}+.1))) + ?{Additional Attack Bonus/Penalty?|0} ]] ) for [[ @{" + d20autosheet.attribute["rangedDmg"].name + "} + @{" + d20autosheet.attribute["str"].name + "} + ?{Additional damage?|0} ]] damage.\n/w gm Range of weapon = @{test|RangedWeapon|max},\n/w gm @{test|RangedAttack|max}\n/w gm @{test|RangedDamage|max}" }, ]; d20autosheet.stats = [ { name: d20autosheet.attribute["str"].name }, { name: d20autosheet.attribute["dex"].name }, { name: d20autosheet.attribute["con"].name }, { name: d20autosheet.attribute["int"].name }, { name: d20autosheet.attribute["wis"].name }, { name: d20autosheet.attribute["cha"].name } ]; d20autosheet.saves = [ { name: d20autosheet.attribute["fort"].name, attribute: d20autosheet.attribute["con"].name }, { name: d20autosheet.attribute["ref"].name, attribute: d20autosheet.attribute["dex"].name }, { name: d20autosheet.attribute["will"].name, attribute: d20autosheet.attribute["wis"].name } ]; /** Skills Skills are represented as an object, which consists of three values. */ d20autosheet.skill = [ { name: "Appraise", start: 0, attribute: d20autosheet.attribute["int"].name, acpenalty: "" }, { name: "Balance", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Bluff", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Climb", start: 0, attribute: d20autosheet.attribute["str"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Concentration", start: 0, attribute: d20autosheet.attribute["con"].name, acpenalty: "" }, { name: "Decipher-SCript", start: 0, attribute: d20autosheet.attribute["int"].name, acpenalty: "" }, { name: "Diplomacy", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Disable-Device", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: "" }, { name: "Disguise", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Escape-Artist", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Forgery", start: 0, attribute: d20autosheet.attribute["int"].name, acpenalty: "" }, { name: "Gather-Information", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Handle-Animal", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Heal", start: 0, attribute: d20autosheet.attribute["wis"].name, acpenalty: "" }, { name: "Hide", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Intimidate", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Jump", start: 0, attribute: d20autosheet.attribute["str"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Listen", start: 0, attribute: d20autosheet.attribute["wis"].name, acpenalty: "" }, { name: "Move-Silently", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Open-Lock", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: "" }, { name: "Ride", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: "" }, { name: "Search", start: 0, attribute: d20autosheet.attribute["int"].name, acpenalty: "" }, { name: "Sense-Motive", start: 0, attribute: d20autosheet.attribute["wis"].name, acpenalty: "" }, { name: "Sleight-of-Hand", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Spot", start: 0, attribute: d20autosheet.attribute["wis"].name, acpenalty: "" }, { name: "Survival", start: 0, attribute: d20autosheet.attribute["wis"].name, acpenalty: "" }, { name: "Spellcraft", start: 0, attribute: d20autosheet.attribute["int"].name, acpenalty: "" }, { name: "Survival", start: 0, attribute: d20autosheet.attribute["wis"].name, acpenalty: "" }, { name: "Swim", start: 0, attribute: d20autosheet.attribute["str"].name, acpenalty: " - (@{" + d20autosheet.attribute["acpenalty"].name + "}*2) " }, { name: "Tumble", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: " - @{" + d20autosheet.attribute["acpenalty"].name + "} " }, { name: "Use-Magic-Device", start: 0, attribute: d20autosheet.attribute["cha"].name, acpenalty: "" }, { name: "Use-Rope", start: 0, attribute: d20autosheet.attribute["dex"].name, acpenalty: "" } ]; d20autosheet.knowledge = []; d20autosheet.knowledge["arcana"] = { name: "Knowledge-Arcana", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["dungeoneering"] = { name: "Knowledge-Dungeoneering", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["engineering"] = { name: "Knowledge-Engineering", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["geography"] = { name: "Knowledge-Geography", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["history"] = { name: "Knowledge-History", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["local"] = { name: "Knowledge-Local", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["nature"] = { name: "Knowledge-Nature", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["nobility"] = { name: "Knowledge-Nobility", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["planes"] = { name: "Knowledge-Planes", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.knowledge["religion"] = { name: "Knowledge-Religion", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft = []; d20autosheet.craft["alchemy"] = { name: "Craft-(Alchemy)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["armorer"] = { name: "Craft-(Armorer)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["basketweaving"] = { name: "Craft-(Basketweaving)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["bookbinding"] = { name: "Craft-(Bookbinding)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["bowyer"] = { name: "Craft-(Bowyer)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["blacksmith"] = { name: "Craft-(Blacksmith)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["brewing"] = { name: "Craft-(Brewing)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["calligraphy"] = { name: "Craft-(Calligraphy)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["carpentry"] = { name: "Craft-(Carpentry)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["cobbling"] = { name: "Craft-(Cobbling)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["cooking"] = { name: "Craft-(Cooking)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["gemcutting"] = { name: "Craft-(Gemcutting)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["glasscutting"] = { name: "Craft-(Glassblowing)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["goldsmith"] = { name: "Craft-(Goldsmith)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["leatherworking"] = { name: "Craft-(Leatherworking)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["locksmithing"] = { name: "Craft-(Locksmithing)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["painting"] = { name: "Craft-(Painting)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["pottery"] = { name: "Craft-(Pottery)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["sculpting"] = { name: "Craft-(Sculpting)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["stonemasonry"] = { name: "Craft-(Stonemasonry)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["tailoring"] = { name: "Craft-(Tailoring)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["trapmaking"] = { name: "Craft-(Trapmaking)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["weaponsmith"] = { name: "Craft-(Weaponsmith)", start: 0, attribute: d20autosheet.attribute["int"].name }; d20autosheet.craft["clothmaking"] = { name: "Craft-(Weaving)", start: 0, attribute: d20autosheet.attribute["int"].name }; on("ready", function() { sendChat("system", "/w GM API is ready and running"); on("add:character", function(character) { insertAttributes(character); insertStatRolls(character); insertSaves(character); insertAttacks(character); insertSkills(character); }); }); /** Functions list of functions: (planned or in place) insertAttribute insertAbilities insertSkills rollStats */ function insertAttributes(character) { for (var index in d20autosheet.attribute) { createObj("attribute", { name: d20autosheet.attribute[index].name, current: d20autosheet.attribute[index].start, max: d20autosheet.attribute[index].max, characterid: character.id }); }; for(var index in d20autosheet.skill) { createObj("attribute", { name: d20autosheet.skill[index].name, current: d20autosheet.skill[index].start, max: "", characterid: character.id, }); }; for(var index = 0; index < d20autosheet.knowledge.length; index++) { createObj(".attribute", { name: d20autosheet.knowledge[index].name, current: d20autosheet.knowledge[index].start, max: "", characterid: character.id, }); }; }; function insertAttacks(character) { for (var index = 0; index < d20autosheet.attack.length; index++) { createObj("ability", { name: d20autosheet.attack[index].name, description: "", action: d20autosheet.attack[index].macro, characterid: character.id, }); }; }; function insertSkills(character) { for (var index = 0; index < d20autosheet.skill.length; index++) { var macro = "/e makes a check vs " + d20autosheet.skill[index].name + " ( [[" + d20autosheet.dicetype + " + @{" + d20autosheet.skill[index].name + "} + @{" + d20autosheet.skill[index].attribute + "} " + d20autosheet.skill[index].acpenalty + " ]] )"; createObj("ability", { name: d20autosheet.skill[index].name, description: "", action: macro, characterid: character.id }); }; }; function insertKnowledges(character) { for (var index = 0; index < d20autosheet.knowledge.length; index++) { var macro = "/e makes a check vs " + d20autosheet.knowledge[index].name + ": ( [[" + d20autosheet.dicetype + "+@{" + d20autosheet.knowledge[index].name + "} ]] )"; createObj("ability", { name: d20autosheet.knowledge[index].name, description: "", action: macro, characterid: character.id }); }; }; function insertStatRolls(character) { for (var index = 0; index < d20autosheet.stats.length; index++) { var macro = "/e rolls a [[" + d20autosheet.dicetype + "+@{" + d20autosheet.stats[index].name + "} ]] for his " + d20autosheet.stats[index].name + " check."; createObj("ability", { name: d20autosheet.stats[index].name, description: "", action: macro, characterid: character.id }); }; }; function insertSaves(character) { for (var index = 0; index < d20autosheet.saves.length; index++) { var macro = "/e rolls a [[" + d20autosheet.dicetype + "+@{" + d20autosheet.saves[index].name + "}+@{" + d20autosheet.saves[index].attribute + "} ]] save VS " + d20autosheet.saves[index].name + "."; createObj("ability", { name: d20autosheet.saves[index].name, description: "", action: macro, characterid: character.id }); }; };
1384406765
Lithl
Pro
Sheet Author
API Scripter
Okay, so d20autosheet contains template information for the character. You're going to want a placeholder in your template, which is replaced when the character is created. At its most basic, you'll want something like: macro: "/e attacks with @{{0}|" + d20autosheet.attribute["his/her"].name + "} @{"... ... action: d20autosheet.attack[index].macro.replace('{0}', character.get('name')), ... Note the addition of {0}| in the macro template text, which is replaced when you create the actual macro. On the other end of the spectrum, you could write up a full sprintf-type function (or use somebody else's ). You could even prototype it onto the String object so that it functions as part of a normal JS string: String.prototype.format = function(args) {...}; ... '{0} b {1} {0}'.format('a', 'b'); // -> "a b c a" The main problem I see is that the insertXX functions are being called as soon as the character is created, so if you simply click the new character button, the template would be filled in with the default character name. On the other hand, if you had an API command to create the characters (which also let you set the name at the same time), that wouldn't be an issue.