So I've run into a problem with the dreaded token ID bug that I'd never run across before.
Generally the bag of tricks fix sorts this. As a reminder, basically it works as follows:
- Generate a list of all token IDs
- For each ID, if the ID is not 32 characters long, assume the ID should be padded to the left by a bunch of 0s
- Copy the token with this presumed ID, and remove the token
That's always worked for me in the past. But tonight I hit the following token ID: 0000000090158353400E000000000000. Maptool turns this into 90158353400. That is, it strips off the leading zeroes, as well as E000000000000 which presumably it thinks is just scientific notation. Then the bag of tricks fix left-pads with a bunch of zeroes to give me 00000000000000000000090158353400. And this token can't be copied and removed because it doesn't exist.
Any useful suggestions?
Since all my tokens have unique names, I could presumably solve the problem by something like
Code: Select all
[IDList = getTokens("json",'{layer:["TOKEN","GM","OBJECT","BACKGROUND"]}')]
[NameList = getTokenNames()]
[ForEach(ID,IDList), Code:
{ [if(length(id) == 32), Code:
{ [tName = getName(ID)]
[tPos = listFind(NameList,tName)]
[NameList = listDelete(NameList,tPos)]
}]
}]
at which points NameList should contain a list of token names which correspond to tokens with invalid IDs. Then presumably I can copy/remove tokens on that basis. But this fix clearly relies on all token names being unique, which we can't assume in general.