Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Repeating Row IDs and ChatSetAttr

Here is a fun one: I'm coding a Mutants and Masterminds 3E game and the powers are repeating rows. I know I can use the -CREATE syntax to populate a repeating row, but then is there a way to get that row ID easily? I need the row ID as some powers are linked to together on the sheet through the Row ID and I would need to reference it back to the first power created. 
1637845042
timmaugh
Pro
API Scripter
Fetch can get that. *(character name.list.[subattr pattern].rowid[default value]) In that, everything is replaceable (like subbing your character name for "character name") except rowid . That is what will return the row ID of what you are looking for. For instance, you create a power on the character "Roen" in the "powers" list. The "power_name" sub-atttribute contains the power's name, which is "Flapjackery." The Fetch construction would be: *(Roen.powers.[power_name=Flapjackery].rowid That would return the value to the line (for use in another script's command), or, with ZeroFrame, you could output it with {&simple}. Here is the link to the Fetch thread discussing repeating attributes: " Special Information About Repeating Items "
1637871811

Edited 1637873013
Neat! Can Fetch do that right in a script card as the rows are being built? --:StartBattlesuitOffensivePowers| --@setattr|_silent _charid [*S:character_id] _repeating_powers_-CREATE_label|Weapons Array _repeating_powers_-CREATE_element_type|power _repeating_powers_-CREATE_cost|28 _repeating_powers_-CREATE_description|Array --&MasterRow|*^([*S:character_name].powers.[label=Weapons Array].rowid) --@setattr|_silent _charid [*S:character_id] _repeating_powers_-CREATE_label|Plasma Blast _repeating_powers_-CREATE_master_row|[&MasterRow] _repeating_powers_-CREATE_attack_type|alternative _repeating_powers_-CREATE_element_type|attack_fx _repeating_powers_-CREATE_rank|10 _repeating_powers_-CREATE_description|Ranged Damage 10, Accurate 4 Thanks and Happy Thanksgiving!
1637940348
timmaugh
Pro
API Scripter
It can, with certain steps. Remember the order of operations in script processing... Roll20 Parsing ==> Metascript processing (loops to Roll20 parsing again) == eventually ==> Destination Script (ScriptCards) The Fetch call will only work after the row is created, which means we're past the main metascript loop. The outbound call to ChatSetAttr (to create the repeating item) initiates a new metascript loop, but there again the row isn't created yet. The Fetch call will only resolve on a chat message initiated *after* the row is created; each new message initiates a new metascript loop. So the easiest solution is to have ScriptCards send another outbound call. To itself. Put everything that SC will need in the downstream command. The constructions that resolve in the original, top-level of the ScriptCard can either be moved (if it's just a matter of assignment of a variable to equal a value) or duplicated (if the variable is derived from some process, and now you just need to track it forward to the new call). Then the only thing you will have to work around is whether the ChatSetAttr attribute creation is handled asynchronously, where command execution returns to ScriptCards before the row is created. You can check this by including a default value in your Fetch call. *^([*S:character_name].powers.[label=Weapons Array].rowid[oh that was bad]) If the default value (oh that was bad) is returned, you know the repeating item wasn't found. In THAT case, you might want to delay the ScriptCard's outbound call to itself... you can do that using Aaron's Delay script. Probably any amount of time is enough to put it at the bottom of the async stack and have it resolve once the row is created.