PDA

View Full Version : Generating Images/Maps (FGU Scripting)



seansps
July 31st, 2020, 21:45
Hey everyone,

I'm trying to create an extension for Fantasy Grounds Unity that will generate basic outdoor maps from a set of backgrounds and other decorative images.

I have never written a FG extension before, and I am running into some issues, hopefully someone can help.

So far, I have created an additional button in the Images window that creates a new image under a new category with a random name. I am trying to figure out how to add a layer to it (using an asset that is already loaded) and not having any luck. Is there an API call to do this? What I have been trying is just using "createChild" and "setValue" on the image node I created, but it is not adding entries in the "<layers />" node.

Any ideas?


Here's an example of the XML I am generating... (I can't get anything to go under the layers element!)
<category name="Maps - Generated">
<Plains-b67bd10c-1aef-4f99-b63c-b77298014775>
<image type="image">
<allowplayerdrawing>on</allowplayerdrawing>
<gridsnap>on</gridsnap>
<layers />
</image>
<locked type="number">0</locked>
<name type="string">Plains - Fri Jul 31 16:52:44 2020</name>
</Plains-b67bd10c-1aef-4f99-b63c-b77298014775>
</category>

Moon Wizard
July 31st, 2020, 22:01
There is no way to interact with the image data at this point that will allow you to interact with layers. The only thing you can do currently is use a DB.setValue call on the node to reset all layers, and set a single layer in place using a string variable. We won't be looking at fleshing out the image API until sometime after we get to release; since there are a lot of moving parts in the image area still.

Regards,
JPG

seansps
July 31st, 2020, 22:10
Thanks, that's too bad, this would be a great feature, but I look forward to being able to have more control here!

As far as what you said about "set a single layer in place using a string variable". Is it possible to do this to add layers using existing JPG assets? (Each as a layer?)

Moon Wizard
July 31st, 2020, 22:18
No, it was simply a way to create a simple single layer image to support existing ruleset functionality. The DB.setValue call to an image data node with a string clears all layers, and inserts the one in the string as the only layer.

Regards,
JPG

seansps
July 31st, 2020, 22:21
Got it. Thanks for the info!