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: How do you get specific info from a string?

Previous Thread :: Next Thread 
WhoBloxedWho is online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
23 Mar 2012 09:09 PM
Say I had a script that created string values to hold data for a game.

Score:123, Level:9, LastMap:CrossRoads

that sort of thing.


How would I be able to load the players score, level and last map in separate pieces? Say I only needed the score right now sort of thing.





Report Abuse
XhappysmileX is not online. XhappysmileX
Joined: 22 Feb 2009
Total Posts: 124
23 Mar 2012 09:14 PM
Ehh string manipulation...I'm rough at this but I believe this is how (I replaced your colons with slashes as it makes it easier:

local s = [[Score/123/, Level/9/, LastMap/CrossRoads/]]
local t = {}

for value in s:gmathc("(/%w+/)") do
table.insert(t, value)
end

print("Score:"..t[1].." Level:"..t[2].." LastMap:"..t[3])
Report Abuse
WhoBloxedWho is online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
23 Mar 2012 11:26 PM
So what exactly is going on there in the for part?

Report Abuse
WhoBloxedWho is online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
23 Mar 2012 11:27 PM
Or more specifically 's:gmathc("(/%w+/)")'
Report Abuse
WhoBloxedWho is online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
24 Mar 2012 08:56 AM
bump
Report Abuse
DragonFang1 is not online. DragonFang1
Joined: 02 Apr 2009
Total Posts: 1068
24 Mar 2012 09:05 AM
thats over complicating things..

x="Score:123, Level:9, LastMap:CrossRoads"

so you say this is your string ?
colon,_=x:find(":")
comma,__=x:find(",")
score=x:sub(colon+1,comma-1)

so you got your scrore.. and for level and lasmap you could use the same way tell me if you need help with it.
Report Abuse
WhoBloxedWho is online. WhoBloxedWho
Joined: 25 Mar 2009
Total Posts: 4611
24 Mar 2012 10:29 AM
I think I get it. Thanks for the help.
Report Abuse
Athism is not online. Athism
Joined: 05 Jun 2008
Total Posts: 68
24 Mar 2012 10:35 AM
@DragonFang,

Mine was actually simpler because you don't have to continuously look for each value individually.
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