-
July 25th, 2019, 22:15 #1
[requesting help]Custom Die Results from character sheet roll
hey guys, so i'm slowly figuring things out, but still feel like i'm miles from my goal.
trying to make a character sheet for the Alien RPG, and i've taken some stuff from the Shadowrun 4e ruleset i found on here in order to make my main character sheet. right now, i'm just trying to make it so that the attributes determine the number of dB (base dice) to roll. i feel like i'm close, but the results are not showing due to the script, and i'm having trouble figuring out what to modify. I don't need the extra roll result stuff from the ActionManager2 file referenced from the ActionAttribute file. I just need the dB to roll from the character sheet and display the results that are already programmed into the custom dice.
This is the code for the custom dice. this all works fine when rolled normally from the custom dice menu when rightclicking the d6 or an assigned quickslot
Code:-- wedge for handling custom dice results function onInit() --Debug.console("dS onInit called"); ActionManagerOverrides.registerCustomDiceResultWedge("dS", dSCustomResult); end function dSCustomResult(diceTable) --Debug.console("dSCustomResult called"); local desc = ""; local sEffects = 0; local bEffects = 0; for k,v in ipairs(diceTable) do if v.type == "dS.1" then sEffects = sEffects + 1; diceTable[k].result = 0; end if v.type == "dS.6" then bEffects = bEffects + 1; diceTable[k].result = 0; end if v.type == "dB.6" then bEffects = bEffects + 1; diceTable[k].result = 0; end end if sEffects > 0 and bEffects > 0 then desc = "[Fails: " .. sEffects .. "][Successes: " .. bEffects .. "]"; else if sEffects > 0 and bEffects <= 0 then desc = "[Fails: " .. sEffects .. "]"; else if sEffects <= 0 and bEffects > 0 then desc = "[Successes: " .. bEffects .. "]"; end end end return desc; end
-
July 25th, 2019, 22:17 #2
continued
This is the manager_actions2.lua that is being referenced by the manager_action_attribute file
Code:function getRollType(sDragType, nSlot) for k, v in pairs(aMultiHandlers) do if k == sDragType then return v(nSlot); end end return sDragType; end -- -- INITIATE ACTION -- function performReroll(rSource, rRoll) rRoll.aDice = {}; rRoll.sDesc = rRoll.sRerollDesc; for i = 1, rRoll.nRerollCount do table.insert (rRoll.aDice, "dB"); end performSingleRollAction(nil, rSource, "reroll", rRoll) end function performOpposedRoll(rSource, rRoll) rRoll.aDice = {}; rRoll.sDesc = "" rRoll.sDesc = "[OPPOSED] Check" rRoll = ActionSkill.getSpiritOpposedRoll(rSource, rRoll); rRoll.nValue = 0; performSingleRollAction(nil,rSource,"spiritisopposed", rRoll) end -- -- DETERMINE TARGETS -- function handleActionDrop(draginfo, rTarget) if rTarget then local sDragType = draginfo.getType(); local rSource, rRolls = decodeActionFromDrag(draginfo); lockModifiers(); for k,v in ipairs(rRolls) do local sType = getRollType(sDragType, k); applyModifiersAndRoll(rSource, rTarget, sType, v.sDesc, v.aDice, v.nValue, false); end unlockAndResetModifiers(); else handleDragDrop(draginfo, true); end end function handleActionNonDrag(rActor, sDragType, rRolls, rTarget) local bSingleRoll = false; local aTargets = {}; if rTarget then table.insert(aTargets, rTarget); else for k, v in pairs(aTargetingHandlers) do if k == sDragType then aTargets, bSingleRoll = v(rActor, rRolls); break; end end end lockModifiers(); local nRerollSuccesses = 0; local nTotalDice = 0; if #aTargets == 0 or bSingleRoll then for k, v in ipairs(rRolls) do local sType = getRollType(sDragType, k); nRerollSuccesses = v.nRerollSuccesses; nTotalDice = v.nTotalDice; applyModifiersAndRoll(rActor, aTargets, sType, v.sDesc, v.aDice, v.nValue, true, nRerollSuccesses, nTotalDice); end else for i = 1, #aTargets do for k, v in ipairs(rRolls) do local sType = getRollType(sDragType, k); applyModifiersAndRoll(rActor, aTargets[i], sType, v.sDesc, v.aDice, v.nValue, false, nRerollSuccesses, nTotalDice); end end end unlockAndResetModifiers(); end function performSingleRollAction(draginfo, rActor, sType, rRoll, bOverride, rTarget) if not rRoll then return; end local rRolls = {}; table.insert(rRolls, rRoll); ActionsManager.performMultiAction(draginfo, rActor, sType, rRolls); end function createRollTable(rSource, rRoll) local nSuccesses = 0; local nFailures = 0; local nGlitchDice = 0; local bNoPrint = false; local bEdge = false; local nRerollCount = 0 local nTotalDice = 0 local rMessage = ChatManager.createBaseMessage(rSource); local bNonD6 = false local nSuccessesCalling = 0 local isEdge = string.match(rRoll.sDesc, "%[EDGE]"); if isEdge then bEdge = true; end if rSource and rSource.sType == "pc" then local rCheckbox = DB.findNode(rSource.sCreatureNode).getChild("edgecheckbox") if rCheckbox then b = rCheckbox.getValue(); if b == 1 then bEdge = true; end end end if bEdge == true and rSource then local nEdgeUsed = 0 nEdgeUsed = DB.findNode(rSource.sCreatureNode).getChild("base.attribute.edge.mod").getValue(); if DB.findNode(rSource.sCreatureNode).getChild("edgecheckbox").getValue() == 1 then nEdgeUsed = (nEdgeUsed + 1) DB.findNode(rSource.sCreatureNode).getChild("base.attribute.edge.mod").setValue(nEdgeUsed); DB.findNode(rSource.sCreatureNode).getChild("edgecheckbox").setValue(0); end end -- Individual Dice Handling, Trooping the Color if rRoll.nTotalDice then nTotalDice = rRoll.nTotalDice end if rRoll.nRerollSuccesses and rRoll.nRerollSuccesses > 0 then nSuccesses = rRoll.nRerollSuccesses end for i , v in ipairs (rRoll.aDice) do if rRoll.aDice[i].type ~= "dB" or rRoll.aDice[i].type ~= "dB" or rRoll.aDice[i].type ~= "dB" or rRoll.aDice[i].type ~= "dB" then bNonD6 = true elseif rRoll.aDice[i].type == "dB" then nTotalDice = nTotalDice + 1 if rRoll.aDice[i].result == 6 then nSuccesses = nSuccesses + 1; nSuccessesCalling = nSuccessesCalling + 1; rRoll.aDice[i].type = "ddg6"; if bEdge == true or rRoll.sType == "reroll" then bNoPrint = true; nRerollCount = nRerollCount + 1; end elseif rRoll.aDice[i].result == 1 then nFailures = nFailures + 1; rRoll.aDice[i].type = "dr6"; end end end if nRerollCount == 0 then bNoPrint = false end if bNoPrint == true then if rRoll.nRerollsuccesses then rRoll.nRerollSuccesses = rRoll.nRerollSuccesses + nSuccesses; else rRoll.nRerollSuccesses = nSuccesses end if rRoll.nTotalDice then rRoll.nTotalDice = nTotalDice end local isDiceTower = string.match(rRoll.sDesc, "^%[TOWER%]"); local isGMOnly = string.match(rRoll.sDesc, "^%[GM%]"); if isDiceTower then rMessage.dicesecret = true; rMessage.sender = ""; rMessage.icon = "dicetower_icon"; elseif isGMOnly then rMessage.dicesecret = true; rMessage.text = "[GM] " .. rMessage.text; elseif User.isHost() and OptionsManager.isOption("REVL", "off") then rMessage.dicesecret = true; rMessage.text = "[GM] " .. rMessage.text; end if rRoll.sType ~= "reroll" then -- save original roll type rRoll.sOriginalType = rRoll.sType; end rRoll.sRerollDesc = rRoll.sDesc; rRoll.sDesc = "Reroll comenced"; rRoll.nRerollCount = nRerollCount; rMessage.text = rRoll.sDesc; rMessage.dice = rRoll.aDice; rRoll.sType = "reroll"; return rMessage, rSource, rRoll; else rRoll.sDesc = rRoll.sDesc .. "Total Dice Pool: " .. nTotalDice .. " " .. "\rSUCCESSES: " .. nSuccesses .. "FAILURES: " .. nFailures; rRoll.nSuccessesCalling = nSuccessesCalling; rRoll.nSuccesses = nSuccesses; end local isSpiritOpposedCheck = string.match(rRoll.sDesc, "%[SPIRIT%]") if isSpiritOpposedCheck then local isDiceTower = string.match(rRoll.sDesc, "^%[TOWER%]"); local isGMOnly = string.match(rRoll.sDesc, "^%[GM%]"); if isDiceTower then rMessage.dicesecret = true; rMessage.sender = ""; rMessage.icon = "dicetower_icon"; elseif isGMOnly then rMessage.dicesecret = true; rMessage.text = "[GM] " .. rMessage.text; elseif User.isHost() and OptionsManager.isOption("REVL", "off") then rMessage.dicesecret = true; rMessage.text = "[GM] " .. rMessage.text; end rRoll.sRerollDesc = rRoll.sDesc; rMessage.text = rRoll.sDesc; rMessage.dice = rRoll.aDice; rRoll.sType = "spiritopposed" rRoll.nRerollCount = nRerollCount; rRoll.nSuccessesPC = nSuccesses return rMessage, rSource, rRoll; end rRoll.nRerollCount = nRerollCount; return rMessage, rSource, rRoll; end function createActionMessage(rSource, rTarget, rRoll) local isDiceTower = rRoll.bTower; --string.match(rRoll.sDesc, "^%[TOWER%]"); local isGMOnly = rRoll.bSecret; --string.match(rRoll.sDesc, "^%[GM%]"); local isInit = string.match (rRoll.sDesc, "%[INIT]"); if isInit then local nInit = 0 local sCTRolled = DB.getValue(ActorManager.getCTNode(rSource), "ctinitrolled", "2"); if sCTRolled == 0 then nInit = rRoll.nSuccessesCalling if rRoll.nRerollSuccesses ~= nil then if rRoll.nRerollSuccesses > 0 then nInit = nInit + rRoll.nRerollSuccesses end end -- NodeManager.set(rSource.nodeCT, "initroll", "number", nInit) -- NodeManager.set(rSource.nodeCT, "ctinitrolled", "number", 1) -- DB.setValue(ActorManager.getCTNode(rSource), "initroll", "number", nInit); -- DB.setValue(ActorManager.getCTNode(rSource), "ctinitrolled", "number", 1); ActionInit.notifyApplyInit(rSource, nInit) else rRoll.sDesc = "Sorry, Initiative already rolled for this Round"; rRoll.aDice = {}; end -- end end -- Handle GM flag and TOWER flag if isDiceTower then rSource = nil; elseif isGMOnly then rRoll.sDesc = string.sub(rRoll.sDesc, 6); end -- Build the basic message to deliver local rMessage = ChatManager.createBaseMessage(rSource, rRoll.sUser); rMessage.text = rRoll.sDesc; if rTarget ~= nil then rMessage.text = rMessage.text .. "\nTargeting " .. rTarget.sName; end rMessage.dice = rRoll.aDice; rMessage.diemodifier = rRoll.nValue; -- Check to see if this roll should be secret (GM or dice tower tag) if isDiceTower then rMessage.dicesecret = true; rMessage.sender = ""; rMessage.icon = "dicetower_icon"; elseif isGMOnly then rMessage.dicesecret = true; rMessage.text = "[GM] " .. rMessage.text; elseif User.isHost() and OptionsManager.isOption("REVL", "off") then rMessage.dicesecret = true; rMessage.text = "[GM] " .. rMessage.text; end -- Show total if option enabled if OptionsManager.isOption("TOTL", "on") and rRoll.aDice and #(rRoll.aDice) > 0 then rMessage.dicedisplay = 1; end return rMessage, rSource, rRoll; end function total(rRoll) local nTotal = 0; for k, v in ipairs(rRoll.aDice) do nTotal = nTotal + v.result; end nTotal = nTotal + rRoll.nValue; return nTotal; end
-
July 25th, 2019, 22:18 #3
continued 2
and this is the manager_action_attribute.lua which allows the player or myself to drag dice from the main character sheet i believe, and calls to the manager_actions2.lua
Code:-- -- Please see the license.html file included with this distribution for -- attribution and copyright information. -- function onInit() ActionsManager.registerModHandler("attribute", modRoll); ActionsManager.registerResultHandler("attribute", onAttribute); end function performRoll(draginfo, rActor, sAttributeStat) local rRoll = {}; local nValue = 0; local aDice = {}; rRoll.sDesc = rActor.sName .. " -> " rRoll.sDesc , nValue = ActorManager2.getAttributeBonus(rActor, sAttributeStat, rRoll.sDesc); rRoll.sDesc , nValue = ActorManager2.getPenalty(rActor, nValue, rRoll.sDesc); rRoll.sDesc , nValue = ActorManager2.getSustainingPenalty(rActor, nValue, rRoll.sDesc); rRoll.sDesc , nValue = ActorManager2.getArmorPenalty(rActor, nValue, rRoll.sDesc, sAttributeStat); rRoll.sDesc, nValue = ActorManager2.getModifiers(rRoll.sDesc, nValue); rRoll.sDesc, rRoll.bEdge , rRoll.nEdgeVal = ActorManager2.getEdge(rActor, rRoll.sDesc); nValue = nValue + rRoll.nEdgeVal -- SETUP for i = 1, nValue do table.insert (aDice, "dB"); end rRoll.aDice = aDice; rRoll.nValue = 0; rRoll.nMod = 0; rRoll.sType = "attribute"; ActionsManager2.performSingleRollAction(draginfo, rActor, "attribute", rRoll); end function onAttribute(rSource, rTarget, rRoll) -- Apply target specific modifiers before roll if rTarget and rTarget.nOrder then ActionsManager.applyModifiers(rSource, rTarget, rRoll); end local rMessage, rSource, rRoll = ActionsManager2.createRollTable(rSource, rRoll); rMessage, rSource, rRoll = ActionsManager2.createActionMessage(rSource, rTarget, rRoll); Comm.deliverChatMessage(rMessage); if rRoll.sType == "reroll" and rRoll.nRerollCount then ActionsManager2.performReroll(rSource, rRoll); end if rRoll.sType == "spiritopposed" then ActionsManager2.performOppossedRoll(rSource, rRoll) end end function total(rRoll) local nTotal = 0; for k, v in ipairs(rRoll.aDice) do nTotal = nTotal + v.result; end nTotal = nTotal + rRoll.nValue; return nTotal; end
-
July 25th, 2019, 22:32 #4
ActionsManager2.performSingleRollAction is just calling a stub handler - ActionsManager2 gives the ability to customize the handler, but in this case it just passes the data on, so it's not the issue.
In your performRoll function in post #3, you add dice to the aDice table of type "dB". But in the ActionManagerOverrides.registerCustomDiceResultWed ge you define them as "dS".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 25th, 2019, 23:09 #5
well there are two types of dice, dB (base) and dS (stress). i had them both refer to the same file to determine the number of successes and failures, so as to eliminate repeat or nil returns to the chat. so if i used a dice pool, and rolled both types, i wouldn't see multiple "[Successes:#]" and/or "[Failures:0]".
so i want it to roll base dice, for now, based on the attribute score, and just let the dice call the successes and failures, but even changing the aDice type returns no results whatsoever in the chat. so something in the description conflicting? or perhaps in the messenger portion of the results?
-
July 25th, 2019, 23:17 #6
here is an extension for the dice, i've merely merged them into a ruleset i've been modifying.
-
July 25th, 2019, 23:39 #7
A bit more info about what is actually happening.
Do the dice roll, but you don't see a result?
What else can you tell us? How are you calling performRoll? How far does your debug code go in the dice roll process - which functions does it call, what data is available at each function? I'd recommend putting debug code in each step and check the main parameters (rRoll, rActor, etc.) and look at what the data contains and try to see where it might be falling over.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 25th, 2019, 23:42 #8
Hhhm, I've just noticed that in performRoll you build the aDice table and then assign that to rRoll.aDice. You may find that this doesn't work as you'd expect. You're best building up rRoll.aDice and add the dice directly from there.
Put debug code in as I mentioned above and see what rRoll contains at the end of performRoll.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 26th, 2019, 00:08 #9
ok, so since the roll system in actionmanager2 is bunk (i literally have pulled the code from another ruleset and have been trying to modify and eliminate code as need be, and probably have a lot of useless code in there) perhaps we can change the script in the attributecheckbonus in the template_charsheet.xml file. i notice it references that, so perhaps we can reference something like the functions in the CoreRPG manager_actions.lua?
Code:<template name="attributecheckbonus"> <linkednumber> <noreset /> <anchored> <position>right</position> <offset>50,0</offset> <size> <width>32</width> </size> </anchored> <frame> <name>modifier</name> <offset>2,4,2,4</offset> </frame> <readonly /> <font>sheetnumber</font> <hideonvalue value="0" /> <rollable /> <script> function onSourceUpdate() setValue(sources[attributebonusfield[1]].getValue() + sources[attributescore[1]].getValue()); end function onInit() addSource(attributebonusfield[1]); addSource(attributescore[1]); super.onInit(); end function action(draginfo) local rActor = ActorManager2.getActor("pc", window.getDatabaseNode()); ActionAttribute.performRoll(draginfo, rActor, self.target[1]); return true; end function onDragStart(button, x, y, draginfo) return action(draginfo); end function onDoubleClick(x,y) return action(); end function onDrop(x,y,draginfo) if draginfo.isType("skill") then local a = getDatabaseNode().getParent().getName(); local b = draginfo.getCustomData(); DB.findNode(b).getChild("skillattribute").setValue(a); end return true; end </script> </linkednumber> </template>
-
July 26th, 2019, 00:15 #10
Like I said - step through the various functions/event that happen as part of the roll - put Debug commands in for the key LUA variables/tables, and see where it might be falling down.
Also check what I said about assigning the dice to rRoll.aDice - put some debug in at the end of performRoll and see what rRoll actually contains.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