
Create a new game with the following custom sheet: <input type="number" name="attr_source_value" value="10">
<input type="hidden" name="attr_source_value">
<input type="number" name="attr_output">
<script type="text/worker">
function sheetOpened() {
getAttrs(['source_value', 'output'], (vals) => {
if (vals.output === '' || vals.output === undefined) {
log(JSON.stringify(vals));
log(vals.source_value);
const output = vals.source_value / 2;
log(output);
setAttrs({output});
}
});
}
on('change:sheet_opened', sheetOpened);
on('sheet:opened', sheetOpened);
</script> and the following API script: on('chat:message', (msg) => { if(msg.content === '!makeChar') { const char = createObj('character', { name: 'test' }); const attr = createObj('attribute', { name: 'sheet_opened', characterid: char.id}); attr.setWithWorker({current: 1}); } }); Open the game, create a new character, go to the character sheet Observe that the source value is 10, and the calculated field is set to 5 - half the source value. This is as expected. Now run !makeChar from the chat window Open the resulting character called "test" and go to the character sheet. Observe that while the source value is still 10, the calculated field is set to 0 - because the API sheetworkers have incorrectly returned an empty value for the source field. I noticed this because of issues with Shaped startup, which is why I've created a testcase that tests behaviour immediately after creating a new character. I'm not sure if this also happens in every case where there are two fields for the same value, or whether it's only before the character has actually been opened for the first time. I've already spent too long nailing this one down so I'll leave that you for you guys to work out - but at least you have some reliable reproduction steps which is more than I usually give you ;-)