PDA

View Full Version : JSON file from Hero Labs Online



Frodie
November 23rd, 2020, 23:46
Hero Labs Online now has the export of the character JSON file. So how do we get that into FGU?

darrenan
November 23rd, 2020, 23:53
Someone will need to write a converter app. Unless they published a full JSON Schema it will be dicey getting the conversion right from single example characters. Looks like they did publish some documentation:

https://docs.herolab.online/HLO-Export-Format-Documentation.pdf

celestian
November 24th, 2020, 00:26
Hero Labs Online now has the export of the character JSON file. So how do we get that into FGU?

This would be a trivial thing (well, a lot less work) if we could get access to the Unity JSON tools in the FGU API. There is a Unity JsonUtility that lets you copy/move data around to/from JSON.

The only JSON work I know performed in FG is within the 2E ruleset. I put together a rudimentary global script that lets me copy a variable into a JSON string and pass it off to the OOB function to maintain the entire structure of it data.... but it's not nearly as complete at the Unity tool would be.

Frodie
November 28th, 2020, 13:58
I would like to help out to write something, but I have zero skills in this. Is there some kind of template I can follow and edit?

darrenan
November 28th, 2020, 15:39
No, as I explained above, this will require writing an application outside of Fantasy Grounds. The simple version would just convert the JSON into the corresponding character XML. A more involved version could also include pulling the character from HL and all the authentication and networking code that would involve.

It's possible you could also do this as an extension that lets you paste in the JSON and create the character from that, but that would involve writing a bunch of JSON parsing code (or as Celestian explained, use some existing JSON parsing library)

Frodie
November 28th, 2020, 15:50
I wonder if someone would write something and sell it on drivethrurpg, or is there copywrite issues?

darrenan
November 28th, 2020, 17:01
I found an open-source LUA JSON library, I'll see if I can hack something together.

Frodie
November 28th, 2020, 17:13
Oh wow, that would be very cool, thank you!

celestian
November 29th, 2020, 20:31
No, as I explained above, this will require writing an application outside of Fantasy Grounds. The simple version would just convert the JSON into the corresponding character XML. A more involved version could also include pulling the character from HL and all the authentication and networking code that would involve.

It's possible you could also do this as an extension that lets you paste in the JSON and create the character from that, but that would involve writing a bunch of JSON parsing code (or as Celestian explained, use some existing JSON parsing library)

Feel free to look in the 2E ruleset (if you're looking for a in-FG solution). manager_json.lua. It's not as flexible as something like the Unity API version would be but it works for my needs and might for whomever is working on this particular project.

darrenan
November 29th, 2020, 23:44
I grabbed this one and modified it to work inside FG: https://github.com/rxi/json.lua

Skellan
November 30th, 2020, 11:29
Awesome stuff.

Is this on the github? I can't see it - probably me being blind... :)

darrenan
November 30th, 2020, 16:20
Other than the link I pasted above, no.

Frodie
December 4th, 2020, 17:19
Someone has made one for another VTT, IDK if that will help with getting it into FGU, but here is the link to the thread - https://forums.wolflair.com/showthread.php?t=65144

Weissrolf
December 4th, 2020, 18:21
I grabbed this one and modified it to work inside FG: https://github.com/rxi/json.lua
What had to be modified to make it work?

I understand that "require" is not available in FG Lua, so do you copy the whole library into your script?

darrenan
December 4th, 2020, 20:07
The whole library is just a single LUA file. It had some executable code at the global scope that needed to be moved into onInit() and there were some other scoping issues that required some locals to be moved around.

At this point it's unlikely I'll continue working on this. It's more involved than I want to commit to right now.

Frodie
December 5th, 2020, 16:26
Thank you for trying, hopefully someone will be able to figure this out.