Tokens ID losing leading zeros?

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Tokens ID losing leading zeros?

Post by xavram »

In 1.4.0.5, I'm getting tokens that sometimes throw the following error when a particular macro is called.

Error executing "getTokens": the token name or id "343778971601000000000000" is unknown.

Here is the code.

Code: Select all

[broadcast(getSelected())]
[h : selectedId = getSelected()]
[broadcast(selectedId)]
[h : MStance = 0]
[h : cond = ""]
[h, if(isPC()) : cond = '{ range: {upto:1, distancePerCell:0, metric:"ONE_TWO_ONE", token: ' + selectedId + '}, npc:1,visible:1 }' ; cond = '{ range: {upto:1, distancePerCell:0, metric:"ONE_TWO_ONE", token: ' + selectedId + '}, pc:1,visible:1 }']
[broadcast(cond)]
[h: ids = getTokens("json", cond)]
On this "bad" token, here are my broadcasts...

00000000343778971601000000000000
343778971601000000000000
{"range":{"upto":1,"distancePerCell":0,"metric":"ONE_TWO_ONE","token":343778971601000000000000},"npc":1,"visible":1}
Error executing "getTokens": the token name or id "343778971601000000000000" is unknown.

Notice that when it first broadcasts "getSelected()", the ID has leading zeros, like most tokens? But once its assigned to the selectedId variable, those leading zeros disappear (second broadcast) and then when that variable is using in setting the conditions for the getTokens call, it fails because its not a valid token.

Here is the out put for a token that's actually working.

00000000343778971C01000000000000
00000000343778971C01000000000000
{"range":{"upto":1,"distancePerCell":0,"metric":"ONE_TWO_ONE","token":"00000000343778971C01000000000000"},"npc":1,"visible":1}

And then the getTokens call works fine. Notice that the leading zeros didn't disappear between the two broadcasts?

Now for the really goofy thing. If I copy the bad token and paste, guess what? It now works FINE.

Reason i bring this up? This happened twice last during our game. Token was working fine, then suddenly started throwing this error. Copied the token, pasted it, deleted the old one and then it started working again.

So there's a workaround for this problem but in the past year of using 1.3.91, I never once saw this problem. Now on the first two sessions of using 1.4.0.5, I've seen it a couple of times. Any ideas?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Tokens ID losing leading zeros?

Post by wolph42 »

this is an ancient issue which i REALLY would like to see resolved and the devs are working on a solution in the next release. in the mean time you can use the boT --> diangose button to scan your campaign file for 'issue' tokens.

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Tokens ID losing leading zeros?

Post by aliasmask »

Yeah, big pain in the behind.

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Tokens ID losing leading zeros?

Post by xavram »

Wow, really? Like I said, never ever say this in .89, not after running that for 2 years. Then in first 2 days, this has bit me on the butt multiple times in 1.4.0.5

But, if its a known issue, okay, I can work around that with the copy/paste solution.

taustinoc
Dragon
Posts: 516
Joined: Mon Aug 03, 2015 6:30 pm

Re: Tokens ID losing leading zeros?

Post by taustinoc »

Edit: The previous, if you read it, was incomplete.

What's happening is that sometimes, the randomly generated ID, which is supposed to be alpha-numberic, randomly has no letter in it (as your example). When this happens, it gets treated as a number instead, and numbers get the leading zeroes dropped. So use an if statement to determine if it is a number, and if so, use strformat to force it to be a string, with leading zeroes, 32 characters long. If not, use as is.

So try this instead of the selectedId variable by itself:

Code: Select all

if(isNumber(id)): (strformat("%032d", selectedId));(selectedId)

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Tokens ID losing leading zeros?

Post by wolph42 »

you can do that trick but there are sooo many variables where that token id is used that you keep getting bit and its a bloody pain to debug. hence its better to remove the tokens from your campaign entirely (either by copy paste delete or using the bot).

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: Tokens ID losing leading zeros?

Post by xavram »

appreciate the clarification guys, heh, at least I know its not something I messed up!!!

Post Reply

Return to “MapTool”