DICE PACKS BUNDLE
Page 1 of 2 12 Last
  1. #1

    Add Effects function

    I'm working on an ext to enable a house rule to roll Athletics with the Run roll and take the higher die. It's working except for when there are Effects modifying Athletics (Boost, for instance). It continues to use the base value.

    I'm getting the athletics value with:
    local oSkillAthletics = SkillManager.getSkill(nodeActor, "athletics")
    local aSkillAthletics = oSkillAthletics.getDice()

    Now, clearly, I need to apply the effects, and I think I understand how that's done (maybe) well enough to parse all the effects and doing some pattern matching, but is there already a defined function somewhere that would return the final value after all the "Athletics|Trait +1d" have been applied?

  2. #2
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,384
    If you need to have adjusted Trait dice:

    Code:
    local nodeTrait = SkillManager.getSkillNode(nodeActor, "athletics")
    local _,aTraitDice = TraitManager.getTraitDice("pc", nodeActor, nodeTrait, nil, { bApplyEffects = true })
    Last edited by Ikael; August 15th, 2020 at 14:24.
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  3. #3
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,384
    If you want to make the actual trait roll but (forcefully) skip Wild Die and add "Running" prefix to roll description

    Code:
    TraitManager.makeSkillRoll("pc", nodeActor, "athletics", { 
        sDescPrefix = "Running",
        bWildCard = false
    })
    Last edited by Ikael; August 14th, 2020 at 17:58.
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  4. #4
    For some reason TraitManager.getTraitDice is returning nil. It errors when I try to feed aTraitDice to a function expecting a table. What could cause that?

  5. #5
    I'm having trouble figuring out what TraitManager.getTraitNode("pc", nodeActor, "athletics") does.

    "pc" is just text, "athletics" is just text, nodeActor is the character node. And I know nodeActor should be correct, because it works when I use the exact same variable for the SkillManager.getSkill(nodeActor, "athletics") function call. So, my first question is, is the character node expected by those 2 function calls different? If so, how?

    But assuming they are the same, then I should have correct parameters when making the call.

    getTraitNode starts by doing this

    local _,nodeChar = CharacterManager.asCharActor(sActorType, nodeActor) - transfer in the parameters asCharActor("pc", nodeActor)

    So, jump to asCharActor

    local sActorType, nodeActor = decodeActor(vActor, vSource) - transfer in the parameters decodeActor("pc", nodeActor)

    decodeActor only checks if "pc" is a table. Since it isn't, it returns the 2 variable. Effectively, that parameter call does nothing.

    So, we just go back to asCharActor. It checks if "pc" is a string - check and nodeActor exists - unless we lost it along the way, it should still be here. Next it checks if "pc" == "cv". It isn't so we fall out of this function just assigning variables back to themselves.

    So, in the end, that rabbit hole did nothing. Two variables got reassigned to themselves twice.

    Going back to getTraitNode, local _,nodeChar = CharacterManager.asCharActor(sActorType, nodeActor) does nothing but assign nodeChar = nodeActor.

    So, now conditionals does nodeActor exist? Yup. Is "athletics" a string? Yup.
    So, that means - return nodeChar.getChild(vSource)

    So, we end up using a method of the node, but this is returning nul

    So, I tried skipping all the function calls and going back to the original call substituting in that final return, effectively

    local nodeTrait = TraitManager.getTraitNode("pc", nodeActor, "athletics")

    becomes

    local nodeTrait = nodeActor.getChild("athletics")

    So, I tried putting that directly in place of the original function call and it also returns nul. So, I must conclude that nodeActor is faulty in some way; everything else is just string comparisons - except it works fine for getSkill. After all of this the only thing I have convinced myself of is that there are at least 2 different structures for nodeActor. Does anyone know where these are created?

  6. #6
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,384
    Good deduction,

    instead of using

    Code:
    TraitManager.getTraitNode("pc", nodeActor, "athletics")
    you should use
    Code:
    SkillManager.getSkillNode(nodeActor, "athletics")
    to get the database node athletics skill.

    I have updated to example.
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

  7. #7
    So, that does return a value now, at least for non-Wildcards. But it just returns the base die, not adjusted for any effects. And for Wildcards, it causes an error.

    Script Error: [string "scripts/manager_trait.lua"]:456: attempt to index local 'rUserData' (a nil value)


    The error happens when calling the second line:

    local nodeTrait = SkillManager.getSkillNode(nodeActor, "athletics")
    local _,aTraitDice = TraitManager.getTraitDice("pc", nodeActor, nodeTrait) <--error

    I'm digging into that now. It looks like the function is expecting more parameters. But even when it doesn't error on non-wildcards, it still isn't giving the the value I want, so this might be a path that doesn't accomplish anything.

  8. #8
    OK, I got it working without error by changing the line to this:

    local _,aTraitDice = TraitManager.getTraitDice("pc", nodeActor, nodeTrait, nil, {})

    rUserData was just being used to hold a variable temporarily before it was assigned somewhere else, so this dummy ({}) serves the same function. But, it doesn't solve the original problem and is still showing only the base skill value.

  9. #9
    And another edit - it does apply a boost if you right click and add one with the boost option, but it doesn't apply effects in the combat tracker added by [Athletics +1d]. I guess those work differently.

  10. #10
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,384
    Quote Originally Posted by ApesAmongUs View Post
    OK, I got it working without error by changing the line to this:

    local _,aTraitDice = TraitManager.getTraitDice("pc", nodeActor, nodeTrait, nil, {})

    rUserData was just being used to hold a variable temporarily before it was assigned somewhere else, so this dummy ({}) serves the same function. But, it doesn't solve the original problem and is still showing only the base skill value.
    I updated the above example one more time. You have explicitely tell the function to apply effects by passing bApplyEffects = true

    Alternative is to use

    Code:
    local rActor = CharacterManager.getActorShortcut("pc", nodeActor)
    local nodeTrait = SkillManager.getSkillNode(rActor, "athletics")
    local rTrait = TraitManager.getTraitRoll(rActor, nodeTrait)
    to get more information about the trait such as description, modifiers, dice etc.
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

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
  •  
FG Spreadshirt Swag

Log in

Log in