
Hello all! I am, at best, a novice coder. Recently with the covid lockdown my friends and I have moved our games to roll20. One of those games is a Zweihander RPG game. We have loaded the character sheet and it has two condition tracks, peril and damage. They essentially go from 0 to 5, perfect for bars on a token. However, because of the way the game works, each of the steps on the tracks have their own variable name and a corresponding value, so there is no one value you can set these token bar values to. I tried to create a custom sheet based on the code and adding some on (change:variable) code in it but it didn't work. The values on the sheet are: "Damage_Track_1", "Damage_Track_2", "Damage_Track_3", "Damage_Track_4", "Damage_Track_5", "Damage_Track_6" for the Damage track and "peril_unhindered","peril_imperiled","peril_ignore_one","peril_ignore_two","peril_ignore_three","peril_incapcitated" for the peril track. I tried to add the following code to the character sheet. Keep in mind that the values for the peril track are as follows when the radio button is selected: peril_imperiled = 1, peril_ignore_one = -10, peril_ignore_two = -10, peril_ignore_three = -10 and peril_incapcitated = 1. // Peril Token Change
on("change:peril_imperiled change:peril_ignore_one change:peril_ignore_two change:peril_ignore_three change:peril_incapcitated", function(obj) {
getAttrs(["peril_imperiled","peril_ignore_one","peril_ignore_two","peril_ignore_three","peril_incapcitated"], function(values) {
obj.set({
bar1_value: parseInt(values.peril_imperiled,10) + parseInt(values.peril_incapcitated,10) + (parseInt(values.peril_ignore_one,10) / -10) + (parseInt(values.peril_ignore_two,10) / -10) + (parseInt(values.peril_ignore_three,10) / -10)
});
});
}); I am clearly doing something wrong because this did nothing. However, I would rather not customize the sheet. I would rather add a separate API for this in addition to the official character sheet. Can someone lend me a hand, please? I would like it so that every radio button checked beyond the first (i.e. zero value) of each track, adds 1 to one of the three bars on a token. Ideally the blue one would be peril and the red one would be damage and when you remove a radio button the value drops from the token. Thus creating a 0-5 value for both red and blue token bars. Thank you, Ben G