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 » Game Creation and Development » Scripting Helpers
Home Search
 

Re: String Manipulation V2

Previous Thread :: Next Thread 
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 04:03 PM
ok if I have basePart1,2 or basePart429,135316 or anything like that how would I isolate just the coordinates after so like

basePart1,2
>1,2

or

basePart429,135316
>429,135316

notice there is no space in the string or anything

thanks in advance
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
01 Mar 2014 04:11 PM
This should work.

a = "basePart429,135316"
function findChar(a, pos)
for i = pos, 0, -1 do
if not tonumber(a:sub(i, i)) then
return i+1
end
end
end
local comma = a:find(",")
print(a:sub(findChar(a, comma), comma-1))
print(a:sub( comma))
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 04:27 PM
I changed all a's to the variable word because I already have an a xD but heres what happens when I try it:

word="basePart1632,13136"
function findChar(word, pos)
for i = pos, 0, -1 do
if not tonumber(word:sub(i, i)) then
return i+1
end
end
end
local comma = word:find(",")
print(word:sub(findChar(word, comma), comma-1))
print(word:sub( comma))

>
>,13136

I want it to print 1632,13136
also the first print shows up blank...
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 04:36 PM
bump
Report Abuse
Disti15 is not online. Disti15
Joined: 04 Sep 2009
Total Posts: 2652
01 Mar 2014 05:12 PM
name = basePart429,135316
name = string.sub(name, 9, string.len(name))
print(name)
Report Abuse
Disti15 is not online. Disti15
Joined: 04 Sep 2009
Total Posts: 2652
01 Mar 2014 05:13 PM
name = "basePart429,135316"

forgot that, sorry.
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 05:21 PM
k thanks, one more xD
say I have like 20 different numbers here, so 1,1:316.2,2:31513.2,3:42698246

(not really going to be 20 but as many as I need, I need to compact data store lol)

how would I make it so it returns
a>1,1
b>316

a>2,2
b>31513

a>2,3
b>42698246

for each one? You can change the symbols that are commas, numbers, and periods, but the .s represent different "ab" sets
Report Abuse
Disti15 is not online. Disti15
Joined: 04 Sep 2009
Total Posts: 2652
01 Mar 2014 05:25 PM
ls = 1
n = 1
data = "1,1:316.2,2:31513.2,3:42698246"
for i = 1, string.len(data) do
if string.sub(data, i, i) == ":" then
print("a"..n..":"..string.sub(data, ls, i-1))
ls = i+1
elseif string.sub(data, i, i) == "." then
print("b"..n..":"..string.sub(data, ls, i-1))
ls = i+1
n = n+1
end
end

There you go.
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 05:29 PM
why doesnt it print b3?
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 05:30 PM
and thanks for the help
Report Abuse
Voidition is not online. Voidition
Joined: 14 Jul 2012
Total Posts: 1849
01 Mar 2014 05:30 PM
[ Content Deleted ]
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 05:33 PM
I am not ripping off minecraft... this has nothing to do with minecraft
Report Abuse
Disti15 is not online. Disti15
Joined: 04 Sep 2009
Total Posts: 2652
01 Mar 2014 05:34 PM
Ooops, sorry, there you go:

ls = 1
n = 1
data = "1,1:316.2,2:31513.2,3:42698246"

for i = 1, string.len(data) do
if string.sub(data, i, i) == ":" then
print("a"..n..":"..string.sub(data, ls, i-1))
ls = i+1
elseif string.sub(data, i, i) == "." then
print("b"..n..":"..string.sub(data, ls, i-1))
ls = i+1
n = n+1
elseif i == string.len(data) then
print("b"..n..":"..string.sub(data, ls, i))
end
end
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 05:35 PM
lol no need to say sorry, I should be saying sorry for being too stupid to be able to understand the wiki page on string manipulation
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
01 Mar 2014 05:42 PM
local brick = "brick2203939"

for i in string.gmatch(brick, "%d*") do
print(i)
end
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
01 Mar 2014 05:46 PM
^ Problem being he has commas =P.
Report Abuse
dave2011 is not online. dave2011
Joined: 02 Oct 2010
Total Posts: 10581
01 Mar 2014 05:47 PM
*sees dominus*
*eats it*
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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