Be sure to have a backup file before trying this!
This method requires you to hit a button twice. First to populate
"passiveperception", and then again to trim the end of senses.
This is because you might not want to push the second button.
Note that the second part in particular will be very sensitive to typos. If
it's wrong even by case or extra white space, it will change "sense" to
nothing!
Sorry, there should be a fail safe mechanism, but it would take too long.
Putting in a fail safe is left to the
student as an exercise. ;-)
Good luck!
\define passiveperception() passive Perception $(x)$
<$button>Change All Passive Perception
<$list filter="[has[senses]]">
<$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable =
'x'>
<$action-setfield passiveperception=<<x>>/>
<!-- <<x>> <br/>this is so I could verify that the variable 'x' held the
correct value -->
</$list>
</$list>
</$button>
<$button>Change Senses
<$list filter="[has[senses]]">
<$list filter = "[<currentTiddler>get[senses]split[ ]last[1]]" variable =
'x'>
<$action-setfield
senses={{{[<currentTiddler>get[senses]removesuffix<passiveperception>] }}}/
>
<!-- <<x>> <br/>this is so I could verify that the variable 'x' held the
correct value -->
</$list>
</$list>
</$button>
On Sunday, April 12, 2020 at 3:11:45 PM UTC-7, Jalen MichalsLevy wrote:
>
> Hi there,
>
> I have many tiddlers (of the same unique type), which contain the field
> "senses". The 'senses' field contains values that look something like this:
> "Darkvision 60ft., passive Perception 12". Now, it has come to my attention
> that it would be far more useful for Passive Perception to be its own field
> with its own numeric value. Instead of doing this manually, as there are
> hundreds of tiddlers like this, I want to make a button that will do this
> by batch. Basically, I want to take the last word (which is actually a
> number in all cases) from the 'senses' field and put it into a new
> "passive-perception field". I have played around with the list widget and
> filter notation, trying to use the 'enlist' operator and the 'last'
> operator, and was able to make it work for a single tiddler (see below).
> But I think I am definitely missing something that ties it all together and
> makes it work for a batch. Any help would be appreciated. Bonus points if
> you can also tell me how to delete the words 'passive Perception ##' from
> the end of the 'senses' field. Thank you!
>
> Code for a single tiddler:
> <$list filter = "[{Boar!!senses}split[ ]last[1]]" variable = 'x'>
>
> <<x>> <!-- this is so I could verify that the variable 'x' held the
> correct value -->
>
> <$button set = "Boar!!passiveperception" setTo = <<x>> >
> Change Boar's Passive Perception
> </$button>
>
> </$list>
>
> Thank you!
>
> -Jalen
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/92c57a62-90ef-4d09-93d2-3ce8ee88d314%40googlegroups.com.