STAR TREK 2d20
  1. #1

    Adding Image to A Map

    Hello everyone, I've been looking into how to make extensions for the first time. It's my Christmas present to myself. I'm still at the beginning, looking at various tutorials, but most of them are outdated at this point, so I've also been relying on unpacking Core RPG and looking at API documents but there's a lot, so I may need some help.

    First question, is it possible to add an image to another image programmatically through a Lua extension? Would I use the addLayer method for it that I see here, and add an image layer that points to an icon resource or something like that? Or would it require something like creating a windowclass with an icon image without a frame?

    Example uses would be adding random decorations to a map, or making other sorts of indicators on the map besides the arrow, square, and circle.

  2. #2
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,272
    Blog Entries
    9
    The current CoreRPG capability that I'm aware of that does this is around the blood splats/death indicators when an NPC is removed from the CT. So yes, its achievable There is a Death Indicators extension that you might find that does a similar thing, but the code you are looking for might be more apparent. Death Indicator Ex v4.5 extension for 5e Fantasy Grounds Unity

    Be aware, make sure you are adding them as layers/images and not tokens. Tokens impact visibility calculations and performance (the extension originally had this problem, but I think SR has since resolved it.)

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

  3. #3
    Yes, thanks! I was hoping someone would respond with some extensions that did something similar I can look at, but I realized I forgot to ask.

    Appreciate the direction! And happy holidays!

  4. #4
    Hope everyone had a good Christmas and is ready for New Year's!

    I've been experimenting with some image adding using the direction of the death indicators functionality Lord Entrails pointed me towards, both the Core RPG version and the 5e extension above, but I have run into a few issues I hope someone can help me. Specifically, I can't really figure out what the "asset" parameter is for the addLayer parameters. I keep getting errors when throwing my own images in there from the same place I put other images (an icon entry in my extension.xml file in the base node pointing to an image in my graphics folder). I can't really figure out what is put in there or how. For CoreRPG, I found the general place its put it in in the manager_image_deathmarker.lua file in the getSetMap() where the sAsset variable here seems to be the key.

    function getSetMap()
    local tSetMap = { };
    for _,nodeSet in ipairs(DB.getChildList("settings.imagedeathmarkers et")) do
    local sName = DB.getValue(nodeSet, "name", "");
    local tSetData = {};
    for _,nodeAsset in ipairs(DB.getChildList(nodeSet, "assets")) do
    local sAsset = DB.getValue(nodeAsset, "value", "");
    if sAsset ~= "" then
    table.insert(tSetData, sAsset);
    end
    end
    local sTint = DB.getValue(nodeSet, "tint", "");
    if (sTint ~= "") then
    tSetData.tint = sTint;
    end
    tSetMap[sName] = tSetData;
    end
    return tSetMap;
    end
    But kind of stuck here. Not really sure what's happening in all those lines. Looks like it's related to some db entry in <settings><imagedeathmarkerset>, but I can't find that entry in any db.xml files in the test projects I've been working with or anywhere in my Find in Files search, let alone anything related to assets in those files at all. I tried throwing a Debug.console line into this file to see if it can help show me what's happening:

    local x,y = token.getPosition();
    local nGridScale = TokenManager.getTokenSpace(token);
    Debug.console("manager_image_deathmarker.lua sAsset", sAsset); --I added this line here
    Image.addLayerPaintStamp(sPath, nLayerID, { asset=sAsset, w=nGridScale, h=nGridScale, x=x, y=y, color=sTint });
    But even when I successfully got death markers to appear by killing enemies then removing them from the combat tracker, nothing would pop up in the console log. Any suggestions on why the console log isn't popping up (in practice 4e and 5e games I tried)? Or with using an image I have as an asset for the Image.addLayer or Image.addLayerPaintStamp functions? Is the relevant database node being created and deleted so fast that I can't see it, or am I on the completely wrong track?

    Thanks and have a Happy New Year!

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    [QUOTE=SieferSeesSomething;704951]...nothing would pop up in the console log. Any suggestions on why the console log isn't popping up[.../QUOTE]
    The console window only "pops up" (opens by itself) if there is an error. Just writing debug to the console won't automatically open it. You can open the console by using the /console chat command but you may find it easier to open the console.log file from the FG app data directory.

    For your first question - sAsset is a FG filepath to a valid graphics file, it isn't an FG icon resource. For example, looking in the database of a test campaign:

    Code:
    		<imagedeathmarkerset>
    			<id-00001>
    				<assets>
    					<id-00001>
    						<value type="string">images/Death Markers/blood/blood_01.png@SmiteWorks Assets</value>
    					</id-00001>
    In this example, the sAsset value is: images/Death Markers/blood/blood_01.png@SmiteWorks Assets - this is the images/Death Markers/blood/blood_01.png file within the SmiteWorks Assets module (SmiteWorks Assets.mod in the <FG app data>\modules directory).

    Hope this helps.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    Oh ya, sorry I phrased that wrong. I was able to make the console log pop up easily enough, it's just that the specific message wouldn't appear within it.

    For the sAsset field example you gave, that was very helpful to understanding what's happening there, thanks! One more question: How would I use that with an extension I'm making instead of putting the graphic in a separate module? Putting images/testimage.png both in the extensions images folder and adding it as an asset to the test campaign I'm using both didn't work. When I put in "images/Death Markers/blood/blood_01.png@SmiteWorks Assets", it does work. Does it only work if i put a graphic in a separate module? Feels like it would make it difficult to ship it all together in a single extension zip, for example.

    Thanks for the help! I feel like I'm getting close!
    Last edited by SieferSeesSomething; January 1st, 2024 at 04:22.

  7. #7
    Zacchaeus's Avatar
    Join Date
    Dec 2014
    Location
    Scotland
    Posts
    20,828
    I don't know the answer you are looking for but there are many extensions which also have accompanying modules. If your extension was on the forge then any files associated with the extension would also get downloaded for anyone subscribed to it. Extensions aren't limited to just the extension file.
    If there is something that you would like to see in Fantasy Grounds that isn't currently part of the software or if there is something you think would improve a ruleset then add your idea here https://www.fantasygrounds.com/featu...rerequests.php

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by SieferSeesSomething View Post
    One more question: How would I use that with an extension I'm making instead of putting the graphic in a separate module? Putting images/testimage.png both in the extensions images folder and adding it as an asset to the test campaign I'm using both didn't work. When I put in "images/Death Markers/blood/blood_01.png@SmiteWorks Assets", it does work. Does it only work if i put a graphic in a separate module? Feels like it would make it difficult to ship it all together in a single extension zip, for example.
    The graphics files need to be accessible via the FG filesystem - so this is local files (global and campaign based), and in modules (.mod files). So you will need two files - a .ext extension and a .mod module. However, the module file doesn't have to be activated - FG can access the files directly as if it's a filesystem.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  9. #9
    Thanks everyone! I made a module file and it seems to be working! Slowly, but surely I'm getting it lol.

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
  •  
DICE PACKS BUNDLE

Log in

Log in