PDA

View Full Version : Dice: Controlling Icon and 3d Model



ragamer
March 3rd, 2010, 14:55
This is my 1st post on this community, so I hope this is the correct category.

I'm on the component creation phase of an Alternity Ruleset and before going deeper into some crazy lua hacking to achieve what I'm looking for, I wanted to ask if there is an easier way to do the following:

Change the Icon used to represent a die roll in the chatbox

The problem is that Customdie object do not allow for icon changes (I don't have problems on the mechanics and events needed to make the dice do whatever I want numerically... The explanations on this forums and the Earthdawn demo ruleset has been an unvaluable help. This is part of a full conversion of the modification box into an Alternity Difficulty Step box instead.)

I have created 2 versions of the icon.png of each die involved into a step roll (d4,d6,d8,d12,d20) in green (_b_icon.png) and red (_m_icon.png) respectively (On top of the canonical "black icon")

I have tried to define a physical die with XML code like this (This is the example for the d4):



<die name="b4">
<icon>b4icon</icon>
<values list="-1,-2,-3,-4" />
</die>
<die name="m4">
<icon>m4icon</icon>
<values list="1,2,3,4" />
</die>


OFC, I included my custom .png files as icon resources before this as follows:



<icon name="m4icon" file="icons/d4_m_icon.png" />
<icon name="b4icon" file="icons/d4_b_icon.png" />


I manage to summon the colored dice icons properly but the 3d model thrown is a d20 and the numeric result range is 1-20, as if the property <values list="" > is ignored completely.

I can intercept manually the rolls at OnDrop() event and correct this (As the custom labels "m4" and "b4" are created properly. I can trigger this dices with "/dice" properly, for example), but before going mad, I wish to double check if I'm not missing any "trick" to get advantage of the default behaviour of the dice rolling approach.

The final goal I have in mind is that the players see the right ammount of 3d models rolled (I know that I cannot change, still, the physical colors of each individual 3d dice) and on the chat the color of the dice backgrounds would match the meaning of the dice (Black for regular dice, red for malus dice triggered by possitive steps and green for bonus dice triggered by negative steps).

Any tips, please?

Foen
March 3rd, 2010, 17:04
I believe you cannot change the icon for custom dice, and the results are set using script, not a values list. Take a quick look at the documentation here (https://www.fantasygrounds.com/refdoc/customdie.xcp).

Foen

Foen
March 3rd, 2010, 17:06
BTW, the following script is used for Call of Cthulhu to represent negative dice (such as the d4 in 1D6-1D4):


<customdie name="m4">
<model>d4</model>
<menuicon>customdice</menuicon>
<script>
function onValue(result)
return -result;
end
</script>
</customdie>

Foen

Foen
March 3rd, 2010, 17:08
BTW, BTW welcome to the forums! I should have been more polite in my first post ;) and I hope you find us friendly and helpful.

Foen

ragamer
March 3rd, 2010, 17:20
Thanks for the fast reply.

Indeed, customdie object cannot be used to alter the Icon linked to the 3d model used. That's why I was trying to get a basic die instead to perform as I intended. The problem there is that I can get the icons perform as I want but the 3d model (and associated numeric range) "defaults" to d20. I can fix, using Lua, the numeric result... But that's the "dirty" solution I want to avoid unless absolutely necesary.

Regarding the numerical results, indeed the Custom die is the way to go... But that leaves you with the basic die model AND icon linked.

I'm trying to find a way to overcome this strange limitation (To link 2 independent resources that exist in different environments, 3d model and icon, into the same hardcoded object, instead of allowing the basic die to have 2 independent properties, 3d model and Icon and then hardcode the values of the 3d model itself), that's why i'm trying to see which is possible and which not.

The "value list" trick I found after some intensive search on this post (https://www.fantasygrounds.com/forums/showthread.php?t=2970). Looking at the date, it may be possible that this "approach" was changed at some point in the Dev Cycle? I'm new to FG and I don't have the necesary "historic knowledge" of this software to know about deprecated interfaces.

EDIT: On your next 2 posts.


BTW, the following script is used for Call of Cthulhu to represent negative dice (such as the d4 in 1D6-1D4):


I checked already the possibilities of the scripts for the Customdie object (I have experience with Lua) so getting the right numerics is not a concern... Lets just say that when I get involved into projects that have a GUI associated I try to make them as visually informative as possible so I'm trying to add "color changing" rolls and probing for "hidden" or "undocumented ways" to get exactly what I'm looking for with the less coding possible, and if not possible, to get as close as the current limitations allow.

So in this case I'm focusing on getting the right icon while trying to preserve the rest.


BTW, BTW welcome to the forums! I should have been more polite in my first post and I hope you find us friendly and helpful.


Thanks for the warm welcome and certainly this community looks helpful, starting by seeing experts answering this fast to the ramblings of a recently joined member like me with some crazy ideas in the pocket ;).

Foen
March 3rd, 2010, 17:25
That was a post for FG1, which was substantially changed in FG2, the current version.

There are some odd limitations to the FG programming model, for example not all of the actions available in right-click menus are accessible from code.

Cheers

Foen

ragamer
March 3rd, 2010, 17:45
That explains why it doesn't work now :)

So basically, if I understood you correctly, the actual situation is that the 3d model and the icon shown on chat are linked (you can alter the icon, but not having multiple icons associated to the same 3d model).

I will check if I can assemble something similar by researching how to create chat entries in lua to see if I can override the basic roll presentation.

Thanks for the enlightening answers, Foen.

ragamer
March 3rd, 2010, 18:55
K, after researching a bit and getting my hands dirty (Very dirty in fact) with Lua :), I found the setup I wanted.

