Noted! I will definitely keep that in mind
Thank you for the help, I truly appreciate it lol. I'm in fact a noobie lol. I did away with the
ConvertToCopper, added the StartGame that I SOMEHOW deleted, it's mostly working (the error comments at least lol) but I go to do /deathdice 5 copper and it won't even let me click enter, just stays in the chat bar while targeting my friend to test. Though, when not targeting my friend it enters, but shows the "You must target a friendly player to start a Death Dice game." error message. I'm missing stuff, or maybe something is in the wrong place is all I can think
, also I downloaded the BugGrabber and BugSack, since I forgot to earlier. Will definitely install them and test with them! Here's what I have updated lol
Lua Code:
-- Global variable to keep track of whose turn it is
local currentPlayer = ""
local isGameInProgress = false
-- Function to start the game
function StartGame(player, target, amount, unit)
currentPlayer = player
isGameInProgress = true
print(player .. " starts a Death Dice game with " .. target .. "! Type '/ddroll' to make your first roll.")
print("Bet amount: " .. amount .. " " .. unit .. ".")
end
-- Function to handle rolling the dice
local function RollDice(player)
if player ~= currentPlayer then
print("It's not your turn to roll!")
return
end
local roll = math.random(1, 100)
print(player .. " rolls: " .. roll)
end
-- Define the confirmation popup dialog
StaticPopupDialogs["DEATHDICE_CONFIRM"] = {
text = "",
button1 = "Yes",
button2 = "No",
OnAccept = function(self, data)
StartGame(data.player, UnitName("player"), data.amount, data.unit)
StaticPopup_Hide("DEATHDICE_CONFIRM") -- Close the confirmation popup
end,
OnCancel = function(self)
print("You declined the Death Dice game.")
StaticPopup_Hide("DEATHDICE_CONFIRM") -- Close the confirmation popup
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
end
-- Define the SlashCmdList.DEATHDICE function to handle initiating and declining a match
function SlashCmdList.DEATHDICE(msg)
if isGameInProgress then
print("A Death Dice game is already in progress!")
return
end
local player = UnitName("player")
local targetName = UnitName("target")
local amount, unit = tonumber(msg:match("(%d+)")), msg:match("(%a+)")
if not targetName then
print("You must target a friendly player to start a Death Dice game.")
return
end
if not amount or not unit or (unit ~= "copper" and unit ~= "silver" and unit ~= "gold") then
print("Usage: /deathdice <amount> <unit> (e.g., /deathdice 5 copper)")
return
end
-- Send a request to the target player
SendRequestToTarget(player, targetName, amount, unit)
end
-- Function to send a request to the target player
local function SendRequestToTarget(player, targetName, amount, unit)
-- Display a confirmation popup on the target player's screen
local confirmation = StaticPopup_Show("DEATHDICE_CONFIRM", "Do you want to start a Death Dice game with " .. player .. "?")
if confirmation then
confirmation.data = { player = player, target = targetName, amount = amount, unit = unit }
end
end
-- Define the /ddroll command to allow players to roll the dice during a Death Dice game
function SlashCmdList.DDROLL(msg)
if not isGameInProgress then
print("No Death Dice game in progress!")
return
end
RollDice(UnitName("player"))
end
-- Define the slash commands
SLASH_DEATHDICE1 = "/deathdice"
SLASH_DDROLL1 = "/ddroll"