QUOTE (Alascia @ Nov 5 2009, 12:40 PM)

I can't for the life of me figure out how to get string.gsub to work.
I made this alias to test:
http://alascia.pastebin.com/m138794and all it's doing is returning Broken every time, the variable is never getting changed.
Any help at all please? Have I got this completely wrong?
No one on the clan has had an answer to this all day.
mystring = "I am the greatest person here"
mystring = string.gsub(mystring, "greatest", "worst")
Note(mystring)
Output:
I am the worst person here.
or
mystring = mystring:gsub("greatest", "worst")
does the same thing.
The function takes the arguments string, pattern, replacewith, and times to replace.
the string is what you want to be replaces, the pattern is what you want to be replaces (can be a lua regexp), replacewith is the value you want to be substituted in everytime the pattern matches something in the string. The the times to replace will limit the number of times the replacement will happen.
However, I think you understand that. Your problem is that when you call the string.gsub() you aren't telling it to store the returned value to anything, so it just dumps it somewhere. This is because it behaves more like a normal function than the built in MUSH functions like Note() or SetVariable() (not to say those aren't perfectly legitimate functions, just that they work a little differently). The string.gsub() returns the string that it makes after the substitution. So it would have to be:
SetVariable("testingsub", subtest:gsub("broken", "working"))
or using lua variables:
subtest = subtest:gsub("broken", "working")
You might also want to make sure the capitalization is matching up correctly. I would also recommend just using internal lua variables to test things and not fumbling around trying to convert mush variables to lua. It's much easier (in my opinion).