Problem with TokenManager/ImageManager
I am attempting to make a ruleset for Earthdawn based on CoreRPG ruleset. I am making fairly good progress, and I finally figured out how to properly navigate the Fantasy Grounds API. The problem I am having seems to have appeared recently, but I have not modified either the scripts/manager_image.lua or scripts/manager_token.lua but I am suddenly getting these errors:
"Script Error: [string "scripts/manager_image.lua"]:208: attempt to call field 'getDatabaseNode' (a nil value)"
"Script Error: [string "scripts/manager_image.lua"]:223: attempt to call field 'getDatabaseNode' (a nil value)"
Line 208 is for adding a token to a map, line 223 is for removing the token.
I cannot seem to recreate the error in my test campaign using the base CoreRPG ruleset, so I know it's something I've done, even though I didn't modify this file.
The strangest thing is that it only happens when I try to add a token to a map after adding tokens on another map. If I open FG, I can add a token to a map, and I can even add more tokens multiple times on the same map from the tokens window or the combat tracker. But, if I then close that map and open a new map and try to add a token to that map, the errors start. Then it happens every time I add or delete any token to any map. If I then close and reopen FG, the first map I open is fine, until I close that map and try to add tokens to a new map.
This is driving me crazy, I hope someone can help me figure out what's going on. I have modified a good number of existing files from CoreRPG, and I have added my own files that I created from scratch, but I swear I have not modified any of the files that mention tokens. To make sure of this, I re-copied the files for the TokenManager and ImageManager from the CoreRPG ruleset.
https://github.com/CaptJack2883/Earthdawn/tree/master
Edit: This happens in both FGU and FGC. I have added a link to my GitHub for the full code.