Thread Tools Display Modes
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
12-28-10, 11:08 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by ChaosInc View Post
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.
I think a massive gsub swap is the only way .. for stuff like replacing "%p", etc

I'm doing it myself like 30/40 times in a function in 1 of my addons; it looked quite dirty ><
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help needed for custom messages containing existing variables?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off