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: Ok, I need an expert scripter for this.... :/

Previous Thread :: Next Thread 
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
18 Jul 2014 04:40 PM
I'm trying to convert a string value that reads "m:ss:msmsms(i.e. 0:23:374)" to a number (by taking out the colons, i.e. 023374). I would THEN like to find the first number, put a colon after it, and then find the third number and put a colon after it. Is this at all possible???
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
18 Jul 2014 04:51 PM
Sure. I'm not sure what the best way to do this is, or if there even is a method that is considered best, but what you would do is some string manipulation. This page will prove useful: http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation
I would take the string and iterate through each character looking for the colon. string.sub creates a substring, so that will be useful for grabbing the individual parts separated by the colons. Then use the concatenation operator on the substrings (..) to combine them.
Report Abuse
super10099 is not online. super10099
Joined: 30 Jan 2010
Total Posts: 1102
18 Jul 2014 04:54 PM
--c:

f = {"0",":","23",":","374"}

for i=1,#f do
if f[i] == ":" then
table.remove(f,i)
end
end
print(table.concat(f))
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
18 Jul 2014 05:38 PM
How can you find where to put the colons when the numbers are printed like "023374"?
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
18 Jul 2014 08:21 PM
1
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
18 Jul 2014 08:24 PM
I could probably do it if I thought for a second, but why in the world would you want to do that? That's like converting 12:30 pm to 1230, which doesn't make sense.
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
18 Jul 2014 08:52 PM
For a DataStore leaderboard.
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
18 Jul 2014 09:18 PM
That's an interesting way to store that.
I assume, since you had to convert it to mm:ss:ms form, that you initially had the seconds that the player was there. Why not store the raw seconds instead and just do the converting when you need to display it?
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
19 Jul 2014 09:06 AM
Because on the DataStore leaderboard script, the score is one value. If I can somehow make three scores for one DataStore, that would be great...
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
19 Jul 2014 09:34 AM
1
Report Abuse
assassincreed722 is not online. assassincreed722
Joined: 20 Mar 2013
Total Posts: 78
19 Jul 2014 09:53 AM
This messed up my brain and i came with the same script as super.
Report Abuse
ohno1112 is not online. ohno1112
Joined: 23 Mar 2013
Total Posts: 833
19 Jul 2014 10:32 AM
i would do only the parsing to 1 value

m:ss:msmsms(i.e. 0:23:374)"

numbers = 0:23:374

stringa = numbers:sub(1,1)

stringb = numbers:sub(3,4)

stringc = numbers:sub(6,8)

string = ""..stringa..stringb..stringc

print(string)

should print 023374
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
19 Jul 2014 10:51 AM
local dostuff=function(string)
local pos={}
for i=1,#string do
if string:sub(i,i)==':' then
string=string:sub(1,i-1)..string:sub(i+1)
pos[#pos+1]=i
end
end
return string,pos
end

local string,tab=dostuff('10:10:10')
print(string,table.concat(tab,', '))


The table stores the positions of the colons. So you could use more string manipulation to insert a
colon to its position, and move everything in front of it over one character.

I'll post a function that does that later after I figure it out.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
19 Jul 2014 12:07 PM
Remove colons - time = time:gsub(":", "");
Add colons - time = time:sub(1, 1) + ":" + time:sub(2, 3) + ":" + time:sub(4);
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
19 Jul 2014 06:25 PM
Thanks, cnt. That's what I was looking for. ;3
Report Abuse
VividNeon is not online. VividNeon
Joined: 24 Apr 2012
Total Posts: 1607
19 Jul 2014 06:26 PM
Thank you all, as well. Everything is much appreciated! ^.^
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