split

API -

function yourEvent(user, string_message)

    local words = helper.split(string_message, ' '); 
    --this is extremely helpful for bots that are trying to read commands!
    --split the message on spaces to get words in an array
    
    --check the first word
    if words[1] ~= '!yourCommand' then --in LUA... arrays start at index 1, not 0!
        
        --if word[1] is not equal to your command, exit.
        yieldBreak();
    end
    
    if words[2] == 'start' then
        log('the user has typed: !yourCommand start');
    end
end

return function()
    addEvent('chatMessage', 'yourEvent'); --attaches the event to yourEvent()
    keepAlive();
end

Last updated