The problem has been fixed with TheAaron and Scott's help. Heyo everyone. I'm most of the way through creating a script to duplicate all objects on a map to a second map, but I've been running into a weird problem that I have no idea how to resolve. Script in question here . I have an attribute in state at 'state.PageCopy.active', that the script uses to prevent users from potentially interrupting active processes. After the script is done creating new graphics, it should call the clearState() function, which resets state.PageCopy to a default state, so users can copy another page. My problem is that clearState() fires but doesn't actually update the state object. What happens instead is that all of the chat messages will fire, as well as all log() calls (even within the clearState function), but state.PageCopy.active stays true and the script continues to think that it's running. I've tried using _.defer and _.delay to let clearState() fire after everything is done, but I get a console error that says: TypeError: Cannot read property 'apply' of undefined
TypeError: Cannot read property 'apply' of undefined
at null._onTimeout (/home/node/d20-api-server/node_modules/underscore/underscore.js:768:18)
at Timer.listOnTimeout (timers.js:92:15) preparePageCopy() is the main function that handles everything. If you want to see the script work, use !pagecopy or '!pagecopy source' on a page to designate it as the source, then !pagecopy again on a different page. A chat prompt will open before the script works. Everything works fine (minus some z-ordering) right until the very end where state.PageCopy is supposed to reset and state.PageCopy.active is set to false. I've also run into a weird issue where pages that have been edited by this script do not delete properly. If you copy page A to page B, page B will reappear after being deleted with nothing inside. You have to delete it twice for it to totally disappear.