Starfinder Playlist
  1. #1

    Question R.E. accessing character sheet info

    I'm 'trying' to work on a small extension to automate the rogues Reliable Talent feat.
    I've got most of the mechanics of it sorted, but I'm really struggling to find how to actually find if the players character has the feat on their character sheet in the 1st place.

    Can anyone give me a shove in the right direction or a short code snippet of how to do this?

    Thanks, Steve.

  2. #2
    There's an example of something similar in CharManager script in the 5E ruleset (campaign/scripts/manager_char.lua).

    Code:
    if hasFeature(nodeChar, FEATURE_UNARMORED_DEFENSE) then
        ....
    end
    So, you could probably re-use that function, but you need to make sure you have the character's database node.

    Code:
    if hasFeature(nodeChar, "reliable talent") then
        ....
    end
    Regards,
    JPG

  3. #3
    I'll give it a shot, thanks for the reply

  4. #4
    Actually, the example running from your own script would be below, since you need to call a function in another script. Just noticed I forgot that.

    Code:
    if CharManager.hasFeature(nodeChar, "reliable talent") then
        ....
    end
    Cheers,
    JPG

  5. #5
    OK, I'm about to show my total ignorance of how the underlying Lua/Db referencing works in Fantasy Grounds by explaining how I'm *thinking* I should be doing this.

    In the onRoll function of manager_action_skill.lua, before the Comm.deliverChatMessage(rMessage) is actioned, I would like to check if the d20 die roll is <10, if so, change it to 10 then action the chatmessage.
    BUT.....I 1st need to check if the character that rolled the dice has the reliable talent function. I am still puzzled how to do this, as I can't get any coding to get the characters node from the Db to work from within the onRoll function.
    I'm sure I must be coming at this entirely the wrong way.

    Thanks in advance for any more pointers you can give me

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by Stv View Post
    ... I can't get any coding to get the characters node from the Db to work from within the onRoll function.
    Most actions have record variables (actually LUA tables) that contain various pieces of information for an "actor" - where an actor is usually the source or the target of the action.

    There is a very useful global script called ActorManager that has various helper functions to get info out of an actor record. This is in CoreRPG scripts\manager_actor.lua - functions to look at are getCTNode (if you want to operate against data in the combat tracker), getCreatureNode, etc. which can return the database node of the actor record. Depending on exactly what you want to do you may be better using getCTNodeName or getCreatureNodeName and then use individual DB.getValue commands using the node name (stored in a string variable). This is much more efficient, as a creature node will contain the whole node substructure and can take up a lot of resources (especially a PC node).

    So, you could do something like this:
    Code:
    local sPCNodeName = ActorManager.getCreatureNodeName(rSource);
    local nodeFeatureList = DB.getChild(sPCNodeName, "featurelist");
    
    if nodeFeatureList then
    	for k, nodeFeature in pairs (nodeFeatureList.getChildren()) do
    		if DB.getValue(nodeFeature, "name", ""):lower() == "reliable talent" then
    			-- Do your code for reliable talent here.
    			break;
    		end
    	end
    end
    Note: I haven't tested this code, so it may not be 100% correct. And, you didn't mention the ruleset you're using, I've assumed 5E which uses "featurelist" to store the feature data in the charsheet database.
    Last edited by Trenloe; January 5th, 2020 at 21:00.
    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!

  7. #7
    My bad, meant to include I was using 5e in my previous post.
    Thank you for replying, something else for me to look at.

    Cheers, Steve.

  8. #8
    Trenloe, you Sir are a legend
    But I have one more question...as I'm inserting my new code into the end of the manager_action_skill.lua file, I must copy the whole of that file to my new one and put the changes in there, as it's not a global script so I can't override the functions in there separately ?

    Thanks again, Steve.

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by Stv View Post
    Trenloe, you Sir are a legend
    I have my good days!

    Quote Originally Posted by Stv View Post
    But I have one more question...as I'm inserting my new code into the end of the manager_action_skill.lua file, I must copy the whole of that file to my new one and put the changes in there, as it's not a global script so I can't override the functions in there separately ?
    manager_action_skill.lua is a global script - with a name of ActionSkill. So you can override it. Use ActionSkill.onRoll = {my new function} where {my new function} is your version of onRoll.
    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!

  10. #10
    Once again, I thank you

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
  •  
DICE PACKS BUNDLE

Log in

Log in