Thread: Add Effects function
-
August 14th, 2020, 16:10 #1
- Join Date
- Jan 2020
- Posts
- 90
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?
-
August 14th, 2020, 17:48 #2
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!
-
August 14th, 2020, 17:54 #3
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!
-
August 14th, 2020, 18:40 #4
- Join Date
- Jan 2020
- Posts
- 90
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?
-
August 15th, 2020, 03:24 #5
- Join Date
- Jan 2020
- Posts
- 90
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?
-
August 15th, 2020, 06:56 #6
Good deduction,
instead of using
Code:TraitManager.getTraitNode("pc", nodeActor, "athletics")
Code:SkillManager.getSkillNode(nodeActor, "athletics")
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!
-
August 15th, 2020, 13:27 #7
- Join Date
- Jan 2020
- Posts
- 90
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.
-
August 15th, 2020, 14:07 #8
- Join Date
- Jan 2020
- Posts
- 90
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.
-
August 15th, 2020, 14:22 #9
- Join Date
- Jan 2020
- Posts
- 90
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.
-
August 15th, 2020, 14:26 #10
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)
"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