What's new

GHATGPT / LUA generation ...

fatbeard

Trial Member
4
2018
0
Hi Guys.

We want an addon for WotLK 335a Trinitycore with ChatGPT3.5

A description of the desired addon, and the generated code are below. Cannot get it to run (tried different clients and servers - its the code not the setup).
A TOC file and LUA file were added to the addons folder (/AuctionBot). The addon is visible in the addon screen, and selected. All other addons turned off.


Hi Mike! (<<my name for ChatGPT)
We were thinking about a WoW addon.
The target client is WoW335a.
The addon in question detects when people offer items for sale with a message such as "WTS [linked item]" into a specified chat channel, and will proceed to auction the item, verbally, into the channel with the message "THANKS SIR! NOW AUCTIONING - [linked object]. Who will start me off at 1g?". The addon will then detect bids from other players in the form "1000g" or "50 gold" (for 1000 or 50 gold), or "10s" (for 10 silver) or "1c" (for 1 copper) noting the bidding [player name]. The addon will prompt 3 times for more bids with "Any more for [linked item] - currently [highest bid]." On a winning bid (the highest bid after 30 seconds of no bids) the addon announces "THANK YOU [player name]. You win [linked item] for [highest bid]." Humans would then arrange the collection, delivery and payment.

The generated code (which I asked for a terse version of) below:

1. AuctionBot.toc

Code:
## Interface: 30300
## Title: AuctionBot
## Version: 0.1
## Author: ChatGPT / LitchLight III / TheFiddler / FatBeard
## Notes: Automated bidding and selling process for Guild Items. Say wts [itemlink] into guild chat!
## Dependencies:

AuctionBot.lua



2. AuctionBot.lua ...

HTML:
local G = "GUILD"
local function AIL(event, m, a, _, _, _, _, _, c, _, _, g)
    if c == G and string.find(m, "wts %[(.-)%]") then
        local i = string.match(m, "|H(.-)|h")
        if i then
            SendChatMessage("THX SIR! NOW AUCTIONING - "..i..". Who will start me off at 1g?", G)
            local p, b, t = nil, 0, 30
            local function ABP()
                t = t - 1
                if t == 0 then
                    if b > 0 then
                        SendChatMessage("THX "..p..". YOU WIN "..i.." FOR "..b, G)
                        -- TODO: Arrange collection, delivery and payment.
                    else
                        SendChatMessage("NO BIDS FOR "..i, G)
                    end
                elseif t == 10 or t == 20 then
                    SendChatMessage("ANY MORE FOR "..i.." - CURRENTLY "..b, G)
                end
            end
            local f = CreateFrame("Frame")
            f:SetScript("OnUpdate", function() ABP() end)
            f:SetScript("OnEvent", function(_, e, b, n) if e == "CHAT_MSG_CHANNEL" and n ~= a and c == G and tonumber(b) then if tonumber(b) > b then p, b = n, tonumber(b) end end end)
            f:RegisterEvent("CHAT_MSG_CHANNEL")
        end
    end
end

local f = CreateFrame("Frame")
f:RegisterEvent("CHAT_MSG_CHANNEL")
f:SetScript("OnEvent", AIL)

Is there anything obvious?

FB.
 
Last edited:

fatbeard

Trial Member
4
2018
0
Here's another try (read "FAIL!") ...


ME:

Hi Mike!
We were thinking about a WoW addon.
The target client is WoW335a.
The addon in question detects when people offer items for sale with a message such as "WTS [linked item]" into a specified chat channel, and will proceed to auction the item, verbally, into the channel with the message "THANKS SIR! NOW AUCTIONING - [linked object]. Who will start me off at 1g?". The addon will then detect bids from other players in the form "1000g" or "50 gold" (for 1000 or 50 gold), or "10s" (for 10 silver) or "1c" (for 1 copper) noting the bidding [player name]. The addon will prompt 3 times for more bids with "Any more for [linked item] - currently [highest bid]." On a winning bid (the highest bid after 30 seconds of no bids) the addon announces "THANK YOU [player name]. You win [linked item] for [highest bid]." Humans would then arrange the collection, delivery and payment.

We have a .toc file so far (File 1) ...

## Interface: 30300
## Title: Guild AuctionBot
## Version: 0.1
## Author: ChatGPT / LitchLight III
## Notes: Automated bidding and selling process for in-game items.
## Dependencies:

AuctionBot.lua



MIKE:

Hi there! It sounds like you're planning to create an interesting WoW addon that can automate the auction process for in-game items.

I see that you've started with creating a .toc file. This file is used by WoW to identify the addon and provide information about it, such as the version number and author.

