Code: Select all
[h: '<!-- change DB token from #e to DB -->']
[H: numArgs = argCount()]
[h: assert(!(numArgs<3),"To few arguments to function "+getMacroName()+"(libMapName,libName,dbVersion). "+getMacroName()+"@"+getMacroLocation())]
[h: 'example usage to change Spells DB to 2e: changeDB("Framework - Library","Lib:Spells","2e")']
[h: 'example usage to change MM DB to 1e: changeDB("Framework - Library","Lib:MM","1e")']
[H: libMapName = arg(0) ]
[H: finalName = arg(1) ]
[H: dbVersion = arg(2) ]
[h: currentMap = getCurrentMapName()]
[h: setCurrentMap(libMapName)]
[h: tokenID = findToken(finalName)]
[h: assert(tokenID !="", strformat("Unable to find original DB token %{finalName}, aborting! <br>"),0)]
[h: CurrentX = getTokenX(1, tokenID)]
[h: CurrentY = getTokenY(1, tokenID)]
[h: replacementDBToken = strformat("%{finalName}:%{dbVersion}")]
[h: replacementExists = findToken(replacementDBToken)]
[h, if (replacementExists == ""), code :{
[h: broadcast(strformat("Unable to find replacement DB Token %{replacementDBToken}, aborting! <br>"),"gm")]
[h: abort(0)]
};{}]
[h: updates = strformat("{name: '%{finalName}',x: '%{currentX}',y: '%{currentY}' }")]
[h: copyToken(replacementDBToken,1,libMapName,updates)]
[h: removeToken(tokenID)]
[h: setCurrentMap(currentMap)
Code: Select all
[changeDB("Framework - Library","Lib:MM","1e")]
The macro above SHOWS the X, Y as "-12500, 5000" and that's also what is placed into the "updates" var for copyToken.
Anyone have any theories?