Coin flip macro

I’m looking to turn my homemade dice rolling macro into a coin flip macro.

/e throws a pair of homemade dice.

/script local d1 = random(6); local d2 = random(6); local d3 = d1+d2; SendChatMessage(“rolls a “…d1…” and a “…d2…”, for “…d3…”!”, “EMOTE”, nil, nil)

My first thought is to eliminate d2 and d3, reduce d1 to random(2) and add an if statement so that if d1=1 then SendChatMessage(“coin lands heads up!”) if d1=2 then SendChatMessage(“coin lands tails up!”) But I can’t find how to do that, or if it’s even possible. Any macro pros out there can help me out?

/run local d1 = random(2) SendChatMessage(format("Coin lands %s up!", d1 == 1 and "Heads" or "Tales"), "EMOTE", nil, nil)
1 Like

Like a charm! thank you.

Don’t suppose there’s any way to add a pause between the flip and the catch eh?

something like this seems to work

/run SendChatMessage("flips a coin.","EMOTE", nil, nil) C_Timer.After(2, function() local d1 = random(2) SendChatMessage(format("catches the coin %s up!", d1 == 1 and "Heads" or "Tails"), "EMOTE", nil, nil) end)
2 Likes

Maybe randomise the 2 second C_Timer.After(x value (between say 2 and 5 seconds) to add suspense.

2 Likes