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 » Scripters
Home Search
 

Re: quick string.sub question

Previous Thread :: Next Thread 
expoundings is online. expoundings
Joined: 02 Feb 2013
Total Posts: 2359
11 Oct 2015 05:28 PM
i want to use string.sub for when a player chats "computer start"
how would i do that with the space in the message?
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 05:29 PM
if msg:sub(1, 14) == "computer start" then

-The [Guy]
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Oct 2015 05:33 PM
if msg:match("^computer start") then


Red Blossoms
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 05:34 PM
"i want to use string.sub"

sub ~= match

-The [Guy]
Report Abuse
DermonDarble is not online. DermonDarble
Joined: 04 Jun 2015
Total Posts: 2576
11 Oct 2015 05:34 PM
match > sub :(

have a kawaii face ~ (✿◠‿◠)
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Oct 2015 05:35 PM
It's a much better solution considering you'd have to count the amount of characters (or do #str, but you then you waste more energy doing that)


Red Blossoms
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 05:38 PM
Yes. As long as OP understands the difference that it could be anywhere in the message with match as opposed to the message being exactly that text with sub.

-The [Guy]
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Oct 2015 05:39 PM
I put an anchor to the beginning, idiot

Red Blossoms
Report Abuse
Rocky28447 is online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
11 Oct 2015 05:43 PM
if msg.lower:sub(1, 14) == "computer start" then

Wouldn't that be better in case they type "comPuter start" or something?


choo choo
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 05:50 PM
msg:lower():sub(1, 14) is what you mean

-The [Guy]
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
11 Oct 2015 05:51 PM
@Rayk Sorry I'm not an expert in string manipulation, I didn't know what ^ meant off the top of my head.

-The [Guy]
Report Abuse
Dralian is not online. Dralian
Joined: 21 Mar 2013
Total Posts: 7624
11 Oct 2015 06:06 PM
oo..
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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