-
July 5th, 2014, 15:23 #1
[Need Help] Trying to create a custom rollable field, like Initiative
Hi, I'm finally breaking down and asking for help. I know I am close to the finish line but just cannot get over this last hurdle for I know I must be missing a small detail but cannot seem to think of it.
I'm modifying a Core-based set. I am trying to create a rollable field for a custom attribute called "Inspiration Check", which totals a character's Wisdom bonus and their character level. Below is the code for the field itself (xml):
From template_char.xml:
Code:<template name="number_inspirationtotal"> <number_linked> <frame name="fieldlight" offset="7,5,7,5" /> <displaysign /> <rollable /> <source><name>abilities.wisdom.bonus</name><op>+</op></source> <source><name>inspiration.level</name><op>+</op></source> <script> function action(draginfo) local nodeWin = window.getDatabaseNode(); if nodeWin then local rActor = ActorManager.getActor("pc", nodeWin.getChild("...")); ActionInspiration.performRoll(draginfo, rActor, nodeWin); end return true; end function onDragStart(button, x, y, draginfo) return action(draginfo); end function onDoubleClick(x,y) return action(); end </script> </number_linked> </template>
Code:function onInit() ActionsManager.registerModHandler("inspiration", modRoll); ActionsManager.registerResultHandler("inspiration", onResolve); end function getRoll(rActor, bSecretRoll) local rRoll = {}; rRoll.sType = "dice"; rRoll.aDice = { "d20" }; rRoll.nMod = 0; rRoll.sDesc = "[Inspiration Check]"; rRoll.bSecret = bSecretRoll; local sAbility = nil; local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor); rRoll.nMod = DB.getValue(nodeActor, "inspiration.total", 0); sAbility = DB.getValue(nodeActor, "abilities.wisdom.bonus", ""); return rRoll; end function performRoll(draginfo, rActor, bSecretRoll) local rRoll = getRoll(rActor, bSecretRoll); ActionsManager.performAction(draginfo, rActor, rRoll); end function modRoll(rSource, rTarget, rRoll) if rSource then local bEffects = false; sActionStat = "wisdom"; -- GET STAT MODIFIERS local nBonusStat, nBonusEffects = ActorManager2.getAbilityEffectsBonus(rSource, sActionStat); if nBonusEffects > 0 then bEffects = true; rRoll.nMod = rRoll.nMod + nBonusStat; end end end function onResolve(rSource, rTarget, rRoll) local rMessage = ActionsManager.createActionMessage(rSource, rRoll); Comm.deliverChatMessage(rMessage); end
A proper nudge in the right direction by someone out there that knows better would be greatly appreciated.
Thank you.Developer for lots of adventures, particularly 5E, Pathfinder, Starfinder, and Pathfinder 2E
Timezone: US Eastern Time
Ultimate License Holder
-
July 5th, 2014, 16:07 #2
The problem is indeed with your sType variable.
ActionsManager.registerModHandler("inspiration", modRoll) and ActionsManager.registerResultHandler("inspiration" , onResolve) are using an Action Type of "inspiration", you dice roll code is using an Action Type of "dice" so modRoll and onResolve will never be called.
Additionally, you need to define "inspiration" as a valid action type in the "actions" table defined in scripts\manager_gamesystem.lua. See post #2 of this thread for details on how to add entries to tables such as these - the example is for DataCommon.conditions, but it equally applies to GameSystem.actions.
If you don't define "inspiration" as a valid action type then the above two handlers won't be called.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!
-
July 5th, 2014, 17:02 #3
Thanks. I knew I was missing some script somewhere to add a value, I just couldn't pinpoint it.
I did add the "inspiration" type in the gamesystem file but it still doesn't work. I actually see that the mod doesn't work even if I put it to "init".
I think it seems to be centered around the nodeActor (possibily being null or empty). If I put a static number for the rRoll.nMod, it works fine, even with the newly created "inspiration" type.
For instance,
rRoll.nMod = DB.getValue(nodeActor, "inspiration.total", 0); <-- no mod is applied
rRoll.nMod = 5; <-- mod is applied
Also, you mentioned "see post #2 of this thread for details...". Your post is #2 (there is no other post in this thread).
For testing reasons in the meantime, I just copied over the entire manager_gamesystem.lua to the extension for now.
Thank you.Developer for lots of adventures, particularly 5E, Pathfinder, Starfinder, and Pathfinder 2E
Timezone: US Eastern Time
Ultimate License Holder
-
July 5th, 2014, 18:09 #4
"init" isn't a recognised action type in the CoreRPG ruleset. These are the valid actions from manager_gamesystem.lua:
Code:-- Ruleset action types actions = { ["dice"] = { bUseModStack = "true" }, ["table"] = { }, ["effect"] = { sIcon = "action_effect", sTargeting = "all" }, };
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!
-
July 5th, 2014, 18:12 #5
Sorry, I forgot to include the link to the thread I was referring to: https://www.fantasygrounds.com/forum...l=1#post168814
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!
-
July 5th, 2014, 18:53 #6
OK, looking at this a bit more - which ruleset are you using? I assume the 3.5E ruleset? I'd originally assumed you were using CoreRPG as you said "Core based" in your OP.
The code for modRoll above will only add ability effects to the roll modifier - nothing else. Your main roll modifier is based off DB.getValue(nodeActor, "inspiration.total", 0).
I suggest you use some Debug.console commands to print variable values to the console - open the console by typing /console in the chat window. Put some Debug.console code at the beginning of each function so you know which functions are being called.
What value is DB.getValue(nodeActor, "inspiration.total", 0) returning? If inspiration.total is not in the character root of the charsheet.id-0000X database entry then this command will return 0. Open your campaign db.xml file and see exactly where inspiration.total is stored for each character.Last edited by Trenloe; July 5th, 2014 at 18:56.
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!
-
July 5th, 2014, 18:53 #7
Sorry, I guess I wasn't completely thorough in the explanation. I am working on a ruleset extension that is based off of 3.5E, which is based off the Core ruleset. In 3.5E, "init" is a recognized action type.
It seems that no matter what type I use, the nMod doesn't work when getting the value through nodeActor. It works fine if I put a static number on it. I'm sure I will figure it out - I know it is likely a small issue.
Thanks.Developer for lots of adventures, particularly 5E, Pathfinder, Starfinder, and Pathfinder 2E
Timezone: US Eastern Time
Ultimate License Holder
-
July 5th, 2014, 18:54 #8
-
July 5th, 2014, 19:05 #9
I solved the issue. When I copied the action(draginfo) script for the char_template code, I copied one type. That must have been specific for the functionality I copied if from.
I changed it it:
Code:function action(draginfo) local rActor = ActorManager.getActor("pc", window.getDatabaseNode()); ActionInspiration.performRoll(draginfo, rActor, nodeWin); return true; end
Part of learning how to develop in a new system is practice and troubleshooting.
Trenloe, thank you for:
- Attempting to help me
- Providing information on how to add values to the tables
- Giving me a mechanism to talk the process out. Talking it out with someone else does cause revelations for problem situations. This is exactly why eXtreme Programming is so effective (not that I have ever seen it in practice much).
Developer for lots of adventures, particularly 5E, Pathfinder, Starfinder, and Pathfinder 2E
Timezone: US Eastern Time
Ultimate License Holder
-
July 5th, 2014, 19:21 #10
Glad you got it sorted in the end.
I frequently find that checking the exact database location of a DB node variable is a good idea - as very often you aren't actually at the db node you thought you were at! Use databasenode.getNodeName() to return the full database location (dot separated) of the db node: https://www.fantasygrounds.com/refdo...cp#getNodeName
For the above code, use: Debug.console("nodeActor nodename = " .. nodeActor.getNodeName()); Using this immediately before the rRoll.nMod = DB.getValue(nodeActor, "inspiration.total", 0); line would have indicated that the nodeActor database node object was looking at the wrong part of the campaign database.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!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks