5E Character Create Playlist
  1. #1

    Starfinder, Starship Stuff, struggling with DB node navigation.

    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:

    bob.png

    On the screen shot when you click the dice at the end it calls a function that I've traced down that calls:
    Code:
    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:

    Code:
    				<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.

  2. #2
    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.

  3. #3
    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.)

    Code:
    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

  4. #4
    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

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by Nutter4Ever View Post
    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/...ets_-_Database This explains, with examples, things like database paths (absolute and relative)
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    Quote Originally Posted by Trenloe View Post
    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/...ets_-_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.

Thread Information

Users Browsing this Thread

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in