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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 24 Mar 2012 11:24 AM |
Bump.
Noob Virus Download Complete. |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
| |
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
| |
|
|
| 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
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
| |
|
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
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
| |
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
| |
|
|
| 25 Mar 2012 01:16 PM |
| Just make your own function. These aren't difficult to write at all. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 25 Mar 2012 01:47 PM |
| I tested them, they work. This thread is now closed. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 09:53 PM |
| can you plz explain what lua is. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 25 Mar 2012 10:00 PM |
| Why would they remove :byte()? Where did you hear that they're removing it? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 25 Mar 2012 10:26 PM |
| That's not string.byte. That's that stupid loadstring("\43\0\52\97") stuff. |
|
|
| Report Abuse |
|
|