DICE PACKS BUNDLE
Page 1 of 2 12 Last
  1. #1

    databasenode = { image.id-00002.image } from tokeninstance getContainerNode

    I'm trying to figure out how to get the actual tokeninstance DB node so I can access the <fow> data for it. But it seems I have to do it manually - so I went and called


    Code:
    	local nodeContainerOld = oldTokenInstance.getContainerNode();
            for _,oldnodeLayer in pairs(DB.getChildren(nodeContainerOld, "layers")) do
    ...
    But I can never find layers. In fact, using the container node to access any of the values under this node (in my case its databasenode = { image.id-00002.image } ) also return nil.

    I'm not sure why a node that supposedly references the object that holds the tokeninstance cannot actually reference anything under it. I'd be open to an alternative way of just getting the db.xml node for the tokeninstance if there is an alternate way to get this.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  2. #2
    *ahem* I will plug FoWEnhanced here (in the forge store). You are completely correct that you can't access anything under the image.id-00000.image object through any calls to the DB. I do hope to add more features to FoWEnhanced if you have any particular needs.

  3. #3
    Quote Originally Posted by jharp View Post
    *ahem* I will plug FoWEnhanced here (in the forge store). You are completely correct that you can't access anything under the image.id-00000.image object through any calls to the DB. I do hope to add more features to FoWEnhanced if you have any particular needs.
    Yes this is very specialized <fow> use as my polymorphism extension replaces tokens and more but loses the <fow> data - so all I'm trying to do is Access the data for the old and the new so it translates down in my replace token code and copies over the old one. Nothing to do with what I'm reading this thing does.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  4. #4
    I'll add an appropriate API to the next build. I'm thinking getFoW(token) returns FoW as string and setFoW(token,string). If you have some other API in mind I can try that. However, I'm not certain how this might work to have other people need to have my extension to have your work. Maybe some price sharing arrangement is better and the functionality simple gets put directly into your code.

    If interested we can discuss in discord at some point.

  5. #5
    Quote Originally Posted by jharp View Post
    I'll add an appropriate API to the next build. I'm thinking getFoW(token) returns FoW as string and setFoW(token,string). If you have some other API in mind I can try that. However, I'm not certain how this might work to have other people need to have my extension to have your work. Maybe some price sharing arrangement is better and the functionality simple gets put directly into your code.

    If interested we can discuss in discord at some point.
    I'll just figure out the standard XML DB.xml way of grabbing it and post it here when I do - its not going to be all that big of a deal. Just wondered if someone knew how to do it.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  6. #6
    Quote Originally Posted by jharp View Post
    I'll add an appropriate API to the next build. I'm thinking getFoW(token) returns FoW as string and setFoW(token,string). If you have some other API in mind I can try that. However, I'm not certain how this might work to have other people need to have my extension to have your work. Maybe some price sharing arrangement is better and the functionality simple gets put directly into your code.

    If interested we can discuss in discord at some point.
    even if SilentRuin doesn't need it, can you please still add those API calls, as others systems that swap tokens may want to use this, thanks!

  7. #7
    I've added it to my todo list. If you have any suggested api needs let me know in my main thread.

  8. #8
    Well, while I can edit it into the db.xml on the fly in the lua code - I can't seem to access the inline memory of the token for the underlying tags of the image object which is essentially an imagecontrol. As I need to do this at runtime with the currently defined data in FGU memory and also replace another set of data loaded into FGU memory - I can't find a way to do that without Moon Wizard providing an API into that ares of the tokeninstance data.

    If there is a way to do that to the inline memory then I'm not finding it. I'll have to wait till an API in FGU comes out giving access to all of the tokeninstance live data.

    Simply editing the db.xml worked but did not solve my runtime issues.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  9. #9
    MeAndUnique and I have been hashing this out and will try one more approach based on his input. Still requires some trial and error as its evident that the pain in the butt export code from /export still removes the tokens but db.export does not. Why these things are so different everywhere I have no idea but it makes figuring out this stuff 10 times longer. This will be my last attempt to get a runtime update in the middle of my code - will post here the results.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

  10. #10
    Giving up - I'd have to manually parse the XML string (mostly because Utility.decodeXML loses data and Utility.encodeXML will not generate the original string) - copy the data over into the new id - which of course is not even there as I'd have to force a save before I read the XML string.... just too much hassle. I think it would work if I knew how to force a save of the campaign which would of course would delay the runtime (not acceptable) - and delete my temp xml I'm creating as they disabled os.remove in FGU.

    If anyone wants to see the gist of where I was heading - and gave up on due to above statments... This was in code for replacing the token with another (losing the FOW). So just going to wait for Moon Wizard to supply an API to get/set the FOW in runtime memory.

    Code:
    -- create an xml file with the old image data
    	local sPath = File.getCampaignFolder() .. "PolyTokenTemp.xml";
    	DB.export(sPath, nodeContainerOld.getParent());
    	local sData = File.openTextFile(sPath);
    	-- extract the id for the old token
    	local oldID = oldTokenInstance.getId();
    	-- extract the fow tag from the old xml string
    	-- find the id for the new token and add/replace old fow data into it
    	local newID = newTokenInstance.getId();
    	-- write the new image xml node out to file
    	File.saveTextFile(sPath, sData);
    	-- import the new image xml node from file
    	DB.import(sPath, newTokenInstance.getContainerNode().getParent());
    This will output the image data with the fow info for sure but in my world will actually fail later because the new ID was not in the file (only memory) wiping it out when imported. To much of a pain to bother with - but supplying what I did in case others don't need runtime instant workability.
    Last edited by SilentRuin; September 16th, 2021 at 23:57.
    Free(Forums/Forge) Extension(FGU 5E):
    Paid (Forge) Extension(FGU 5E):

Thread Information

Users Browsing this Thread

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Dungeons & Dragons 2024 Core Rulebooks Pre-Order

Log in

Log in