PDA

View Full Version : Starfinder, Starship Stuff, struggling with DB node navigation.



Nutter4Ever
April 30th, 2019, 00:00
I'm working on the Starfinder starship dice rollers. Not sure how many are familar with it. But heres what I've got so far:

27219

On the screen shot when you click the dice at the end it calls a function that I've traced down that calls:


local nodeChar = window.getDatabaseNode();
local rActor = ActorManager.getActor("pc", nodeChar);
ChatManager.SystemMessage(rActor.sType .. "", false);
ChatManager.SystemMessage(rActor.sName .. "", false);
ActionSkill.performRoll(draginfo, rActor, sSkill, nValue);


Now this is after 3 hours of poking around and on the fly learning Lua, so bear with me.

The chatManager.SystemMessagers were just messages to me so see what the values held, as the dice roll wasn't for Bob, but was for "Audacious Gambit", so I figure that it's taking that part of the screen and trying to make an actor out of it, which given they aren't a PC then it falls flat.

However in the DB.xml we have:



<id-00001>
<public />
<actions>
<public />
<audacious_gambit>
<public />
<attackmod1 type="number">0</attackmod1>
<attackmod2 type="number">0</attackmod2>
<attackmod3 type="number">0</attackmod3>
<attackmod4 type="number">0</attackmod4>
<name type="string">Audacious Gambit</name>
<skill1 type="string">piloting</skill1>
<type type="string">skill</type>
</audacious_gambit>
...
</actions>
<link type="windowreference">
<class>charsheet</class>
<recordname>charsheet.id-00001</recordname>
</link>
<minoractions>...
</minoractions>
<name type="string">Bob</name>
<role type="string">Pilot</role>
<roleclass type="string">officer</roleclass>
<token type="token"></token>
<tokenscale type="number">1</tokenscale>
</id-00001>


As far as I can make out, I need to do something to get up a level in the DB, and then get the name which will return Bob, then I can find Bob as a character sheet, and use that same logic to get the skill required, get the skill from Bob, and then make the dice rolls. But can I figure out how to even get the message box to tell me Bobs name, I cannot.

If anyone has an insight that they could off that would be cool. I need to get some sleep.

Thank you all in advance.

Nutter4Ever
April 30th, 2019, 00:43
Actually, I think I need this bit:

<link type="windowreference">
<class>charsheet</class>
<recordname>charsheet.id-00001</recordname>
</link>

if I can grab that note and make a PC out of it... I think that might sorted it... too tired to try now, and if anyone has the exact code just to grab that it would be appreciated.

Moon Wizard
April 30th, 2019, 17:18
Nutter4Ever,

You can also use the Debug.chat and Debug.console APIs to output any list of variables to the chat window or console window.
Ex: Debug.chat(rActor.sType, rActor.sName)
Ex: Debug.chat(rActor)

Depending on what scope your code is running in, you would get something like this. (This code assumes it is running in control context of a control that is a child of the same window as the link.)



local node = window.getDatabaseNode();
local sClass, sRecord = DB.getValue(node, "link", "", "");
if sClass ~= "charsheet" then return; end
local nodeChar = DB.findNode(sRecord);
if not nodeChar then return; end
local rActor = ActorManager.getActor("pc", nodeChar);
ActionSkill.performRoll(draginfo, rActor, sSkill, nValue);


Regards,
JPG

Nutter4Ever
April 30th, 2019, 20:19
Thank you for your reply. It gives me something to work with, it's not working out the box but not expecting that.

I just wish I understood half of what you said and this might all make sense :-)

The link was a couple of steps up, so if that's what you meant by scope I had to "...link" (that bit was learnt from a really old post, that turned out also to be authored by you :-).

And now there are some other quirks need to work out, but now I've gotten a little bit better at navigating the DB hopefully it should prove a little easier.

Thank you

Trenloe
April 30th, 2019, 20:27
The link was a couple of steps up, so if that's what you meant by scope I had to "...link" (that bit was learnt from a really old post, that turned out also to be authored by you :-).
If you haven't seen it already, the Database page in the developer Wiki might help explain a few things: https://www.fantasygrounds.com/wiki/index.php/Developer_Guide_-_Rulesets_-_Database This explains, with examples, things like database paths (absolute and relative)

Nutter4Ever
April 30th, 2019, 21:09
If you haven't seen it already, the Database page in the developer Wiki might help explain a few things: https://www.fantasygrounds.com/wiki/index.php/Developer_Guide_-_Rulesets_-_Database This explains, with examples, things like database paths (absolute and relative)

Thank you Trenloe, I have seen that document, but I'm so not familar with Lua or the coding in FG to make sense of the documents without the try it and see approach.

Would also suggest the https://www.fantasygrounds.com/refdoc/DB.xcp page for what the DB.xxx commands do.