generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Roblox » Suggestions & Ideas
Home Search
 

Re: New string manipulation functions. [Lua Update]

Previous Thread :: Next Thread 
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Mar 2012 07:27 AM
string.invert(s)

This will take the string located within the (), and switch the capital letters and lowercase letters. EX:

print(string.invert("Hi Mom!"))

--Prints: hI mOM!



string.explode(s,num)

This is a string function used in several other languages, but sadly not rblx.Lua. Now, what it is, it will take the string located within the (), and "explode" the string, using the second argument. If the second argument is 1, it will explode it by separating all the letters, and returning a table with all the letters. If it is 2, it will explode by separating all the words, by spaces, returning a table with the words. EX:

local explodedString = string.explode("Hello World!", 1)
print(table.concat(explodedString, ' '))

--Prints: H e l l o W o r l d !

local separatedString = string.explode("This is a world with bananas.", 2)
print(table.concat(separatedString, ' ')

--Prints: This is a world with bananas.

print(table.sort(separatedString, 2))

--Prints: bananas. world This is with a




Now, the above will make a lot of processes easier. If you wanted to switch the case, you couldn't, because you can't tell if it's lower or upper. If you wanted to get all the letters in a string into a table, you would have to do this:

local s = "Hello World!"
local letters = {}

for i = 1, string.len(s) do --string.len counts the string
   table.insert(letters, string.sub(s, i, i)
end

print(table.concat(letters, ' '))



If you wanted to get all the WORDS, you would have to do a complex formula to find the positions of each space, and then get the letters within them, which I have tried, and it isn't fun at all. -_-

Anyways, these functions will provide greater ease and more capabilities the scripters of ROBLOX, including me. If you aren't a script and you read this stuff, good job, you deserve an award for listening to all this, whereas if you do script, think about the implements that it can do to your scripts, that use string manipulation.


TL;DR: Let me think.... Nope, too lazy, didn't make TL;DR, go and read it.



Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly-
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Mar 2012 07:35 AM
Bumperoo.

Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly-
Report Abuse
TNTxERIC is not online. TNTxERIC
Joined: 20 Nov 2010
Total Posts: 2689
24 Mar 2012 07:40 AM
Ehh I know how to script (not very well) I can see some uses for this, but it is still kinda pointless also read this: http://www.roblox.com/Forum/ShowPost.aspx?PostID=53952944

-somethimes you feel the urge of a pointless siggy-
Report Abuse
pwnagelord1o1 is not online. pwnagelord1o1
Joined: 07 Jun 2011
Total Posts: 3023
24 Mar 2012 07:43 AM
Can we just wait for the water/string update?

I'M A BRONY AND I'M PROUD
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Mar 2012 07:45 AM
My signature is one line... The TL;DR thing is only there as part of the thread.


@pwnagelord1o1

This is string manipulation in SCRIPTING, not building.

Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly-
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Mar 2012 11:24 AM
Bump.

Noob Virus Download Complete.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Mar 2012 11:29 AM
Erg, so many typos I had made.

Noob Virus Download Complete.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
24 Mar 2012 08:57 PM
Reply people, reply!
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 07:33 AM
WHY DOES NOBODY REPLY?
Report Abuse
vampireninja12 is not online. vampireninja12
Joined: 16 Oct 2010
Total Posts: 230
25 Mar 2012 08:12 AM
this makes my brain hurt... even though I can't script that well, excelent idea!
~vampireninja12 leader of the U.R.R. Deal with it kid.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 08:21 AM
Finally a reply. :D
Report Abuse
court2000 is not online. court2000
Joined: 25 Apr 2010
Total Posts: 3066
25 Mar 2012 09:58 AM
I dont know how to script.
But this is probably a good update!
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 10:09 AM
Bumping the bump.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 01:11 PM
Reply, people, reply!
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 01:16 PM
Just make your own function. These aren't difficult to write at all.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 01:24 PM
Here's the explode one:

    function explode(String, LetWord)
       local toreturn = {}
       for Word in String:gmatch(LetWord == 1 and "%S" or "%S+") do
          table.insert(toreturn, Word)
       end
       return toreturn
    end
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 01:34 PM
The invert one was surprisingly more difficult, but I got it:


    function invert(String)
       local toreturn = ""
       for Pos = 1, #String do
          if String:sub(Pos, Pos):byte() - 65 ​> 25 then
             toreturn = toreturn..String:sub(Pos,Pos):upper()
          else
             toreturn = toreturn..String:sub(Pos, Pos):lower()
          end
       end
       return toreturn
    end
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 01:47 PM
I tested them, they work. This thread is now closed.
Report Abuse
bossofyou30 is not online. bossofyou30
Joined: 24 Dec 2011
Total Posts: 186
25 Mar 2012 09:53 PM
can you plz explain what lua is.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 09:58 PM
@King

Well, when they change from Lua 5.1 to Lua 5.2, they will remove :byte(), causing your switching of the case script to break. D:

So, it can be bumped again.

@Boss
It's a scripting language that runs all the games on ROBLOX. It's what makes your guns shoot, makes the disaster run, makes you reset, makes that zombie follow you etc.

Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly-
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 10:00 PM
Why would they remove :byte()? Where did you hear that they're removing it?
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 10:17 PM
Shedletsky said it, I forgot which forum, let me try and find it...

Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly-
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 10:20 PM
There are workarounds to invert though, but I'm still curious as to why they'd remove string.byte.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
25 Mar 2012 10:23 PM
He said "Bytecode is not compatible across Lua versions."

So... Blame them for changing from 5.1 to 5.2.

Annoying the crap out of you, one word at a time. -Says suoicodilaipxecitsaligirfilacrepus repeatedly-
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
25 Mar 2012 10:26 PM
That's not string.byte. That's that stupid loadstring("\43\0\52\97") stuff.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Roblox » Suggestions & Ideas
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image