The trick is creating a custom die with all the required numerical calculations and also creating a basic die with the adequate name with the desired icon. Then you "translate" die rolls on the chat window using the chat event onDiceLanded().

This is the full example with a d4.

First the XML resources:



<icon name="m4icon" file="icons/d4_m_icon.png" />
<icon name="b4icon" file="icons/d4_b_icon.png" />

<die name="ba4">
<icon>b4icon</icon>
</die>

<die name="ma4">
<icon>m4icon</icon>
</die>

<customdie name="b4">
<model>d4</model>
<menuicon>customdice</menuicon>
<script>
function onValue(result)
return(-result);
end
</script>
</customdie>

<customdie name="m4">
<model>d4</model>
<menuicon>customdice</menuicon>
<script>
function onValue(result)
return(result);
end
</script>
</customdie>


And the "translator" into the onDiceLanded():



function onDiceLanded(draginfo)

-- Start of Other actions
-- End of Other actions

if draginfo.isType("dice") then
applyModifierStackToRoll(draginfo);
--We try to trick to change the Dice type after has been rolled but before is been shown on the chat
--We generate a manual message
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
-- We only trigger the "translation" on dices NOT having "d" defined
for i,v in ipairs(entry.dice) do
if string.find(v.type, "d") == nil then
print (v.type);
v.type = string.gsub(v.type,"(%a)","%1a");
print (v.type);
end
end
deliverMessage(entry);
return true;
end
end


Of course the "dirty trick" is creating the name of the basic dice with the additional letter (in this case "a") to be able to perform a simple subsitution (I'm very lazy). But a proper translation table between Custom Dice types and Basic Ones could be created for a more "robust" replace algorithm.

The above setup allows me to show:

- d4 as Black d4 icon.

- m4 as Red d4 icon.

- b4 as Green d4 icon.

While keeping the d4 model rolled on any rolling action that ends in the chatbox.

Ikael
March 3rd, 2010, 19:02
Sadly the dice roll representation in chat is very much fixed. All you can do is change the number displayed within the die and the dice-icon (each 3d model die has one-to-one link to icon representing it). It would be really nice to have ability to modify the dice roll presentation more.

However, one solution might be creating dice icons for all possible results and display that icon in chat messages "icon". This means that you must have icon for all dice rolls (for example in my ruleset, there is self-made icon for representing all 10 results of d10 from 1-10).

Each chat message may have following things: sender ("director"), text content ("Bureucracy and Intelligence..."), mood (none), diemodifier (number 17) and an additional icon ("d10 result 10" and the pin-icon).

This has some limits also, for example you can easily display only one such dice icon result in one chatline, unless you want to do dice icons for representing all possible dice combo results. If you need to represent just one die roll icon per roll then this might be the solution.

ragamer
March 3rd, 2010, 19:07
Check my updated post... I overcame the limit between 3d model and icon with the dirty trick shown above :).

