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: help?

Previous Thread :: Next Thread 
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 01:57 PM
Is there a way to make a script read words no matter what letters are in caps.

Something like this:
if msg == 'Hello' then
end

But it can read: hello, HELLO, Hello. ect?

Without doing this:

if msg == 'Hello' or msg == 'hello' or msg == 'HELLO' then
end
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 01:59 PM
if msg:lower() == "hello" then
Report Abuse
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 02:02 PM
Thank you!
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:03 PM
yep
Report Abuse
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 02:05 PM
I am going to guess and say there isn't a way to make it so it doesn't matter if you put a . or not.
Report Abuse
Burglered is not online. Burglered
Joined: 14 Jul 2011
Total Posts: 962
17 Jul 2015 02:05 PM
i was about to say toUpperCase but that's JavaScript haha. I haven't done lua in a while :/

BCGames.dll is missing. Report to info@roblox.com for help.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:06 PM
yes

if msg:lower():sub(1,5) == "hello" then
Report Abuse
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 02:08 PM
O_o Thank you so much! :D
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 02:09 PM
yessir

OOOOOOOOOOOOOwait

do this 4 xtra safe

if msg:lower():find("hello") then
Report Abuse
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 02:10 PM
Ok. :)
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
17 Jul 2015 02:23 PM
no no no, abstract you're doing it way too simply. it should be done like this

-- if msg:lower():find("hello") then

for word in string.gmatch( msg, "%w+" ) do
word = word or word:lower( )
if word then
-- do something
break
end
end
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
17 Jul 2015 02:23 PM
no no no, abstract you're doing it way too simply. it should be done like this

for word in string.gmatch( msg, "%w+" ) do
word = word or word:lower( )
if word and word == [[hello]] then
-- do something
break
end
end
Report Abuse
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 06:58 PM
Is there anyway to fix this:

if message:lower():find('hi') then
end

When I type something like, "this," it still runs. Is there a way to fix that?
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
17 Jul 2015 07:02 PM
if msg:lower():find("hi") == "hi" then
--stuff?
Report Abuse
AustinNally is not online. AustinNally
Joined: 18 Dec 2012
Total Posts: 163
17 Jul 2015 07:09 PM
Still does it.

How about...

local letters = {q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m}

and it wont allow those letters around it. <-- Idk, im still a noob to scripting
Report Abuse
Burglered is not online. Burglered
Joined: 14 Jul 2011
Total Posts: 962
17 Jul 2015 11:40 PM


game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
local message = msg:lower():find('hi');
if message == true then
print('No error!');
elseif message == false then
print('Error!');
end)
end)



BCGames.dll is missing. Report to info@roblox.com for help.
Report Abuse
Burglered is not online. Burglered
Joined: 14 Jul 2011
Total Posts: 962
17 Jul 2015 11:41 PM
I forgot an end

BCGames.dll is missing. Report to info@roblox.com for help.
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 01:04 AM
^ I think he means though that the text "hi" is still being found inside of "this", and he just wants it to work for "hi". If that's the case he can just go back to the following:

if msg:lower():sub( 1, string.len( "hi" ) ) == "hi" then --[[ stuff ]]-- end
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 01:05 AM
^ eh, I don't know why I did sub, just do msg:lower()
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jul 2015 01:15 AM
if msg:lower():match("%s+hi%s+") then
Report Abuse
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
18 Jul 2015 01:17 AM
Chim totally just rekt you all.
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 01:23 AM
^ but it still runs if you do "my name is chuck. hi
Report Abuse
ImperialOutcast is not online. ImperialOutcast
Joined: 24 Nov 2009
Total Posts: 12054
18 Jul 2015 01:25 AM
Well I must say usually people just use what chim made.
Report Abuse
PearSprite is not online. PearSprite
Joined: 02 Jul 2015
Total Posts: 230
18 Jul 2015 01:27 AM
^ clarify op, do you want just "hi" or hi surrounded by variable whitespace?
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
18 Jul 2015 01:30 AM
Mine matches hi with blank space on both sides of it.

Test if you want.
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