I can't see how. StartGame is completely missing from the code posted
.
The
ConvertToCopper function is also missing (and not an API function) so that will cause an error.
In future, place your code inside code tags (either the # or Lua buttons above the edit box).
Lua Code:
-- Update the StartGame function to accept the initiating player's name and the target's name
local function StartGame(player, target, amount, unit)
print("Death Dice game started! " .. player .. " vs " .. target .. ".")
print("Bet amount: " .. amount .. " " .. unit .. ".")
isGameInProgress = true
currentPlayer = player
betAmount = ConvertToCopper(amount, unit)
end
StaticPopupDialogs["DEATHDICE_CONFIRM"] = {
text = "Do you want to start a Death Dice game?",
button1 = "Yes",
button2 = "No",
OnAccept = function(self, data)
StartGame(data.player, data.target, data.amount, data.unit)
print("You start a Death Dice game with " .. data.target .. "! Type '/roll' to make your first roll.")
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,
}
-- 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
local confirmation = StaticPopup_Show("DEATHDICE_CONFIRM", "Do you want to start a Death Dice game with " .. targetName .. " for " .. amount .. " " .. unit .. "?")
if confirmation then
confirmation.data = { player = player, target = targetName, amount = amount, unit = unit }
end
end
SLASH_DEATHDICE1 = "/deathdice"