I'm taking a screenshot to explain what I managed... brb

EDIT:

I added the screenshot I think it will explain better than my bad english ;)

https://img706.imageshack.us/img706/4544/d4mod.th.jpg (https://img706.imageshack.us/i/d4mod.jpg/)

Foen
March 3rd, 2010, 19:08
@ragamer

Brilliant! This is a really interesting development with some tantalising possibilities. Great research and excellent results!

Stuart

ragamer
March 3rd, 2010, 19:21
Just the luck of the firstimer :).

I hope it helps ppl trying to highlight "wild die" scenarios and/or exploding dices...

...I just can hope they use a proper translation table and not this fast and dirty trick, I should be ashamed for even posting :).

The same way I edited the "icon" on the entry, I think it would be possible to edit also the numeric value to "compile" chains of dices on a single one (ideal to show "wild die" stacked results).

Foen
March 3rd, 2010, 22:32
I think there will be folks who want to make use of this stuff. I'll start a new thread with a link back here.

Stuart

Oberoten
March 3rd, 2010, 23:05
Hat is of to you sir, that is a really good trick.

- Obe

Kalan
March 4th, 2010, 07:03
I can see this coming into the new Savage Worlds ruleset for the wild die! Brilliant!!!!

cylone
March 6th, 2010, 19:13
Where exactly should those bits of code go? I mean which files are modified?

Stitched
August 6th, 2010, 19:39
Ooooh. Dragon Dice for Dragon Age RPG. Need to have that last d6 "red coloured"!

ttuckel
October 29th, 2011, 14:33
Hi, sorry for the necromancy and for my bad english but I have some questions.

My script is :

function rollDice()
local modif = ModifierStack.getSum();
ModifierStack.reset();
local desc = getValue();
ChatManager.throwDice("dice", {"b12"}, getValue(), "Test d'ART Lumi&#232;re (" .. desc .. ")");
ChatManager.throwDice("dice", {"d12"}, getValue(), "Test d'ART T&#233;n&#232;bres (" .. desc .. ")");; end
function onDoubleClick(x, y)
rollDice();
end

and my onDiceLanded(draginfo) :

function onDiceLanded(draginfo)

if ChatManager.getDieRevealFlag() then
draginfo.revealDice(true);
end

applyModifierStackToRoll(draginfo);


-- ***************************** TEST D100
local entry = {};
entry.dice = draginfo.getDieList();
entry.text = draginfo.getDescription();
entry.font = "systemfont";
entry.diemodifier = draginfo.getNumberData();

-- Pour 1 D100, il faut 2 d&#233;s !! (1d100 et 1d10)
if(entry.dice[2] ~= nil)then
-- Si le 1er d&#233; = D10 et le 2nd = d100 OU 1er d&#233; = D100 et le 2nd = d10
if((entry.dice[1].type == "d10") and (entry.dice[2].type == "d100") or
(entry.dice[1].type == "d100") and (entry.dice[2].type == "d10"))then
-- Calcul r&#233;sultat du jet
local d100Result = entry.dice[1].result + entry.dice[2].result;
-- R&#233;&#233;criture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
end
end

-- Si D&#233; Custom
if(entry.dice[1].type == "d80") then
-- R&#233;&#233;criture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
entry.dice = "";
entry.text = "D&#233; custom";
entry.font = "systemfont";
entry.diemodifier = 0;

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

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)
return true;
end

