Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro· GoogleHugging Face LMArena Human Preference 140K

I have below macro in FoundryVTT13. When I execute it, I'm getting rendered list of…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o4-mini-2025-04-16’s answer.
  1. User

    I have below macro in FoundryVTT13. When I execute it, I'm getting rendered list of rolls, instead of list of numbers (parameters: content). When I remove rolls: rolled, from chat message data, I'm getting list of numbers, but DiceSoNice doesn't show animation. How to get just list of number and rolled dice?

  2. Gemini Assistant

    Of course! This is a classic and excellent question that demonstrates a core interaction in the Foundry VTT API. You've correctly identified the conflict:

    • The rolls property in a chat message is what triggers Dice So Nice.
    • A chat message with type: CONST.CHAT_MESSAGE_TYPES.ROLL tells Foundry to ignore your custom content and instead render the rolls array using its default template.

    You need to give the rolls data to Dice So Nice without letting Foundry's default roll template take over the chat message's appearance.

    Here are two effective ways to solve this.


    Solution 1: The Best and Simplest Method

    The easiest fix is to change the chat message type. By setting the type to something other than ROLL (like IC or OOC), you tell Foundry to render your content as-is, while still including the rolls property for Dice So Nice to see.

    Here is your macro, corrected with this simple change.

    /*
    * RECOMMENDED SOLUTION
    * This macro rolls 4d6, displays only the numeric results in a list,
    * and triggers the Dice So Nice animation.
    */
    (async () => {
        // 1. Perform the roll
        const roll = await new Roll('4d6').evaluate({ async: true });
    
        // 2. Extract the results into an array of numbers
        // A more modern way to get all results from all dice is using flatMap
        const results = roll.dice.flatMap(d => d.results.map(r => r.result));
    
        // 3. Build your custom HTML content
        let content_html = `<ul>`;
        results.forEach(r => {
            content_html += `<li>${r}</li>`;
        });
        content_html += `</ul>`;
    
        // 4. Create the Chat Message
        let chatData = {
            user: game.user.id,
            speaker: ChatMessage.getSpeaker(),
            content: content_html,
            // Include the rolls array for Dice So Nice. Note: it must be an array.
            rolls: [roll], 
            // THE KEY CHANGE: Use a different message type so Foundry displays
            // your custom 'content' instead of its own roll template.
            // IC (In Character) or OOC (Out of Character) are good choices.
            type: CONST.CHAT_MESSAGE_TYPES.IC 
        };
    
        ChatMessage.create(chatData);
    })();
    

    Why this works: Dice So Nice listens for any new chat message that has a rolls property. It doesn't care what the message type is. By changing the type to IC, you get the best of both worlds: Foundry renders your custom content, and Dice So Nice sees the rolls and plays the animation.


    Solution 2: Using the Dice So Nice API Directly

    This method is slightly more complex but is very powerful. You create your chat message exactly how you want it to look (without the rolls property), and then you separately tell Dice So Nice to play the animation for your roll.

    This is useful if you want to have animations without creating a chat message at all, or if you want more fine-grained control.

    /*
    * ALTERNATIVE SOLUTION
    * This uses the Dice So Nice API directly to show the roll.
    */
    (async () => {
        // 1. Check if Dice So Nice is active
        if (!game.modules.get("dice-so-nice")?.active) {
            ui.notifications.warn("Dice So Nice is not active.");
            return;
        }
        
        // 2. Perform the roll
        const roll = await new Roll('4d6').evaluate({ async: true });
    
        // 3. Extract results and build your custom HTML
        const results = roll.dice.flatMap(d => d.results.map(r => r.result));
        let content_html = `<ul>${results.map(r => `<li>${r}</li>`).join('')}</ul>`;
    
        // 4. Create a standard chat message with your content
        // Notice there is NO 'rolls' property here.
        let chatData = {
            user: game.user.id,
            speaker: ChatMessage.getSpeaker(),
            content: content_html
        };
        ChatMessage.create(chatData);
    
        // 5. Tell Dice So Nice to show the animation for the roll you made.
        await game.dice3d.showForRoll(roll);
    
    })();
    

    Why this works: You are decoupling the chat message creation from the dice animation.

    1. You create a perfectly formatted chat message with just your numbers.
    2. You then use the game.dice3d.showForRoll() function, which is the core of the Dice So Nice API, to trigger the 3D dice for the Roll object you created earlier.

    Both methods will give you your desired result: a chat message with just a list of numbers, and a beautiful 3D dice animation. I would recommend Solution 1 for its simplicity.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.