Problems displaying dice image in chat window

I have already posted a link to my Animated Dice extension, but as I would find out later, it was still very unstable, with some bugs that would lead to Vassal errors.

Now, with the help of an ASL player, which tried to use it, it seems to be working ok, with the exception of a last detail (so far): the dice images on the chat window. I have used it with a test extension, with OCS and with Vasl, and the dice images display properly when testing with 2 different Vassal instances. So, if I roll in one instance, the animation displays in the other Vassal instance and the chat dice images show up properly. I’m using two vassal instances, but a single user. The guy who is helping me tried with two users in two different computers and it seems that the chat dice images are displaying ok for the player who is rolling, but placeholders are showing up for the opponent. Since I can’t reproduce it on my computer, I’m asking here to see if someone has any idea why this is happening.

Here is the code for sending the results:

private void sendResults(int[] results){
        try {
            String redDie = "";
            if (results.length == 2){
                URL redDieIconURL = dataArchive.getURL(ICONS_IMAGES_PATH + "red" + results[1] + ".png");
                redDie = "<img src='" + redDieIconURL + "' width='25' height='25'>";
            }
            URL whiteDieIconURL = dataArchive.getURL(ICONS_IMAGES_PATH + "white" + results[0] + ".png");
            String whiteDie = "<img src='" + whiteDieIconURL + "' width='25' height='25'>";
            String message = "- | <b>" + playerId + "</b> " + whiteDie + " " + redDie;

            Command c = new Chatter.DisplayText(gameModule.getChatter(), message);
            c.execute();
            gameModule.sendAndLog(c);
        } catch (IOException e){
            e.printStackTrace();
        }
    }

Here is what he is getting:
image

Here is a video showing the extension in use:

And here is the link to the extension, if someone is willing to try it:

Any help would be welcome.

I get the placeholders showing if I run an Animated Dice log file without installing the Animated Dice extension. Check that they didn’t get the following message on the second computer

- This game was saved with extension 'Animated 3D Dice Extension' loaded. You do not have this extension loaded. Place the file into the 'D:\Data\Vassal\Modules\Battle For Moscow\BattleforMoscow_ext' folder to load it

Also, It’s annoying that the ‘Rolling’ message and the dice display are 2 separate Commands that need 2 separate Next clicks (or 2 separate uindos) to step through in the log. I would combine the two into a single Command.

I have to say you are a brave man developing a Die Roller for the VASL crowd.

I rolled 6 dice and got 3 sixes. Talk about streaky.

Random ran = new Random();

OMG!!! They will eat you alive :slight_smile: That’s the original RNG we stopped using under protest in 2007 due to the VASL folks whinging.

Also, It’s annoying that the ‘Rolling’ message and the dice display are 2 separate Commands that need 2 separate Next clicks (or 2 separate uindos) to step through in the log. I would combine the two into a single Command.

I did so for when someone is using the extension with another player that isn’t. So, the Rolling message will display before the animation and the chat dice will display after the animation.

I have to say you are a brave man developing a Die Roller for the VASL crowd.
I rolled 6 dice and got 3 sixes. Talk about streaky.

Random ran = new Random();

OMG!!! They will eat you alive :slight_smile: That’s the original RNG we stopped using under protest >in 2007 due to the VASL folks whinging.

Is Random ran = new Random() really biased?
If so, what would you suggest in place of it, to get a fair result?

Btw, I’m not doing it specifically for ASL. In OCS it is working ok. I think it should work well with any game using one or two 6 sided dice. I did nothing for it to work in OCS and ASL. In the case of ASL, just the chat presents this problem, since they use a specific chatter class. Anyway, Vasl has pre-established buttons for specific types of dice roll, so I don’t know if they will use it anyway. I’ll make the extension available for whoever wants to use or modify it. It can fit from wargames to backgammon.

Use GameModule.getRNG().

Thanks uckelman. Will do it.

No, not all, just being cheeky. As Joel suggests, use GameModule.getRNG() to get the current RNG we use in Vassal for everything else.

