Took me a bit longer than planned to have some free time, but here's an example of how it would work. <button type='action' name='act_interact_with_chat'>Grab Chat roll</button>
<span name='attr_chat_roll'>Chat Roll Will Go Here</span>
<charmancer class="sheet-charmancer-roller"><!--note that charmancer elements must use double quotes and have the sheet- prefix added in the html, unlike normal sheet elements-->
<div class="container"><!-- The contents of a charmancer tag should always be put inside a div-->
<input type='text' name='comp_roll_result' value='Roll Result will go here'>
<button type='roll' name='roll_chat' value='[[1d100]] [[1d100]] [[1d100]] [[1d100]]'>Roll to chat</button>
<button type='finish' value='resolve'>Resolve Roll Result</button>
</div>
</charmancer>
<charmancer class="sheet-charmancer-final">
<!-- You can put summary info here and updates on how the port to the sheet itself is going-->
</charmancer>
<script type='text/worker'>
on('clicked:interact_with_chat',(event)=>{
console.log(`starting mancer`);
console.log(event);
startCharactermancer('roller');//load the mancer on the roller slide
});
on('mancerroll:chat',(event)=>{//react to the roll
console.log(`mancer roll detected`);
console.log(event);
setAttrs({roll_result:_.map(event.roll,(r)=>{return r.result}).join(',')},{silent:true});//Because the mancer is open, this setAttrs will only affect mancer attributes (name="comp_some_attribute")
});
on('mancerfinish:resolve',(event)=>{//react to the final slide being activated
console.log(`finishing mancer`);
console.log(event);
let data = _.reduce(event.data,(memo,slide)=>{
memo.mancerData = _.extend(memo.mancerData,slide.values);
return memo;
},{mancerData:{}});
console.log(data);
setAttrs({chat_roll:data.mancerData.roll_result},()=>{//Because we're on the final slide, this setAttrs will affect the regular sheet
finishCharactermancer();//closes the charactermancer completely
});
});
</script> Unfortunately the automated transition from rolling to closing the charmancer that I had planned doesn't work as apparently opening the final slide via a sheetworker doesn't activate the normal behavior of the final slide that lets you set normal sheet attributes with setAttrs instead of charactermancer attributes.