quote:
Originally posted by Mattike
Aaah... here's where regular expressions can help.
I'll try to simplify it for you, since I guess you've never worked with those.code:
//Register our command
function OnGetScriptCommands() {
...
}
OnGetScriptCommands has got absolutely nothing todo with "registering" a command and is absolutely not needed.
A command is reconized as a command of your script ONLY if you handle it in the ChatWndSendMessage event and return an empty string.
If you do not return an empty string the command line is passed further to other scripts and eventually to Plus! itself. Though this returning of something or an empty string is not mandatory and you can still perfectly 'react' on something the user has typed.
So...
quote:
Originally posted by Mattike
//An example function. Note that you always have to return something to be sent as replacement for the original message.
No you don't. This only depends on what you wanna do and is not mandatory for handling commands (though it is recommended and the 'right' thing todo).
quote:
Originally posted by Mattike
Note: this code is not tested. It's possible that something wasn't noticed while I reviewed my post. If so, please let me know (or you can try to fix it yourself of course)!
For stuff like this always test the code yourself first (and verify the things you claim are correct like "
OnGetScriptCommands registers our command").