|
| 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 |
|
|
|
| 17 Jul 2015 01:59 PM |
| if msg:lower() == "hello" then |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 17 Jul 2015 02:06 PM |
yes
if msg:lower():sub(1,5) == "hello" then |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Jul 2015 02:09 PM |
yessir
OOOOOOOOOOOOOwait
do this 4 xtra safe
if msg:lower():find("hello") then
|
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 17 Jul 2015 07:02 PM |
if msg:lower():find("hi") == "hi" then --stuff? |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 18 Jul 2015 01:05 AM |
| ^ eh, I don't know why I did sub, just do msg:lower() |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 18 Jul 2015 01:15 AM |
if msg:lower():match("%s+hi%s+") then
|
|
|
| Report Abuse |
|
|
|
| 18 Jul 2015 01:17 AM |
| Chim totally just rekt you all. |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2015 01:23 AM |
| ^ but it still runs if you do "my name is chuck. hi |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2015 01:25 AM |
| Well I must say usually people just use what chim made. |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2015 01:27 AM |
| ^ clarify op, do you want just "hi" or hi surrounded by variable whitespace? |
|
|
| Report Abuse |
|
|
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 |
|
|