Hello everyone,
I want to have a chat button, that when clicked on, query for an entry of a repeating row and uses a specific button from it.
Is that possible? What are good ways to do it if not?
Thanks
Hello everyone,
I want to have a chat button, that when clicked on, query for an entry of a repeating row and uses a specific button from it.
Is that possible? What are good ways to do it if not?
Thanks
Custom Roll Parsing can handle this. I've got a few sheets in development that use a pattern like this. Using the K-scaffold's JS library this would look like:
const initiateRoll = function(event){ k.getAllAttrs({ props:['character_name'],//non repeating attributes that needed to be gotten are specified in this array. sectionDetails:[{section:'repeating_sectionname',fields:['name']}],//The details of the repeating sections to get IDs for are defined here. callback:async (attributes,sections)=>{//The callback function to run once all attributes have been retreived. We define this as an async function so we can await the results of startRoll and the k.extractQueryResult function let query = sections.repeating_sectionname.reduce((text,id)=>{ let rollName = attributes[`repeating_sectionname_${id}_name`] text.push(`${rollName},${id}`);//Push the text and id to the array of query prompts return text; },['Use which row']) .join('|');//Join the created array of query info with `|`. let selectedID = await k.extractQueryResult(query);//The k-scaffold provides this function for asking the player for input on the roll. The returned value will be the value of the option in the query that was selected (the id in this case) let roll = await startRoll(`%{${attributes.character_name}|repeating_sectionname_${selectedID}_roll}`) finishRoll(roll.rollId);//We aren't doing anything with this roll, so we just finish it immediately. //The above method assumes that the roll you are calling is a regular roll button. You could also just assemble the roll based on the selected row and send it using the custom roll parsing itself. } }); } on('clicked:my-button',initiateRoll);
That looks great. Can you tell me which sheets use it so I can lookup the functionality of extractQueryResults?
Thanks
You can do this with old traditional method too. The important thing to ask is - how are you determining which button in the repeating section to draw on?
There is only one button. Currently it has no name, but I imagined that giving it a name should solve the issue
Buttons need to have a name to function properly, so it's a good idea to give it a name. Remember to start the name with act_ if its an action button, roll_ if its a roll button.
I meant, really, how are you identifying which row in the section to use.
That is the initial question. I want to have query popup with alle elements of the repeating query and the user has to choose which one he want to have "clicked"
Do you mean a dropdown on the character sheet? If so, Roll20 doesnt support that kind of dynamic interface.
.Hell said:
That looks great. Can you tell me which sheets use it so I can lookup the functionality of extractQueryResults?
Thanks
The Rapidfire system sheet uses this, you can also find this utility function (and a lot more) in the utility.js file in the k-scaffold here (ignore the registration to the kfuncs object as that's specifically for use within the k-scaffold).
GiGs said:
Do you mean a dropdown on the character sheet? If so, Roll20 doesnt support that kind of dynamic interface.
True, but you can fake it through some CRP magic using roll queries
.Hell said:
That is the initial question. I want to have query popup with alle elements of the repeating query and the user has to choose which one he want to have "clicked"
As I note above, this is possible, but generally a better UX is to just have roll buttons for each repeating item. There's a few reasons to go with this query method of selecting the section though. The reason I've used it several times is because I've been working on systems that allow construction of dice pools based on an array of dynamic skills and attributes.
Heh, see the code a few posts up for a k-scaffold method! The idea is originally Oosh's, and you can find his write up in the Adventures with Startroll thread. I've changed some of the code from Oosh's original setup, but the same idea is there.