How far (if at all) can you script things?
#1
Say, for instance... is it possible to parse a string and have a script reverse the order of the letters? I know, this is hardly placed in the useful-stuff category of utilities, but would it be possible?

ie, "/reverse Hello world!" would end up as "!dlrow olleH"

I heard and read a little about ui customization and scripting but would this be possible?

If it would be possible, that'd be ... :shuriken:

Alrin, lurking away until Wow EU retail release :whistling:
[Image: 104024yQmrG.png][Image: 201194cOrXg.png]
Reply
#2
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.

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
(still stuck at work)
Reply
#3
*surfer voice*

Whoooahhh duuuuude. :blink:

Faaar out, man!

Thanks a million. Let's hope wow will allow this kind of scripting.

Cheers, thanks.
[Image: 104024yQmrG.png][Image: 201194cOrXg.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)