• 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 Jiddo's NPC System: FocusModule.messageMatcher(keywords, message)

Status
Not open for further replies.

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,892
Solutions
5
Reaction score
858
Could someone explain me how does this function work:
PHP:
function FocusModule.messageMatcher(keywords, message)

Here's the entire function in LUA:
PHP:
function FocusModule.messageMatcher(keywords, message)
		for i, word in pairs(keywords) do
			if(type(word) == 'string') then
				if string.find(message, word) and not string.find(message, '[%w+]' .. word) and not string.find(message, word .. '[%w+]') then
					return true
				end
			end
		end
		return false
	end

I've tried using it for different greeting keywords in a NPC script, this way; but it didn't work:
PHP:
FocusModule.messageMatcher(FOCUS_GREETWORDS, "charach")

The NPC would ignore word 'charach' and would respond to default greet words (hello, hi, greetings)

Or.. Is there any other way to change the default greet keywords? Maybe by using a callback ;D?
Rep+ for helping me...
 
Status
Not open for further replies.
Back
Top