Page 1 of 1

Tokens ID losing leading zeros?

Posted: Sat Apr 22, 2017 5:54 pm
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?

Re: Tokens ID losing leading zeros?

Posted: Sat Apr 22, 2017 6:33 pm
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.

Re: Tokens ID losing leading zeros?

Posted: Sat Apr 22, 2017 7:11 pm
by aliasmask
Yeah, big pain in the behind.

Re: Tokens ID losing leading zeros?

Posted: Sat Apr 22, 2017 7:19 pm
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.

Re: Tokens ID losing leading zeros?

Posted: Sat Apr 22, 2017 11:00 pm
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)

Re: Tokens ID losing leading zeros?

Posted: Sun Apr 23, 2017 5:51 am
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).

Re: Tokens ID losing leading zeros?

Posted: Sun Apr 23, 2017 11:24 am
by xavram
appreciate the clarification guys, heh, at least I know its not something I messed up!!!