View Single Post
02-15-24, 07:13 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,892
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:
  1. -- Update the StartGame function to accept the initiating player's name and the target's name
  2. local function StartGame(player, target, amount, unit)
  3.     print("Death Dice game started! " .. player .. " vs " .. target .. ".")
  4.     print("Bet amount: " .. amount .. " " .. unit .. ".")
  5.     isGameInProgress = true
  6.     currentPlayer = player
  7.     betAmount = ConvertToCopper(amount, unit)
  8. end
  9.  
  10. StaticPopupDialogs["DEATHDICE_CONFIRM"] = {
  11.     text = "Do you want to start a Death Dice game?",
  12.     button1 = "Yes",
  13.     button2 = "No",
  14.     OnAccept = function(self, data)
  15.         StartGame(data.player, data.target, data.amount, data.unit)
  16.         print("You start a Death Dice game with " .. data.target .. "! Type '/roll' to make your first roll.")
  17.         StaticPopup_Hide("DEATHDICE_CONFIRM") -- Close the confirmation popup
  18.     end,
  19.     OnCancel = function(self)
  20.         print("You declined the Death Dice game.")
  21.         StaticPopup_Hide("DEATHDICE_CONFIRM") -- Close the confirmation popup
  22.     end,
  23.     timeout = 0,
  24.     whileDead = true,
  25.     hideOnEscape = true,
  26.     preferredIndex = 3,
  27. }
  28.  
  29. -- Define the SlashCmdList.DEATHDICE function to handle initiating and declining a match
  30. function SlashCmdList.DEATHDICE(msg)
  31.     if isGameInProgress then
  32.         print("A Death Dice game is already in progress!")
  33.         return
  34.     end
  35.  
  36.     local player = UnitName("player")
  37.     local targetName = UnitName("target")
  38.     local amount, unit = tonumber(msg:match("(%d+)")), msg:match("(%a+)")
  39.  
  40.     if not targetName then
  41.         print("You must target a friendly player to start a Death Dice game.")
  42.         return
  43.     end
  44.  
  45.     if not amount or not unit or (unit ~= "copper" and unit ~= "silver" and unit ~= "gold") then
  46.         print("Usage: /deathdice <amount> <unit> (e.g., /deathdice 5 copper)")
  47.         return
  48.     end
  49.  
  50.     local confirmation = StaticPopup_Show("DEATHDICE_CONFIRM", "Do you want to start a Death Dice game with " .. targetName .. " for " .. amount .. " " .. unit .. "?")
  51.     if confirmation then
  52.         confirmation.data = { player = player, target = targetName, amount = amount, unit = unit }
  53.     end
  54. end
  55. SLASH_DEATHDICE1 = "/deathdice"
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-15-24 at 08:17 PM.
  Reply With Quote