Thread Tools Display Modes
03-31-09, 05:25 PM   #1
LeChango
A Defias Bandit
Join Date: Mar 2009
Posts: 1
Question Converting /random into a usuable string?

Hello, I am new here to WoWInterface. Here is my problem:

I am trying to create a blackjack addon that displays an automated dealer's hand, then a player's hand to party chat, then gives the option to hit/stand to the player. I would like to generate the cards drawn by using RandomRoll(1,13) and displaying a card in party based off of the roll. (Ex: a Roll of 11 would display "[J]" in party chat).

My problem is this. I cannot find a way to convert the RandomRoll() to a string that can be applied to a conditional statement. I understand that I can use just use math.random() but I do not want to do this, I want people playing the blackjack to know that the game is not rigged, and that the cards are based off of a 1-13 roll.

I think this can be done with a CHAT_MSG_SYSTEM event, but I'm new to this and new some guidance.

Thanks for any help in advance.
  Reply With Quote
04-02-09, 01:12 PM   #2
Exawatt
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 36
Here's more on CHAT_MSG_SYSTEM. You'll have to register-for and handle the event and use pattern matching to pull the numbers out (though this wouldn't be wise if you plan on localizing).

I would also keep the extracted number as an integer for comparison purposes, and just format output using tostring() or string.format().

Originally Posted by LeChango View Post
I understand that I can use just use math.random() but I do not want to do this. I want people playing the blackjack to know that the game is not rigged, and that the cards are based off of a 1-13 roll.
Unless you're obfuscating your code, it'll be easy to say "The game doesn't cheat. Look at the code yourself. (Then point to line number(s).) Besides, you can mimic the output of RandomRoll() on your own, so if someone thought you were cheating, the roll output wouldn't dissuade them.

Unless the players are typing "/roll 1 13" themselves?

But why are your cards generated at random? Is the game using an infinite number of decks? Part of the strategy to Blackjack is card counting (in one form or another), so a predetermined number of decks helps create strategy. I'd create a predetermined number of cards and randomly shuffle them.

That's all just my two cents on this method.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Converting /random into a usuable string?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off