I was able to retrieve the elevation in the code, and was able to store it in scCopy, but the value is lost after scCopy.createEmbeddedDocument in the update_preset function. My guess is that a token somewhere during this process is PrototypeTokenData (which does NOT have elevation) and is not TokenData (which does have elevation). I can get this to work by getting the elevation at the start of main() and passing it in as an argument to replace_token() and doing this at the end of the function:
let newToken = canvas.tokens.get(newTokenID[0])
await newToken.document.update({'elevation': elevation})
I was able to retrieve the elevation in the code, and was able to store it in
scCopy
, but the value is lost afterscCopy.createEmbeddedDocument
in theupdate_preset
function. My guess is that atoken
somewhere during this process isPrototypeTokenData
(which does NOT have elevation) and is notTokenData
(which does have elevation). I can get this to work by getting the elevation at the start ofmain()
and passing it in as an argument toreplace_token()
and doing this at the end of the function: