PDA

View Full Version : Displaying Custom Icons for Die Results



Ogedei
November 3rd, 2017, 03:08
Ok. I don't know if I am dumb or just missing something.

I am trying to build a Conan oriented d6.

I have the icons defined as

<root>
<icon name="dCombaticon" file="graphics/dice/dCombat/dCombat.png" />
<icon name="dCombaticon.1" file="graphics/dice/dCombat/dCombat.1.png />
<icon name="dCombaticon.2" file="graphics/dice/dCombat/dCombat.2.png" />
<icon name="dCombaticon.3" file="graphics/dice/dCombat/dCombat.3.png" />
<icon name="dCombaticon.4" file="graphics/dice/dCombat/dCombat.4.png" />
<icon name="dCombaticon.5" file="graphics/dice/dCombat/dCombat.5.png" />
<icon name="dCombaticon.6" file="graphics/dice/dCombat/dCombat.6.png" />
</root>

I have the die defined as

<root>
<customdie name="CombatDie">
<model>d6</model>
<menuicon>customdice</menuicon>
</customdie>
<die name="CombatDie.1"><icon>dCombaticon.1</icon></die>
<die name="CombatDie.2"><icon>dCombaticon.2</icon></die>
<die name="CombatDie.3"><icon>dCombaticon.3</icon></die>
<die name="CombatDie.4"><icon>dCombaticon.4</icon></die>
<die name="CombatDie.5"><icon>dCombaticon.5</icon></die>
<die name="CombatDie.6"><icon>dCombaticon.6</icon></die>
</root>

I expect to see results that use the defined die icons, but all I get is regular numbers when I roll it.

Nickademus
November 3rd, 2017, 05:47
Check the /console just after you load the ruleset and look for warnings about icons failing to load. It may be that icon names cannot have a "." in them.

Bidmaron
November 3rd, 2017, 12:29
If I understand what you are trying to do you cannot do it. If you are expecting the 3d dice to display with your defined graphics on the die itself, that cannot be done. If not then you need to say what it is you are trying to do, as it is not very clear. What you have shown us in code is very incomplete.

Ogedei
November 3rd, 2017, 13:15
Check the /console just after you load the ruleset and look for warnings about icons failing to load. It may be that icon names cannot have a "." in them.

I have tried with and without the . in the name. The only load error I get is one I introduced, which is dCombat.4.png does not load, because I deleted it, to make sure the code was being looked at.

Ogedei
November 3rd, 2017, 13:17
If I understand what you are trying to do you cannot do it. If you are expecting the 3d dice to display with your defined graphics on the die itself, that cannot be done. If not then you need to say what it is you are trying to do, as it is not very clear. What you have shown us in code is very incomplete.

I am not trying to modify the 3d dice. I am trying to build a custom die that displays custom result graphics in the chat window.

I expect to see results that use the defined die icons, but all I get is regular numbers when I roll it.

dulux-oz
November 3rd, 2017, 13:55
I am not trying to modify the 3d dice...

Yeah, but that's what you ARE trying to do (change the 3d dice) - its the way the FG Engine works.

Unless things have changed recently (and I/we haven't been informed) then as Bidmaron said what you are trying to do can't be done. :(

damned
November 3rd, 2017, 14:11
the OP is just trying to replace the final results that are shown in the chat window.

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=21347

21347

Ogedei
November 3rd, 2017, 14:23
the OP is just trying to replace the final results that are shown in the chat window.

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=21347

21347

Correct. That is the goal.

dulux-oz
November 3rd, 2017, 14:27
Yes, I understand that - and my previous statement stands; unless something has changed recently that part of the code is embedded in the FG Engine and is not accessible to the Community Devs.

And I will be more than happy to be proved wrong because I've been trying to do something similar on and off for a couple of years, and the last time I asked Moon he said basically what I just said.

damned
November 3rd, 2017, 14:36
Yes, I understand that - and my previous statement stands; unless something has changed recently that part of the code is embedded in the FG Engine and is not accessible to the Community Devs.

And I will be more than happy to be proved wrong because I've been trying to do something similar on and off for a couple of years, and the last time I asked Moon he said basically what I just said.

But thats a screen shot... and so is this...

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=21348

21348

Ogedei
November 3rd, 2017, 14:40
Yes, I understand that - and my previous statement stands; unless something has changed recently that part of the code is embedded in the FG Engine and is not accessible to the Community Devs.

And I will be more than happy to be proved wrong because I've been trying to do something similar on and off for a couple of years, and the last time I asked Moon he said basically what I just said.

It might not be possible, but I'm not modifying the 3d dice. The displayed value is not derived from the 3d dice. I can make the black results die graphics come up as any numbers that aren't displayed on a d6. 0, -1, etc. Which suggests they are built rather than a static graphic.

Other threads seem to suggest it is which is why I'm even trying.

Heck even this suggests it might be possible.

https://www.fantasygrounds.com/refdoc/die.xcp

Andraax
November 3rd, 2017, 14:42
Then how does the Star Wars EotE ruleset do it?

dulux-oz
November 3rd, 2017, 14:43
But thats a screen shot... and so is this...

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=21348

21348

Then I'd love to know how it was done, because as I said: Moon said it wasn't possible for the Community Devs to do it because that functionality hadn't been exposed. He also said that modifing that part of the dice system would also be modifing the rolling dice, as it was the same section of code. :confused:

damned
November 3rd, 2017, 14:43
Have a look at the Mutant Year Zero extension (for CoreRPG or MoreCore)
Or look at the Funky Dice in MoreCore or the d66, d666, d60, d600 in MoreCore
Or look at the dice in Star Wars: Edge of the Empire or in the Warhammer FRP rulesets...

damned
November 3rd, 2017, 14:44
Trenloe has written up some guide on it before too IIRC...

Bidmaron
November 3rd, 2017, 14:45
The best way to approach this is find another ruleset or extension that modifies the result display and mimic that. I don’t use any such unusual dice games so I don’t know where to point you unfortunately. Someone just did though if you own that Star Wars material.

Ogedei
November 3rd, 2017, 14:47
I've looked through starwars EotE. I've built my die xml to mimic theirs. But I'm clearly missing something key.

damned
November 3rd, 2017, 14:51
The Mutant Year Zero extension is probably the best place to look as there is a much smaller number of files to work thru

Also see these:
https://www.fantasygrounds.com/forums/showthread.php?20615-Custom-Dice
https://www.fantasygrounds.com/forums/showthread.php?28287-Mutant-Year-Zero-Dice-Mechanic
https://www.fantasygrounds.com/forums/showthread.php?23452-DCC-Dice-d3-d5-d7-d14-d16-d24-d30
https://www.fantasygrounds.com/forums/showthread.php?23013-Demi-Dice
https://www.fantasygrounds.com/forums/showthread.php?25068-Change-colour-on-1-dice

All of these threads have some good info on the challenge.

Trenloe
November 3rd, 2017, 17:26
I've looked through starwars EotE. I've built my die xml to mimic theirs. But I'm clearly missing something key.
Are you actually rolling the custom dice and not just the normal dice?

Can you provide a screenshot of the chat window after you've done a few rolls?

Trenloe
November 3rd, 2017, 17:29
Then I'd love to know how it was done, because as I said: Moon said it wasn't possible for the Community Devs to do it because that functionality hadn't been exposed. He also said that modifing that part of the dice system would also be modifing the rolling dice, as it was the same section of code. :confused:
I think you're getting confused with what Moon was discussing. It is possible to modify the dice result icons in chat, and is done after the roll, in the action result handler.

Nickademus
November 3rd, 2017, 18:26
I did this in an extension at one point in time. I modified custom dice to show images instead of numbers. Don't remember where I put that extension, but it wasn't hard.

Trenloe
November 3rd, 2017, 18:42
@Ogedei - I'm guessing you're probably missing the dice action result handler that changes the default dice icons? More details here: https://www.fantasygrounds.com/forums/showthread.php?23013-Demi-Dice&p=197883&viewfull=1#post197883 See also the gotcha if you don't want the dice number appearing.

Ogedei
November 3rd, 2017, 18:59
Are you actually rolling the custom dice and not just the normal dice?

Can you provide a screenshot of the chat window after you've done a few rolls?

Once I get home I can. I am pretty sure I am rolling the custom die. In that I was screwing with it this morning and writing a custom script in it to roll appropriate values and that was working.

I think what I am missing, after looking through the Mutant.ext extension is an action result handler. (I'm a noob, see my little green bars!?)

Ogedei
November 4th, 2017, 01:35
Thanks for all the help and code snipets to look at! Very much appreciated!

21350

Ogedei
November 4th, 2017, 01:44
Now with proper damage count.

21351

damned
November 4th, 2017, 02:06
Well done Ogedei.
Minor suggestion - use a number like d101 or d106.
Dont be afraid to post your solution too!

Ogedei
November 4th, 2017, 02:11
I'm using D1 as the combat die number. So I can call it from the chat window etc.

Nothing special in my solution. It's pretty much copied right out of the mutant.ext with a slight modification to the action dice handler.

function onInit()
Debug.console("Die Manager Initalized");
ActionsManager.registerResultHandler("dice", onDice);
ActionsManager.registerModHandler("dice", modDice);
end

function modDice(rSource, rTarget, rRoll)
-- Debug.console("modDice: ", rRoll);
end

function onDice(rSource, rTarget, rRoll)
Debug.console("onDice: ", rRoll);
for cnt=1, #rRoll.aDice do
if rRoll.aDice[cnt].type == "d1" then
if (rRoll.aDice[cnt].result==6 or rRoll.aDice[cnt].result ==5) then
rRoll.aDice[cnt].type = "d1"..rRoll.aDice[cnt].result;
rRoll.aDice[cnt].result=1;
elseif (rRoll.aDice[cnt].result==3 or rRoll.aDice[cnt].result ==4) then
rRoll.aDice[cnt].type = "d1"..rRoll.aDice[cnt].result;
rRoll.aDice[cnt].result=0;
else
rRoll.aDice[cnt].type = "d1"..rRoll.aDice[cnt].result;
end
-- rRoll.aDice[cnt].result = 0;
end
Debug.console("onDice: ", rRoll.aDice[cnt])
end

local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
Comm.deliverChatMessage(rMessage);
end