View Single Post
12-28-10, 08:12 PM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Help needed for custom messages containing existing variables?

I want to add the ability for users to make custom messages in MageTaxi. The problem is I'm not sure how I would go about doing this or the best way to do so.

The current format is as follows:
lua Code:
  1. msg = "MageTaxi: WTS portals to ".. dest.. " from ".. currentLoc.. ", "..MageTaxi_PriceBox:GetText().. "g.  ".. MageTaxi_TravelBox:GetText().. "g for me to come to another city."
  2. SendChatMessage(msg, "CHANNEL", nil, trade)

The vision is to add an edit box to the bottom of the GUI. I know in other addons authors used a certain method that I'd like to replicate. The user could do something to the effect of "WTS port to %p from %l" and %p/%l would automatically fill in the selected portal/current location respectively.

I had the idea of trying a gsub swap before printing the message but not sure if that would be the most effective method since I'd have to check the message multiple times to check/change existing/absent variables.
  Reply With Quote