if draginfo.isType("dice") then
applyModifierStackToRoll(draginfo);
--We try to trick to change the Dice type after has been rolled but before is been shown on the chat
--We generate a manual message
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
-- We only trigger the "translation" on dices NOT having "d" defined
for i,v in ipairs(entry.dice) do
if string.find(v.type, "d") == nil then
print (v.type);
v.type = string.gsub(v.type,"(%a)","%1a");
print (v.type);
end
end
deliverMessage(entry);
return true;
end


-- Pour &#233;viter la triche avec les D10 et les D100
local d10Found = false;
local d100Found = false;
local AutreDe = false;
local ListeDes = "";
--
if entry.dice then
for k,die in pairs(entry.dice) do
if die.type == "d100" then
d100Found = true;
end
if die.type == "d10" then
d10Found = true;
end

if die.type == "d4" then
AutreDe = true;
end
if die.type == "d8" then
AutreDe = true;
end
if die.type == "d12" then
AutreDe = true;
end
if die.type == "d20" then
AutreDe = true;
end


-- Composition de la liste des d&#233;s
--print("dieList: " .. die.type);
end
-- Composition de la liste des d&#233;s
if AutreDe then
ListeDes = "";
elseif d100Found and d10Found and AutreDe == false then
ListeDes = " [Tas de d10 et d100 !!]";
elseif d100Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d100]";
elseif d10Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d10]";
end
end


-- On complete la structure 'Entry" avant le renvoie
if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end

-- On calcul le r&#233;sultat : Jet de d&#233;s + modificateur
local Total = entry.diemodifier;
for k,De in ipairs(entry.dice) do
if De.result then
Total = Total + De.result;
end
end
--
local Text = entry.text .. ListeDes;
entry.text = Text .." [Total: ".. Total.."]";

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)
return true;


end

Without the modification on the onDiceLanded(draginfo) I have this result :
https://tuckel.free.fr/images/FG/screenshot0004.png

and after the modification I obtain that :
https://tuckel.free.fr/images/FG/screenshot0003.png

How can I have, at the same time, the test decription (with the total), and the black and white dices ?

Thank you in advance !

StuartW
October 30th, 2011, 10:31
I think you have probably over-written some newer code with your modification. FG is frequently updated and the original post on this thread is quite old, so using the code from an old thread in a recent ruleset means you may have accidentally undone some more recent changes.

Can you post an unmodified copy of the onDiceLanded code?

Stuart

ttuckel
October 30th, 2011, 15:02
Thank you !

Here is the unmodified onDiceLanded code :


function onDiceLanded(draginfo)

if ChatManager.getDieRevealFlag() then
draginfo.revealDice(true);
end

applyModifierStackToRoll(draginfo);


-- ***************************** TEST D100
local entry = {};
entry.dice = draginfo.getDieList();
entry.text = draginfo.getDescription();
entry.font = "systemfont";
entry.diemodifier = draginfo.getNumberData();

-- Pour 1 D100, il faut 2 dés !! (1d100 et 1d10)
if(entry.dice[2] ~= nil)then
-- Si le 1er dé = D10 et le 2nd = d100 OU 1er dé = D100 et le 2nd = d10
if((entry.dice[1].type == "d10") and (entry.dice[2].type == "d100") or
(entry.dice[1].type == "d100") and (entry.dice[2].type == "d10"))then
-- Calcul résultat du jet
local d100Result = entry.dice[1].result + entry.dice[2].result;
-- Réécriture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
end
end

-- Si Dé Custom
if(entry.dice[1].type == "d80") then
-- Réécriture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
entry.dice = "";
entry.text = "Dé custom";
entry.font = "systemfont";
entry.diemodifier = 0;

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

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)
return true;
end

-- Pour éviter la triche avec les D10 et les D100
local d10Found = false;
local d100Found = false;
local AutreDe = false;
local ListeDes = "";
--
if entry.dice then
for k,die in pairs(entry.dice) do
if die.type == "d100" then
d100Found = true;
end
if die.type == "d10" then
d10Found = true;
end

if die.type == "d4" then
AutreDe = true;
end
if die.type == "d8" then
AutreDe = true;
end
if die.type == "d12" then
AutreDe = true;
end
if die.type == "d20" then
AutreDe = true;
end


