[b87,89,90] BUG: FOREACH strips some leading zeros
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager
Forum rules
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
- lmarkus001
- Great Wyrm
- Posts: 1867
- Joined: Sat Mar 29, 2008 12:30 am
- Location: Layfayette Hill, PA
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
Yep, I just got confirmation that mote has this fixed
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
great! In the mean time: do you happen to have a campaign file with such a token (numeric id). Ive upgraded 'diagnose' in the bag of tricks, to check for this as well, but I can't test it.lmarkus001 wrote:Yep, I just got confirmation that mote has this fixed
alternatively, you could replace the ontokenmove.rptok, with the latest available and run diagnose and let me know if it detects it.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- lmarkus001
- Great Wyrm
- Posts: 1867
- Joined: Sat Mar 29, 2008 12:30 am
- Location: Layfayette Hill, PA
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
Here are my Identify, and my Identify & Replace macros:
Identify Bad IDs
Identify, Copy, Remove Bad IDs
Identify Bad IDs
Code: Select all
[H: selectTokens()]
[H: ids = getSelected()]
[H: badids = "[]"]
[H,FOREACH(id,ids),CODE: {
[ tlen = length(id) ]
[IF( tlen != 32 ): badids = json.append(badids,id); ""]
}]
[R,FOREACH(id,badids,""): "<b>Bad ID:</b> " + getName(strformat("%032d",id)) + " ("+id+")<br>" ]
[R: json.length(badids) + " IDs are bad."]
Code: Select all
[H: selectTokens()]
[H: ids = getSelected()]
[H: badids = "[]"]
[H,FOREACH(id,ids),CODE: {
[H: tlngth = length(id) ]
[IF( tlngth < 32 ): badids = json.append(badids,id); ""]
}]
[R,FOREACH(id,badids,""),CODE: {
[H: switchToken(strformat("%032d",id)) ]
[H: tname = getName() ]
[H: tupdates = json.set("{}","name",tname,"delta",1,"x",0,"y",0)]
[H: copyToken(strformat("%032d",id),1,"",tupdates) ]
[H: removeToken(strformat("%032d",id)) ]
[R: "<b>Bad ID:</b> " + tname + " ("+id+")<br>" ]
}]
[R: json.length(badids) + " IDs were bad and repaired."]
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
Cool.lmarkus001 wrote:Yep, I just got confirmation that mote has this fixed
Nice catch, btw.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
- lmarkus001
- Great Wyrm
- Posts: 1867
- Joined: Sat Mar 29, 2008 12:30 am
- Location: Layfayette Hill, PA
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
https://www.dropbox.com/s/p70gvtimlllrr ... cmpgn?dl=0wolph42 wrote:great! In the mean time: do you happen to have a campaign file with such a token (numeric id). Ive upgraded 'diagnose' in the bag of tricks, to check for this as well, but I can't test it.lmarkus001 wrote:Yep, I just got confirmation that mote has this fixed
alternatively, you could replace the ontokenmove.rptok, with the latest available and run diagnose and let me know if it detects it.
MapTool version: 1.3.b89 Nerps! P
The map: Battlemap_OpenSea
Bad ID tokens: Marine 3, Marine 22
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
thnx.
urgh... why didn't I think of that.strformat("%032d",id)
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
what maptool version are you using for that campaign file? I get a load error (lumens) on load in b90.
ah wait 'lumens' thats the special compilation of Jamz' right?
edit: *facepalm*, you named the file as such.... sigh...
edit2: also your length check works better then the isnumber method as this "00000000E87994005575000000000000" id *does* check as a number but does NOT give any issues.
ah wait 'lumens' thats the special compilation of Jamz' right?
edit: *facepalm*, you named the file as such.... sigh...
edit2: also your length check works better then the isnumber method as this "00000000E87994005575000000000000" id *does* check as a number but does NOT give any issues.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [b87,89,90] BUG: FOREACH strips some leading zeros
ok. BoT is updated. Diagnose now automatically fixes 'broken' ID's.
In case your interested:
This is the relevant part
BoT version 37g.
Also, in case you're interested in the campaign file you provided but then usable in b90, its attached.
In case your interested:
This is the relevant part
Code: Select all
<!-- check whether the ID of the tokens are NOT numerical -->
<!-- code (for the most part) by lmarkus -->
[hasWrongIdName = "[]"]
[idList = getTokens("json", '{layer:["TOKEN","GM","OBJECT","BACKGROUND"]}')]
[splices = bot_createSplices(idList)]
[foreach(splice, splices), CODE:{
[foreach(id, splice), if(length(id) != 32): hasWrongIdName = json.append(hasWrongIdName, id)]
''
}]
<!-- add the mapname to the tokens and create a clickable output -->
[if(json.length(hasWrongIdName)): txtOutput = txtOutput + strformat("The following token <b>ID's</b> have been <b>fixed</b> (numerical token ids can lead to a lot of issues in maptool. By copy pasting the original they get a new ID. Run Diagnose again just to be sure that the new name is not a number):<b> ")]
[txtOutputL = ""]
[foreach(id, hasWrongIdName), CODE:{
[txtOutputL = listAppend(txtOutputL, getName(strformat("%032d",id)))]
[copyToken(strformat("%032d",id),1,"",json.set("{}","name",getName(strformat("%032d",id)),"delta",1,"x",0,"y",0)) ]
[removeToken(strformat("%032d",id)) ]
}]
[txtOutput = txtOutput + txtOutputL + if(txtOutputL != "", "</b><br><br>", "")]
Also, in case you're interested in the campaign file you provided but then usable in b90, its attached.
- Attachments
-
- MT1.3.90.BAD_IDs.cmpgn
- (26.64 MiB) Downloaded 51 times
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS