PDA

View Full Version : One last problem on the Wild-Die...



Oberoten
March 5th, 2008, 11:20
I have one last problem with my wild-Die for Ars Magica... While it shows the rolls under the Wild perfectly... it doesn't sum them up properly.

IE, I roll a wild-die (any D10 on the window unless the toggle is down) and it re-rolls and doubles on ones...
... but the final little die-result bubble only shows the first roll. I try to pass the result back into the array but... no dice so to say. Any suggestion on what I am doing wrong?





function onDiceLanded(draginfo)
if ChatManager.getDieRevealFlag() then
draginfo.revealDice(true);
end
if draginfo.isType("fullattack") then
for i = 1, draginfo.getSlotCount() do
draginfo.setSlot(i);
if not ModifierStack.isEmpty() then
local originalnumber = draginfo.getNumberData();
local numstr = originalnumber;
if originalnumber > 0 then
numstr = "+" .. originalnumber;
end

draginfo.setStringData(draginfo.getStringData() .. " " .. numstr .. " (" .. ModifierStack.getDescription(true) .. ")");
draginfo.setNumberData(draginfo.getNumberData() + ModifierStack.getSum());
end
local entry = {};
entry.text = draginfo.getStringData();
entry.font = "systemfont";
entry.dice = draginfo.getDieList();
entry.diemodifier = draginfo.getNumberData();

if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end

deliverMessage(entry);
end

ModifierStack.reset();
return true;
elseif draginfo.isType("dice") then
dielist = draginfo.getDieList();
for i=1,table.maxn(dielist) do

if dielist[i].type == "d10" and ChatManager.getDieWildFlag()~= True then

local mult=1;
local msg = {font="narratorfont"};
local result=dielist[i].result;

if User.isHost() then
msg.sender = "WildDie";
else
msg.sender = User.getIdentityLabel();
end

msg.icon = "textentry_die";


if result==1 then
msg.icon = "wild_die";
mult=2;
result = math.random(10);
msg.text = " Rolled a one, further roll=" .. result;
ChatManager.deliverMessage(msg);
while result==1 do
mult = mult * 2;
result = math.random(10);
msg.text = " Another one, further roll=" .. result;
ChatManager.deliverMessage(msg);
end

elseif result==10 then
msg.icon = "botch_die";
mult=-1;
result = math.random(10);
msg.text = " Rolled a zero, further roll=" .. result;
ChatManager.deliverMessage(msg)
while result==10 do
mult = mult * 2;
result = math.random(10);
msg.text = " Another zero, further roll=" .. result;
ChatManager.deliverMessage(msg);
end
end

if mult~=1 then
msg.text = " " .. mult .. " times " .. result .. " Gives a Total of " .. (mult * result);
ChatManager.deliverMessage(msg);
end
dielist[i].result = mult * result;
applyModifierStackToRoll(dielist[i]);

end
end
applyModifierStackToRoll(draginfo);
end
end