-- Composition de la liste des dés
--print("dieList: " .. die.type);
end
-- Composition de la liste des dés
if AutreDe then
ListeDes = "";
elseif d100Found and d10Found and AutreDe == false then
ListeDes = " [Tas de d10 et d100 !!]";
elseif d100Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d100]";
elseif d10Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d10]";
end
end


-- On complete la structure 'Entry" avant le renvoie
if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end

-- On calcul le résultat : Jet de dés + modificateur
local Total = entry.diemodifier;
for k,De in ipairs(entry.dice) do
if De.result then
Total = Total + De.result;
end
end
--
local Text = entry.text .. ListeDes;
entry.text = Text .." [Total: ".. Total.."]";

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)
return true;


end

StuartW
October 30th, 2011, 22:14
I think the problem is that your new code finishes too early, so that the entry.text field is not set properly. The code also over-writes the description of the roll, so you lose it:



function onDiceLanded(draginfo)

if ChatManager.getDieRevealFlag() then
draginfo.revealDice(true);
end

applyModifierStackToRoll(draginfo);


-- ***************************** TEST D100
local entry = {};
entry.dice = draginfo.getDieList();
entry.text = draginfo.getDescription();
entry.font = "systemfont";
entry.diemodifier = draginfo.getNumberData();

-- Pour 1 D100, il faut 2 dés !! (1d100 et 1d10)
if(entry.dice[2] ~= nil)then
-- Si le 1er dé = D10 et le 2nd = d100 OU 1er dé = D100 et le 2nd = d10
if((entry.dice[1].type == "d10") and (entry.dice[2].type == "d100") or
(entry.dice[1].type == "d100") and (entry.dice[2].type == "d10"))then
-- Calcul résultat du jet
local d100Result = entry.dice[1].result + entry.dice[2].result;
-- Réécriture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
end
end

-- Si Dé Custom
if(entry.dice[1].type == "d80") then
-- Réécriture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
entry.dice = "";
entry.text = "Dé custom";
entry.font = "systemfont";
entry.diemodifier = 0;

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

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)
return true;
end

if draginfo.isType("dice") then
applyModifierStackToRoll(draginfo);
--We try to trick to change the Dice type after has been rolled but before is been shown on the chat
--We generate a manual message
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
-- We only trigger the "translation" on dices NOT having "d" defined
for i,v in ipairs(entry.dice) do
if string.find(v.type, "d") == nil then
print (v.type);
v.type = string.gsub(v.type,"(%a)","%1a");
print (v.type);
end
end
deliverMessage(entry);
return true;
end


-- Pour éviter la triche avec les D10 et les D100
local d10Found = false;
local d100Found = false;
local AutreDe = false;
local ListeDes = "";
--
if entry.dice then
for k,die in pairs(entry.dice) do
if die.type == "d100" then
d100Found = true;
end
if die.type == "d10" then
d10Found = true;
end

if die.type == "d4" then
AutreDe = true;
end
if die.type == "d8" then
AutreDe = true;
end
if die.type == "d12" then
AutreDe = true;
end
if die.type == "d20" then
AutreDe = true;
end


-- Composition de la liste des dés
--print("dieList: " .. die.type);
end
-- Composition de la liste des dés
if AutreDe then
ListeDes = "";
elseif d100Found and d10Found and AutreDe == false then
ListeDes = " [Tas de d10 et d100 !!]";
elseif d100Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d100]";
elseif d10Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d10]";
end
end


-- On complete la structure 'Entry" avant le renvoie
if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end

-- On calcul le résultat : Jet de dés + modificateur
local Total = entry.diemodifier;
for k,De in ipairs(entry.dice) do
if De.result then
Total = Total + De.result;
end
end
--
local Text = entry.text .. ListeDes;
entry.text = Text .." [Total: ".. Total.."]";

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)
return true;


end


I have coloured your new code in red, and you can see in bold towards the end that it writes the results to the chat box (deliverMessage) and then exits the function (return true). This stops the rest of the code from executing. The totals are only added to the roll text later (the code in blue), so that code is never executed.

