5E Character Create Playlist
Page 1 of 6 123 ... Last
  1. #1

    Experimental APIs for FGU

    As part of v4.0.7; I've actually embedded quite a few new APIs that I'm testing out to see how useful they are; as well as to make sure that the API calls are in the right formats that are needed as well as to sound out issues with the new APIs. These APIs may change in the near term based on feedback, and I'll post here if I do. So, if you plan to look at using these, make sure to subscribe to this thread.

    And here they are:

    imagecontrol
    getTokensWithinDistance(token/{x=#,y=#}, #) -> (table of tokens)
    getDistanceBetween(token/{x=#,y=#}, token/{x=#,y=#}) -> (number/nil)

    File (new global package)
    addCampaignAssetFile(path, type) -> (string/nil)
    getCampaignFolder() -> (string)
    getDataFolder() -> (string)
    openCampaignFolder([subpath])
    openDataFolder([subpath])
    openTextFile(path) -> (string/nil)
    saveTextFile(path, string)

    Token
    getTokensWithinDistance(token, #) -> (table of tokens)
    getDistanceBetween(token, token) -> (number/nil)

    Utility (new global package)
    decodeXML(string) -> (table)
    encodeXML(table, [bool]) -> (string)

    Regards,
    JPG
    Last edited by Moon Wizard; January 27th, 2021 at 21:51.

  2. #2
    Thanks Moon Wizard! I just gave Token.getDistanceBetween() a shot, and I love how it returns usable values in ruleset units instead of the pixels or whatever they were that getPosition() returns. I was trying to figure out how to convert for ChatBat. I'll be using that for sure.

  3. #3
    Oh wow, so will this import Hero Labs Online?

  4. #4
    I can see these being pretty useful. Not planning on making any more extensions at the moment, but you never know what will trigger one as my own campaign progresses. I can see these being handy enough (plus any future ones - maybe with lighting?) that I will need to track this thread in case I want to incorporate new stuff into my existing extensions or make a new one.

  5. #5
    Quote Originally Posted by Moon Wizard View Post
    As part of v4.0.7; I've actually embedded quite a few new APIs that I'm testing out to see how useful they are; as well as to make sure that the API calls are in the right formats that are needed as well as to sound out issues with the new APIs. These APIs may change in the near term based on feedback, and I'll post here if I do. So, if you plan to look at using these, make sure to subscribe to this thread.

    And here they are:

    imagecontrol
    getTokensWithinDistance(token/{x=#,y=#}, #) -> (table of tokens)
    getDistanceBetween(token/{x=#,y=#}, token/{x=#,y=#}) -> (number/nil)

    File (new global package)
    addCampaignAssetFile(path, type) -> (string/nil)
    getCampaignFolder() -> (string)
    getDataFolder() -> (string)
    openCampaignFolder([subpath])
    openDataFolder([subpath])
    openTextFile(path) -> (string/nil)
    saveTextFile(path, string)

    Token
    getTokensWithinDistance(token, #) -> (table of tokens)
    getDistanceBetween(token, token) -> (number/nil)

    Utility (new global package)
    decodeXML(string) -> (table)
    encodeXML(table) -> (string)

    Regards,
    JPG
    OMG, how did I miss this post. I will test various bits of this. The distance/between and decode/encodeXML will be useful (aura in the 2E ruleset and the XML handoffs for OOB messages).
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  6. #6
    Quote Originally Posted by Moon Wizard View Post
    Utility (new global package)
    decodeXML(string) -> (table)
    encodeXML(table) -> (string)

    Regards,
    JPG
    I ran a few tests to figure out how to use these, "Utility" seems to be valid? Utility.encodeXML()

    The test was this:

    Code:
    msgOOB.jsonDice = JSON.encode(aDice or "");
    
    Debug.console("manager_action_damage.lua","notifyApplyDamage","aDice---->",aDice);  
    Debug.console("manager_action_damage.lua","notifyApplyDamage","msgOOB.jsonDice---->",msgOOB.jsonDice);
    
    if UtilityManagerADND.isFGU() then
      Debug.console("manager_action_damage.lua","notifyApplyDamage","encodeXML()",Utility.encodeXML(aDice));
    end
    Code:
    [1/27/2021 2:07:39 PM] s'manager_action_damage.lua' | s'notifyApplyDamage' | s'aDice---->' | { #1 = { s'value' = #1, s'type' = s'd3', s'result' = #1 }, s'expr' = s'd3' }
    [1/27/2021 2:07:39 PM] s'manager_action_damage.lua' | s'notifyApplyDamage' | s'msgOOB.jsonDice---->' | s'{"1":{"value":1, "type":"d3", "result":1}, "expr":"d3"}'
    [1/27/2021 2:07:39 PM] s'manager_action_damage.lua' | s'notifyApplyDamage' | s'encodeXML()' | s'<?xml version="1.0" encoding="utf-8"?>'
    I expected the msgOOB.jsonDice to be similar to the encodeXML() value (JSON.encode/decode is my internal methods I use in 2E) but... as you can see it's not. Perhaps im not using it as intended?
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  7. #7
    What is in aDice?

    EDIT: Nevermind, I see it in your code output

    JPG
    Last edited by Moon Wizard; January 27th, 2021 at 21:52.

  8. #8
    The encode/decode XML is very specifically to encode/decode between XML and Lua tables. I do not expect it to match to JSON encoding/decoding.

    JPG

  9. #9
    Quote Originally Posted by Moon Wizard View Post
    The encode/decode XML is very specifically to encode/decode between XML and Lua tables. I do not expect it to match to JSON encoding/decoding.

    JPG
    Woops, yeah thats my fault for seeing encodeXML and translating that to "encodeJSON" because... yeah I'd LOVE that also. My mistake.

    Would it be possible to add a JSON encode? I'm fairly certain that Unity has it native, would be nice to have.
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  10. #10
    Just to clarify, there is a very specific format that the encoding supports for Lua tables in order to allow bi-directional translation of data. It's not meant (at least at this point) to be some sort of general purpose convert "any" Lua table to XML. It could be something to enhance later.

    Within the table, all XML child tags are referred to by number indicating their child sibling order pointing to a table that must include a "name" variable. This is the XML "tag". You can also specify an "attr" table for the tag, as well a numerical children. This is to deal with the fact that XML child tags can have the same name; mirrors the format used for controls to access XML tags; and matches up with a common Lua library used for XML processing.

    Here's an example:

    XML
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <root version="4" dataversion="20201016" release="4.1">
    	<character>
    		<name type="string">Bobby</name>
    		<token type="token">portrait_id-00002_token</token>
    		<coins>
    			<slot1>
    				<amount type="number">0</amount>
    			</slot1>
    			<slot2>
    				<amount type="number">0</amount>
    			</slot2>
    			<slot3>
    				<amount type="number">0</amount>
    			</slot3>
    			<slot4>
    				<amount type="number">0</amount>
    			</slot4>
    			<slot5>
    				<amount type="number">0</amount>
    			</slot5>
    			<slot6>
    				<amount type="number">0</amount>
    			</slot6>
    		</coins>
    	</character>
    </root>
    Decoded Table
    Code:
    { 
    	1 = { 
    		name = "root",
    		attr = { release = "4.1", dataversion = "20201016", version = "4"} 
    		1 = {
    			name = "character",
    			1 = {
    				name = "name",
    				attr = { type = "string" }, 
    				1 = "Bobby", 
    			}, 
    			2 = { 
    				name = "token",
    				attr = { type = "token" }, 
    				1 = "portrait_id-00002_token", 
    			}, 
    			3 = { 
    				name = "coins",
    				1 = { 
    					name = "slot1",
    					1 = { name = "amount", attr = { type = "number" }, 1 = "0", }, 
    				}, 
    				2 = { 
    					name = "slot2",
    					1 = { name = "amount", attr = { type = "number" }, 1 = "0", }, 
    				}, 
    				3 = { 
    					name = "slot3",
    					1 = { name = "amount", attr = { type = "number" }, 1 = "0", }, 
    				}, 
    				4 = { 
    					name = "slot4",
    					1 = { name = "amount", attr = { type = "number" }, 1 = "0", }, 
    				}, 
    				5 = { 
    					name = "slot5",
    					1 = { name = "amount", attr = { type = "number" }, 1 = "0", }, 
    				}, 
    				6 = { 
    					name = "slot6",
    					1 = { name = "amount", attr = { type = "number" }, 1 = "0", }, 
    				}, 
    			},
    		},
    	},
    }
    Regards,
    JPG

Thread Information

Users Browsing this Thread

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

Posting Permissions

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

Log in

Log in