Archmage
May 7th, 2008, 12:13
I'm trying to give the player the option to change which ability score is used for their saves. I've been pulling my hair out over this, because A) this whole "sources" thing seems very static and unwieldy, and B) I can completely remove parts of the code from the Save total fields, and it still works exactly like it did before, as though that code has no real purpose.
For example: this script in the charsheet_templates.xml file is located in the "save" template, which is used for the save total on the combat page of the character sheet. You can completely remove all of the bold lines, which supposedly are linking the related values and ability score to the save total, and yet the save total continues to function normally. Why is that? Where are these sources being added from?
<script>
function onInit()
addSourceWithOp("saves." .. root[1] .. ".base", "+");
addSourceWithOp("saves." .. root[1] .. ".misc", "+");
addSourceWithOp("saves." .. root[1] .. ".temporary", "+");
addSourceWithOp("abilities." .. stat[1] .. ".bonus", "+");
super.onInit();
end
</script>
What I want to do is have the player be able to click on the stat bonus for a given save on the combat page, and it should cycle between 2 stats. I want all the totals to update using whatever stat the player has selected (I don't think this whole "addSources" thing is going to work for that). So far, this has proved rather difficult.
I attempted to look at the skills sheet because I know custom skills can be set to use any stat. However, trying to decipher the workings of that convoluted uncommented spaghetti code just doesn't seem worth it. If somebody has already managed to understand how that works, I'd really appreciate an explanation.
For example: this script in the charsheet_templates.xml file is located in the "save" template, which is used for the save total on the combat page of the character sheet. You can completely remove all of the bold lines, which supposedly are linking the related values and ability score to the save total, and yet the save total continues to function normally. Why is that? Where are these sources being added from?
<script>
function onInit()
addSourceWithOp("saves." .. root[1] .. ".base", "+");
addSourceWithOp("saves." .. root[1] .. ".misc", "+");
addSourceWithOp("saves." .. root[1] .. ".temporary", "+");
addSourceWithOp("abilities." .. stat[1] .. ".bonus", "+");
super.onInit();
end
</script>
What I want to do is have the player be able to click on the stat bonus for a given save on the combat page, and it should cycle between 2 stats. I want all the totals to update using whatever stat the player has selected (I don't think this whole "addSources" thing is going to work for that). So far, this has proved rather difficult.
I attempted to look at the skills sheet because I know custom skills can be set to use any stat. However, trying to decipher the workings of that convoluted uncommented spaghetti code just doesn't seem worth it. If somebody has already managed to understand how that works, I'd really appreciate an explanation.