The reason there is no description is because this is first set at the top of the function (the underlined code in black), but then over-written by your new code (the underlined code in red).

Hope this helps

Stuart

ttuckel
October 31st, 2011, 22:56
Thank you Stuart !
IT WORKS !

My new code :

function onDiceLanded(draginfo)

if ChatManager.getDieRevealFlag() then
draginfo.revealDice(true);
end

applyModifierStackToRoll(draginfo);


-- ***************************** TEST D100
local entry = {};
entry.dice = draginfo.getDieList();
entry.text = draginfo.getDescription();
entry.font = "systemfont";
entry.diemodifier = draginfo.getNumberData();

-- Pour 1 D100, il faut 2 dés !! (1d100 et 1d10)
if(entry.dice[2] ~= nil)then
-- Si le 1er dé = D10 et le 2nd = d100 OU 1er dé = D100 et le 2nd = d10
if((entry.dice[1].type == "d10") and (entry.dice[2].type == "d100") or
(entry.dice[1].type == "d100") and (entry.dice[2].type == "d10"))then
-- Calcul résultat du jet
local d100Result = entry.dice[1].result + entry.dice[2].result;
-- Réécriture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
end
end

-- Si Dé Custom
if(entry.dice[1].type == "d80") then
-- Réécriture dans le tableau
entry.dice = {{type="d100", result=d100Result}};
entry.dice = "";
entry.text = "Dé custom";
entry.font = "systemfont";
entry.diemodifier = 0;

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

-- On reposte le message
deliverMessage(entry);

-- Retour (pour terminer les affichages)

end

-- Pour éviter la triche avec les D10 et les D100
local d10Found = false;
local d100Found = false;
local AutreDe = false;
local ListeDes = "";
--
if entry.dice then
for k,die in pairs(entry.dice) do
if die.type == "d100" then
d100Found = true;
end
if die.type == "d10" then
d10Found = true;
end

if die.type == "d4" then
AutreDe = true;
end
if die.type == "d8" then
AutreDe = true;
end
if die.type == "d12" then
AutreDe = true;
end
if die.type == "d20" then
AutreDe = true;
end

-- Composition de la liste des dés
--print("dieList: " .. die.type);
end
-- Composition de la liste des dés
if AutreDe then
ListeDes = "";
elseif d100Found and d10Found and AutreDe == false then
ListeDes = " [Tas de d10 et d100 !!]";
elseif d100Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d100]";
elseif d10Found and AutreDe == false then
ListeDes = " [" .. #entry.dice .. "d10]";
end
end

-- On complete la structure 'Entry" avant le renvoie
if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end

if draginfo.isType("dice") then
applyModifierStackToRoll(draginfo);
--We try to trick to change the Dice type after has been rolled but before is been shown on the chat
--We generate a manual message
local entry = {};
entry.text = draginfo.getDescription();
entry.font = "systemfont";
entry.dice = draginfo.getDieList();
entry.diemodifier = draginfo.getNumberData();

-- On calcul le résultat : Jet de dés + modificateur
local Total = entry.diemodifier;
for k,De in ipairs(entry.dice) do
if De.result then
Total = Total + De.result;
end
end
--
local Text = entry.text .. ListeDes;
entry.text = Text .." [Total: ".. Total.."]";

-- On reposte le message
if User.isHost() then
if ChatManager.getDieRevealFlag() then
entry.dicesecret = false;
end
entry.sender = GmIdentityManager.getCurrent();
else
entry.sender = User.getIdentityLabel();
end
-- We only trigger the "translation" on dices NOT having "d" defined
for i,v in ipairs(entry.dice) do
if string.find(v.type, "d") == nil then
print (v.type);
v.type = string.gsub(v.type,"(%a)","%1a");
print (v.type);
end
end
deliverMessage(entry);
return true;
end


end

Just some permutations !

One more time, thanks a lot !

StuartW
October 31st, 2011, 23:05
Je vous en prie :)