I get the placeholders showing if I run an Animated Dice log file without installing the Animated Dice extension. Check that they didn’t get the following message on the second computer

  • This game was saved with extension ‘Animated 3D Dice Extension’ loaded. You do not have this extension loaded. Place the file into the ‘D:\Data\Vassal\Modules\Battle For Moscow\BattleforMoscow_ext’ folder to load it

Brent, when I try two instances of vassal, one with the extension and another without it, I still get the dice image, so I supposed, when I first saw it, that the images where somehow sent to the opponent:

But it seems you’re getting the placeholders in this case. I don’t know what causes it, but I think it would be safer to send text only messages for those that don’t have the extension installed. Is there a way to send a chat message that, once the images aren’t found, would display a text only message? I would have to, somehow, encode it on the command sent, I suppose.

Everyone playing a game should be using the same set of extensions. Having different sets of extensions active can lead to all kinds of problems.

Ok, nice to. So I can expect people won’t usually do it.

People might do it, but it’s not supported, so if they do it’s their problem to solve.

No, images are never sent to other clients, they have to exist in the target client. Where you running the extra client under the IDE? That may have been picking up the images that would not normally be available to a normal client.

That’s not really possible within the existing DisplayText command. The inclusion of images in the chat message by tags is an add-on hack. There are no changes you could make to DisplayText that could maje a Dice-unaware client display anything differently.

One possibility you could try is to create a new DisplayDice command to display the images. Then you send the text of the result as a DisplayText command and piggyback on a DisplayDice command to show the images. Clients that do not have AnimatedDice loaded would ignore the DisplayDice command.

DisplayDice would just locally build a DisplayText and execute it.

This gives you the Text PLUS the image, not Text OR the image, but would work cleanly on clients that don’t have the extension loaded.

I’m not sure I understood the approach, mainly the part in which DisplayDice would build the DisplayText.
I can have a DisplayText command followed by a DisplayDice command as a simple approach, but then the modules that have the extension installed will present two chat lines, one with text and one with the dice images. I think it isn’t a problem having both text and images on the same line, but having two lines would make things too poluted, since I already have the “Rolling” line displayed. Yet, I think this isn’t what you have in mind.

The only way you can get a client without the extension to display a message without the Die images is to send a standard DisplayText command with the message without the source tags.

The Animated part would be sent as a separate DisplayDice command that in DisplayDice.executeCommand() does something like

   <Do Dice Animation>
   final Chatter.DisplayText animatedText = new Chatter.DisplayText(..., 'Report with images included');
   animatedText.execute();
   --

i.e. build a DisplayText command on the local client and execute it, but don’t send it anywhere.

Now, the problem you have is that on a client that has the extension, you don’t actually want to display that original text that is for the non-extension client.

That’s where it get’s interesting.

You could possibly insert your own Command Encoder that checks for a DisplayText, identifies that this is an alternate display for the extension and suppress it.

To do this, you would need to do something like

   final GameModule gm = GameModule.getGameModule();
   final Chatter chat = gm.getChatter();
   gm.remove(chat)
   gm.addCommandEncode(mySpecialCommandEncoder);
   gm.add(chat);

As there is no other way to install your CommandEncoder before the already existing Chatter CommandEncoder.

Thanks for the suggestion and explanation, but I think it is becoming too complicated just to deal with a occasions where one side doesn’t have the extension, which shouldn’t be the rule, as stated by uckelman.

I’ll settle for a middle term solution. I’ll present the results as numbers before the dice images and allow users to prevent both the dice images display and the numbers display. So, if someone wants to play another person without the extension, they will get the numbers with the place holders behind. If that is bothering somehow, the one with the extension can switch off the dice images. The bonus is the it will become more customizable this way.

1 Like

Here is the new version, displaying numbers and dice images with the option to turn off both.

I have optimized the buttons response too, since I found out that the sound clip was causing some delay. They are more responsive now.

Here is the link, if you are willing to try it:

Btw, is there any place I can make this link available? I noticed in Vassal site, that we can create a module page, but there is no place for extensions outside a module page. Since this extension is generical, I would like to make it available to anyone wanting to try it with any module that uses one or two 6 sided dice.

I have packed it with a readme and a license allowing anyone to change and use it at will. Is there any place in vassal site I can make the link available? If not, what would you suggest?