01-13-2005, 03:40 AM
Here's a list of the potentially available Blizzard designed global functions: wow wikki.
The general math, string, and table functions from LUA script API should be usable.
For string manipulation, try the following functions:
strchar(string,charindex)
example: strchar("1234567",6) == "7"
strfind(string,searchval,startindex)
example: strfind("abcdefcd","cd", 5) == 6
strlen(string)
example: strlen("1234567") == 7
strlower(string)
example: strlower("MyMixedCase") == "mymixedcase"
strsub(string, beginindex, endindex)
example: strsub("abcDef",2,4) == "cD"
strupper(string)
example: strupper("mYmiXEDcase") == "MYMIXEDCASE"
-------------
after you get the basic lua script infrastructre in (see the walkthrough stickied on the official UI forum), add the following function to barebones script.
then from chat type:
"/script reverse(Hello World!)"
You could also add a slashcommand handler so it could be "/reverse Hello World!".
(still stuck at work)
The general math, string, and table functions from LUA script API should be usable.
For string manipulation, try the following functions:
strchar(string,charindex)
example: strchar("1234567",6) == "7"
strfind(string,searchval,startindex)
example: strfind("abcdefcd","cd", 5) == 6
strlen(string)
example: strlen("1234567") == 7
strlower(string)
example: strlower("MyMixedCase") == "mymixedcase"
strsub(string, beginindex, endindex)
example: strsub("abcDef",2,4) == "cD"
strupper(string)
example: strupper("mYmiXEDcase") == "MYMIXEDCASE"
-------------
after you get the basic lua script infrastructre in (see the walkthrough stickied on the official UI forum), add the following function to barebones script.
Code:
function reverse(msg)
myLength = strlen(msg);
myString = "";
myChar = "";
myCounter = 0;
if (msg) then
-- fill myString with reversed text from the input msg
for myCounter = 1, myLength do
myChar = strsub(msg, (myLength - myCounter), (myLength - myCounter + 1));
myString = (myString .. myChar);
end
end
ChatFrame:AddMessage("the reverse of your message is: " .. myString);
return( myString );
end
then from chat type:
"/script reverse(Hello World!)"
You could also add a slashcommand handler so it could be "/reverse Hello World!".
Code:
local function mySlashCommandHandler(msg)
if (msg) then
reverse(msg);
else
ChatFrame:AddMessage("correct use: /reverse YourTextHere");
end
end