
Hi!
I'm not gonna say that I've been through everything already since being referred to Roll Parsing just last night/this morning but I have done a fair bit of reading and can't help but feel that I just don't have a good enough understanding of what the Roll20 site/engine does. I have read through Oosh's wonderful Adventures with StartRoll() and while I can grasp some of it I don't know why certain things are utilized. I found this pretty quickly:
// Helper function to grab player inputconst getQuery = async (queryText) => {const rxGrab = /^0\[(.*)\]\s*$/;let rollBase = `! {{query1=[[ 0[${queryText}] ]]}}`, // just a [[0]] roll with an inline tagqueryRoll = await startRoll(rollBase),queryResponse = (queryRoll.results.query1.expression.match(rxGrab) || [])[1];finishRoll(queryRoll.rollId); // you can just let this time out if you want - we're done with itreturn queryResponse;};
Which looks like just about what I need but honestly don't know how to apply it in my setting.
- const rxGrab: I don't really get what the need for this regex is? It's looking for 0[something] is that due to the structure of something Roll20 has done?
- ?{ } is the basic setup for a query, with | being used to set a value and other factors such as creating a list. I don't need all that extra just to take the value from ?{PlayerInput} and store it in attr_PsyUsed or some such.
Is there not a simple way to grab that value? It doesn't matter if it is overwritten each time the ToHit Roll is triggered because I only need the most recent value that is entered by the player.
In another thread I found I asked about this as:
Dustin S. said:
Sorry to hijack/necro this but I imagine this is something very simple that I'm just not wrapping my head around.
I am looking to effectively just do this:
Scott C. said:
This would require that you create an attribute to store the query in and reference it in the macro like so:
{{Dodge=[[d20+@{dodge} - @{dodge_query}]]}}I want to create an attribute to store the value of a query from a longer calculation/macro. I've only used a bit of API and haven't got a firm grasp of the roll20 wizardry.
<div class="sheet-item sheet-redbgns" style="width: 15%;"><button name="roll_PsyHit" type="roll" value="!roll40k @{character_name}, ?{Focus Power Characteristic | Willpower,@{Willpower} | Perception,@{Perception} | Psyniscience,@{PsyniscienceCharacteristic}}, [[(@{PsyRating} - ?{Psy Use?|1}) *10 + ?{Modifier|0}]]"> <span data-i18n="hit-u">Hit</span> </button></div>This is the button for the roll and I want to save the used PsyRating into an attribute so that when I perform the damage roll that can be added if necessary, also to add some flavor text in the result of the roll.
EDIT: I guess I should add that I'm editing/fixing an existing sheet and am trying to go for the least impact possible. I might have to completely rewrite the existing API if there's not a way to pull out this singular query and store it in an attribute.
Thanks.