Here is the sheet worker code: on('change:currenthp sheet:opened', function() {
getAttrs(['currenthp', 'greendtype', 'greenmin', 'greenmax', 'yellowdtype',
'yellowmin', 'yellowmax', 'reddtype', 'redmin', 'redmax', 'status' ], function(values) {
var index = parseInt(values.currenthp);
if (index <= 0) {
setAttrs({ 'status': '0' });
} else if (index <= 'redmax' && index >= 'redmin') {
setAttrs({ 'status': 'reddtype' });
} else if (index <= 'yellowmax' && index >= 'yellowmin') {
setAttrs({ 'status': 'yellowdtype' });
} else if (index <= 'greenmax' && index >= 'greenmin') {
setAttrs({ 'status': 'greendtype' });
}
});
});
Here is the HTML: <table style="width: 100% ; margin: 0 auto ; text-align: center ; padding: 2px">
<tbody>
<tr style="background-color: #99ffbb">
<td style="width: 25%">Green</td>
<td style="width: 25%">Min</td>
<td style="width: 25%">Max</td>
<td style="width: 25%">Current</td>
</tr>
<tr style="background-color: #99ffbb">
<td>
<select name="attr_greendtype" class="sheet-dtype" style="width: 100%">
<option value="1d4">1d4</option>
<option value="1d6">1d6</option>
<option value="1d8">1d8</option>
<option value="1d10">1d10</option>
<option value="1d12">1d12</option>
</select>
</td>
<td>
<input type="number" name="attr_greenmin" class="sheet-green-min">
</td>
<td>
<input type="number" name="attr_greenmax" class="sheet-green-max">
</td>
<td>
<!-- <input type="radio" name="attr_status" class="sheet-status" value="@{greendtype}"> -->
</td>
</tr>
<tr style="background-color: #ffff99">
<td style="width: 25%">Yellow</td>
<td style="width: 25%">Min</td>
<td style="width: 25%">Max</td>
<td style="width: 25%"></td>
</tr>
<tr style="background-color: #ffff99">
<td>
<select name="attr_yellowdtype" class="sheet-dtype" style="width: 100%">
<option value="1d4">1d4</option>
<option value="1d6">1d6</option>
<option value="1d8">1d8</option>
<option value="1d10">1d10</option>
<option value="1d12">1d12</option>
</select>
</td>
<td>
<input type="number" name="attr_yellowmin" class="sheet-yellow-min">
</td>
<td>
<input type="number" name="attr_yellowmax" class="sheet-yellow-max">
</td>
<td>
<!-- <input type="radio" name="attr_status" class="sheet-status" value="@{yellowdtype}"> -->
</td>
</tr>
<tr style="background-color: #ff5c33">
<td style="width: 25%">Red</td>
<td style="width: 25%">Min</td>
<td style="width: 25%">Max</td>
<td style="width: 25%"></td>
</tr>
<tr style="background-color: #ff5c33">
<td>
<select name="attr_reddtype" class="sheet-dtype" style="width: 100%">
<option value="1d4">1d4</option>
<option value="1d6">1d6</option>
<option value="1d8">1d8</option>
<option value="1d10">1d10</option>
<option value="1d12">1d12</option>
</select>
</td>
<td>
<input type="number" name="attr_redmin" class="sheet-red-min">
</td>
<td>
<input type="number" name="attr_redmax" class="sheet-red-max">
</td>
<td>
<!-- <input type="radio" name="attr_status" class="sheet-status" value="@{reddtype}"> -->
</td>
</tr>
<tr style="background-color: #bfbfbf">
<td>
OUT
</td>
<td>
-
</td>
<td>
<input type="text" name="attr_status" class="sheet-status">
</td>
<td>
<!-- <input type="radio" name="attr_status" class="sheet-status" value="0"> -->
</td>
</tr>
<tr style="background-color: #bfbfbf">
<td>
<b>HP</b>
</td>
<td>
<input type="number" name="attr_currenthp" class="sheet-current-hp">
</td>
<td>
<b>Defend</b>
</td>
<td>
<input type="number" name="attr_currentdefend" class="sheet-current-defend">
</td>
</tr>
</tbody>
</table>
The code used to function with Radio buttons that could be selected. Now I am trying to get it to work based off what ever the current HP is. That way you can set the range for Green, Yellow, and Red, and when you change/load your current HP it uses the right dice size. Just trying to improve my sheet with automation. The selection functionality is fine, but I would like it to make this simple check and grab the right die value. Probably some really silly mistake but let me know!