• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua An easy question / message

sestorme

Member
Joined
Dec 9, 2011
Messages
272
Reaction score
6
Location
Birmingham, UK
if(msgcontains(msg, 'xxx'))then

How to change it from contains into exact match?

I looked through other npc scripts, couldn't find anything useful. Thanks.
 
just use
Lua:
if msg == "xxx" then
Just remember that msg is usually converted into all lower case so it will never contain capital letters. So make sure xxx never has capital letters or else they will never be equal.
 
No. What the player says is usually always converted to lower case. You can try it and see but I am 90% sure it does. So if a player says "Hi, my name is Far Carder" it is converted to "hi, my name is far carder".

So if you do this:
Lua:
if "Hi, my name is Far Carder" == "hi, my name is far carder" then
    print("It worked")
else
    print("Didnt work")
end

You will get Didnt work in your console because capital letters are not considered equal to their lower case version.
 
Bogart you miss understood what I ment I am saying that that already happens so the MSG is already converted to lowercase so whatever is put in xxx needs to be in lower case aswell
 
It definatly is case sensitive. I am 100% on that. What I'm not 100% sure on is if jiddos system automatically makes the message parameter lower case or not.
 
It definatly is case sensitive. I am 100% on that. What I'm not 100% sure on is if jiddos system automatically makes the message parameter lower case or not.

data/npc/lib/npc.lua
Lua:
function doMessageCheck(message, keyword)
	if(type(keyword) == "table") then
		return table.isStrIn(keyword, message)
	end

	local a, b = message:lower():find(keyword:lower())
	if(a ~= nil and b ~= nil) then
		return true
	end

	return false
end
msgcontains = doMessageCheck
 
Oh ok so I missunderstood what you said and it doesnt automatically make msg lowercase but Lua is definatly case sensetive and if you use
Lua:
if msg:lower() == 'xXx' then
It will never work since the captial X is different to the lowercase x
 
Oh ok so I missunderstood what you said and it doesnt automatically make msg lowercase but Lua is definatly case sensetive and if you use
Lua:
if msg:lower() == 'xXx' then
It will never work since the captial X is different to the lowercase x

It actually converts both to lowercase for example "if msg = 'XXX'" == "if msg:lower() == 'xxx'"
 
only if you use
Lua:
if msgContains(msg, "HI") then
...
but he wants to use it to make the msg is exactly the same so just
Lua:
if msg == "hi" then
...
so that only hi works and not hi there NPC which would work in the first one
 
Back
Top