PDA

View Full Version : How to extract data from a dropped getShortcutData type of object?



SilentRuin
July 11th, 2020, 04:38
I was experimenting around with onDrop functionality - dragging things into a field that supported it and seeing what getShortcutData() gave me back.

I would see things like this:

-- charsheet

-- shortcut = {charsheet:charsheet.id-00002}
-- npc

-- shortcut = {npc:reference.npcdata.aarakocra@DD MM Monster Manual}
-- shortcut = {npc:combattracker.list.id-00005}
-- item

-- shortcut = {item:item.id-00001}
-- shortcut = {reference_equipment:reference.equipmentdata.abacu s@DD PHB Deluxe}
-- shortcut = {reference_mountsandotheranimals:reference.equipme ntdata.camel@DD PHB Deluxe}
-- shortcut = {reference_armor:reference.equipmentdata.leather@D D PHB Deluxe}
-- shortcut = {reference_weapon:reference.equipmentdata.club@DD PHB Deluxe}
-- shortcut = {reference_magicitem:reference.magicitemdata.leath erarmorofacidresistance@DD Dungeon Masters Guide}

Now I'm new to "link" logic in LUA and how to access it. Is there a document/example that actually details out how I can extract out specific information from these things?

I looked at things using getShortcutData() in 5E and CoreRPG code but it made no sense to me. Things did not really seem to ever be trying to grab any specific data out that I could see.

For example - I can see how I could define a node for things like charsheet.id-00002/combattracker.list.id-00005/item:item.id-00001 and find the data under those nodes in the DB - but what about things like all the reference* type of shortcuts? How do you extract that data?

Maybe a dumb question - but I really don't see it. I get something dropped on me - I want to find the data for it - no matter where it was dropped from. Not seeing how some of that data extraction works.

damned
July 11th, 2020, 05:17
Search CoreRPG or 5E for

draginfo.get

See examples of all of these:
getType()
getDieList()
getTokenData()
getShortcutData()
getDatabaseNode()
getNumberData()
getDescription()
getStringData()
getCustomData()
getMetaDataList()
getSlotType()
getSecret()
getSlotCount()

damned
July 11th, 2020, 05:17
There may be others in 5E I havent looked.

SilentRuin
July 11th, 2020, 15:53
Search CoreRPG or 5E for

draginfo.get

See examples of all of these:
getType()
getDieList()
getTokenData()
getShortcutData()
getDatabaseNode()
getNumberData()
getDescription()
getStringData()
getCustomData()
getMetaDataList()
getSlotType()
getSecret()
getSlotCount()

All the stuff above I can actually see simply by doing Debug.console(dragInfo) which does not give me anything about the reference data. For example, if I drop an NPC into my field and print out the dragInfo I can see:

DRAGDATA = { type = s'shortcut', desc = s'Aarakocra', #slots = #1, slot = #1, string = s'', num = #0, diceexpr = {}, shortcut = {npc:reference.npcdata.aarakocra@DD MM Monster Manual}, asset = {, instance = }, custom = nil }

Which seems to be what all the functions you just listed are involved with. I am trying to get the data out of

reference.npcdata.aarakocra@DD MM Monster Manual

Or things like that. Looking at the functions you provided I don't see how to look up anything in the NPC sheet that is displayed if I actually use the link to bring up something instead of dropping it on my field.

As I stated in my original message - if the shortcut is a DB reference then its simple - make it a DB node and go get data. But these reference things I don't understand how to extract the data out of. Where is the non-id name? The strength? Intelligence? Block of text describing attacks?

You'll have to explain how these functions get me that as I'm not seeing it in examples. They just look like they are dragging things out of dragInfo - which is just a vehicle for transporting data - not the data itself. I want the data.

damned
July 11th, 2020, 15:55
reference.npcdata.aarakocra@DD MM Monster Manual

is a npc in the Monster Manual
you then have to lookup that record to find the other info you mention

SilentRuin
July 11th, 2020, 16:29
reference.npcdata.aarakocra@DD MM Monster Manual

is a npc in the Monster Manual
you then have to lookup that record to find the other info you mention

And we come full circle to my original post.

How? Is there document/examples around that show this?

SilentRuin
July 11th, 2020, 17:57
Maybe I've found something. I thought if I did not see the entry in my db.xml - DB.findNode() would not be able to find it.

But apparently, it is more intelligent than I thought and can locate other .xml files outside of my campaign's db.xml.



local sClass, sRecord = dragInfo.getShortcutData();

Debug.console(dragInfo);

local nodeSource = DB.findNode(sRecord);
Debug.console(nodeSource);
if not nodeSource then
local sRecordSansModule = StringManager.split(sRecord, "@")[1];
nodeSource = DB.findNode(sRecordSansModule .. "@*");
Debug.console(nodeSource);
if not nodeSource then
return false;
end
end


Apparently it returns a db node in my experiment above when dropping reference.npcdata.aarakocra@DD MM Monster Manual type of data. So if that is the case, then I know how to extact the data once I figure out the XML tags to use.