-
February 25th, 2015, 09:45 #11
Please do share your code!
-
February 25th, 2015, 09:54 #12
- Join Date
- Aug 2012
- Posts
- 40
It's not completed (with no guarantee it can be completed) and I'm not Lua expert by any stretch of imagination but following shows my way of thinking:
Helper functions:
Code:function serializeTable(val) local tmp = "" for k, v in pairs(val) do tmp = tmp .. v.result .. "," .. v.type .. ";" end return tmp end function deserializeTable(val) local result = {} for k,i in string.gmatch(val, "(%w+),(%w+)") do local vvv = {} vvv.result = k vvv.type = i table.insert(result, vvv) end return result end function getReRoll(aDice, iRoll) local rRoll = {} rRoll.aDice = aDice rRoll.nMod = iRoll.nMod rRoll.sType = iRoll.sType rRoll.bSecret = iRoll.bSecret rRoll.nStrain = iRoll.nStrain rRoll.sDesc = iRoll.sDesc rRoll.rPreviousResult = serializeTable(iRoll.aDice) return rRoll end
Code:function onResult(rSource, rTarget, rRoll) local isMaxResult = function(rDie) if tonumber(rDie.type:match("^d(%d+)")) == rDie.result then return rDie.result else return 0 end end explode = {} for i,die in ipairs(rRoll.aDice) do local reroll = isMaxResult(die) if reroll>0 then table.insert(explode, die.type) end end if rRoll.rPreviousResult then prev = deserializeTable(rRoll.rPreviousResult) for i,roll in ipairs(prev) do table.insert(rRoll.aDice, 1, roll) end end if table.getn(explode) > 0 then ActionsManager.performAction(draginfo, rActor, getReRoll(explode, rRoll)); return false; end; local rMessage = ActionsManager.createActionMessage(rSource, rRoll); local nTotal = ActionsManager.total(rRoll); Comm.deliverChatMessage(rMessage); end
What is not done is handling of draginfo (I'm not sure - is it lost?) and rActor. I simply had no time to analyze this so it might be a case that it cannot be done. :/ Fantasy Grounds surprised me like that more than once.
-
February 28th, 2015, 19:59 #13
One last question, where and how would I add in a target value for a roll?
-
February 28th, 2015, 20:12 #14Private 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