Next, you will need to create the AuctionBot.lua file that contains the actual code for your addon. This file will need to listen for chat messages in the specified channel and parse them to identify when someone is offering an item for sale.

Once the item is identified, you will need to use the WoW API functions to create an auction for the item and manage the bidding process. You can use the SendChatMessage function to announce the auction to the channel and prompt for bids.

To manage the bidding process, you will need to track the current highest bid and the bidder's name. You can use the SetAuctionBid function to place bids and the GetNumAuctionItems and GetAuctionItemInfo functions to retrieve information about the auction.

Finally, you will need to determine when the auction has ended and announce the winner to the channel. You can use the OnAuctionClosed event to detect when an auction has ended and the highest bidder is the winner.

I hope this information helps you get started with your addon development. Good luck!


ME:
The auction will take place only in a chat channel ... no items will be listed on the auctionhouse. The process is a game to be played by guild members in the /guild channel.

MIKE:
Thanks for the clarification! If the auction will take place only in a chat channel and not on the auction house, then you will not need to use the WoW API functions for creating and managing auctions. Instead, you can focus on listening for chat messages, parsing them, and announcing the auction and bids in the guild channel.

To listen for chat messages, you can use the ChatFrame_OnEvent function, which is called whenever a chat message is received. You can then use string manipulation functions such as string.find and string.match to identify when someone is offering an item for sale and extract the item name.

To announce the auction and bids, you can use the SendChatMessage function with the guild channel as the first argument. You can format the messages to include the item name, current highest bid, and bidder's name as appropriate.

To manage the bidding process, you will need to track the current highest bid and the bidder's name, and use a timer to determine when the auction has ended. You can use the C_Timer.NewTimer function to create a timer, and when the timer expires, you can announce the winner to the guild channel.

Remember to also include error checking and validation to ensure that the addon handles unexpected situations gracefully and does not cause any problems for the players.




ME:
Understood.
Mike ... can you please produce the code for the .lua file?
Please use short variable and function names (for instance "auctionItem" would be "aI"). Please do not include comments (to save space).
[^^ This was done because of the low token limit on GPT3.5 free).


MIKE:

Certainly! Here's an example of the code you could use in your AuctionBot.lua file. Please note that this is just a basic outline and you will need to customize it based on your specific requirements:


Code:
local aI -- auction item
local hB -- highest bid
local hBN -- highest bidder name
local t -- timer

local function StartAuction(itemLink)
  aI = itemLink
  hB = 0
  hBN = nil
  SendChatMessage("THANKS SIR! NOW AUCTIONING - "..aI..". Who will start me off at 1g?", "GUILD")
  t = C_Timer.NewTimer(30, function()
    if hBN then
      SendChatMessage("THANK YOU "..hBN..". You win "..aI.." for "..hB.."!", "GUILD")
      aI = nil
      hB = nil
      hBN = nil
      t = nil
    else
      SendChatMessage("No bids for "..aI..". Auction cancelled.", "GUILD")
      aI = nil
      hB = nil
      hBN = nil
      t = nil
    end
  end)
end

local function UpdateBid(bidder, amount)
  local gold, silver, copper = string.match(amount, "(%d+)g?%s?(%d*)s?%s?(%d*)c?")
  local total = tonumber(gold or 0) * 10000 + tonumber(silver or 0) * 100 + tonumber(copper or 0)
  if total <= hB then
    SendChatMessage("Sorry "..bidder..", your bid of "..amount.." is not high enough. Current highest bid is "..hB.."g by "..hBN..".", "GUILD")
  else
    hB = total
    hBN = bidder
    SendChatMessage("BID ACCEPTED! "..bidder.." bids "..amount.." for "..aI..".", "GUILD")
    SendChatMessage("Any more for "..aI.." - currently "..hB.."g by "..hBN.."?", "GUILD")
    t:Cancel()
    t = C_Timer.NewTimer(30, function()
      if hBN then
        SendChatMessage("THANK YOU "..hBN..". You win "..aI.." for "..hB.."!", "GUILD")
        aI = nil
        hB = nil
        hBN = nil
        t = nil
      else
        SendChatMessage("No bids for "..aI..". Auction cancelled.", "GUILD")
        aI = nil
        hB = nil
        hBN = nil
        t = nil
      end
    end)
  end
end

local function OnEvent(self, event, message, author, ...)
  if event == "CHAT_MSG_GUILD" then
    local itemLink = string.match(message, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%[.+%]")
    if itemLink then
      StartAuction(itemLink)
    else
      local bidder, amount = string.match(message, "^(%S+) bids (%S+) for "..(aI or ""))
      if bidder and amount then
        UpdateBid(bidder, amount)
      end
    end
  end
end

local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_GUILD")
frame:SetScript("OnEvent", OnEvent)
 
Top