Joshua Stream Pre
  1. #1

    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.

    Edit: This happens in both FGU and FGC. I have added a link to my GitHub for the full code.
    Last edited by CaptJack2883; May 12th, 2021 at 11:52. Reason: I have added a link to my GitHub for the full code.

  2. #2
    Are you calling ImageManager in your code; or replacing functions that call ImageManager?

    It sounds like something is calling ImageManager.registerImage with a value of nil.


  3. #3
    That's why I'm so confused. None of my code refers to ImageManager in any way. I'm literally using the CoreRPG versions of all the files that make those calls. But I guess somehow I'm causing whatever variable is being sent to the call to be nil. I'll see if I can try to back-track the variable to see where its getting turned into nil. I did notice that when this starts happening, all of the character's portraits went blank. But even still, it's also happening when use tokens from the token bag. It's all very strange.

    Thanks for your help!

  4. #4
    If you replace any functions; then you lose access to the variables they reference. Every script has its own “function/variable space”; and even if you override one in another script, the variable space is still the new script for those calls.


  5. #5
    That's why I am having trouble understanding why there would suddenly be an error with the images and tokens if I didn't modify or replace those. I also don't understand why it doesn't happen until after I've opened and closed an image, instead of every time?

    I was doing more testing today, and I found out that the error on FGU is different than the one on FGC, even though it still reports an error. The error I get from FGU is:

    [ERROR] Handler error: [string "scripts/manager_image.lua"]:208: attempt to index local 'vImage' (a userdata value)

    So according to FGU, the vImage isn't nil, but it isn't the right kind of data either.

    I've made sure my github is updated with today's code. You can see from the file list, as well as the base.xml file that I haven't touched either the manager_token.lua or manager_image.lua files. If either of these are accessed or replaced somehow within the files I uploaded, I haven't been able to figure out where.

    Thanks again, I really do appreciate all your help!

    Here is the link again, just in case:

  6. #6
    Make sure you use liberal use of the and Debug.console APIs to review variable inputs and outputs in calls that you override.

    Just because something is a userdata; does not mean it’s the right type of object. Userdata implies any custom object set up in Lua; so it can be any FG object type. You won’t be able tell without outputting it in debug; or checking the type(<variable>)

    Additionally, if the object is deleted but not removed from the list by the same script that added it, then it will still be referenced by script variables which will cause issues. Since FGC and FGU handle deleted objects slightly differently, then that may be why you get different errors.

    So, most likely, it appears that either the wrong object type is being used, or deleted objects are not being removed.


  7. #7
    Ok, thanks for your help.

  8. #8
    After more testing today, I finally found it! The command helped me find out that the ImageManager.registerImage() function was being called twice. From there, I realized the only place that was being called was the imagewindow's onInit() function. After that, I was able to find out that I had inadvertently changed the button_record_locked template to call the window.onInit() function twice on every window with a lock button.

    So that's how I messed up the ImageManager without directly modifying it. Thanks for your help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Log in

Log in