Renumbering and Colorizing Tokens: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Recipe to renumber tokens and add a unique halo color to each)
 
m (Taustin moved page renumbering and Colorizing Tokens to Renumbering and Colorizing Tokens without leaving a redirect)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Cookbook]]
This simple GM macro allows you to renumber and provide halos to a group of tokens. Change the listOfColors line to add colors or modify their assignment order. Note that if you have more tokens than colors, they will cycle from the beginning of the list.  
This simple GM macro allows you to renumber and provide halos to a group of tokens. Change the listOfColors line to add colors or modify their assignment order. Note that if you have more tokens than colors, they will cycle from the beginning of the list.  


<syntaxhighlight lang="mtmacro" line>
<syntaxhighlight lang="java" line>
[h: status = input("name||Name?|TEXT", "idx|1|Begin at index|TEXT")]
[h: status = input("name||Name?|TEXT", "idx|1|Begin at index|TEXT")]
[h: abort(status)]
[h: abort(status)]

Latest revision as of 17:50, 3 May 2023

This simple GM macro allows you to renumber and provide halos to a group of tokens. Change the listOfColors line to add colors or modify their assignment order. Note that if you have more tokens than colors, they will cycle from the beginning of the list.

[h: status = input("name||Name?|TEXT", "idx|1|Begin at index|TEXT")]
[h: abort(status)]
[h: colorid = 0]
[h:listOfColors = "blue, fuchsia, green, orange, purple, red, teal, yellow, black, lime, cyan"]
[h: tokens = getSelected()]
[h, foreach( id, tokens ), code: {
    [h: setName(name+" "+(strformat("%02d",idx)), id)]
    [listGet(listOfColors, colorid)]
    [h: setHalo(listGet(listOfColors, colorid), id)]
    [h: setGMName("", id)]
    [h: idx = idx+1]
    [h: colorid = if(colorid < listCount(listOfColors) - 1, colorid+1, 0)]
}]

Inspiration from CoveredInFish post