Chatcommand Library by LMD

Making chatcommands a pleasure to use.

69 downloads

Chatcommand Library (cmdlib)

Making chatcommands a pleasure to use.

About

Adds a few features to chatcommands useful for devs (parsing, trees, forbidden privs, etc), and other features useful for players, such as suggestions, command trees, and a better help command.

Note : Overrides /help chatcommand and builtin functions (minetest.register_chatcommand), replaces chatcommand handler.

Depends on modlib. IntelliJ IDEA with EmmyLua plugin project. Code & media by Lars Mueller aka LMD or appguru(eu). Licensed under GPLv3.

Screenshot

Screenshot

API

A few API methods are listed below. Browse the code for more. Three parts are provided by cmdlib :

cmd_ext.register(name, def)

Name (name) : Chatcommand name, including whitespaces (such as mod command)

Definition (def) : Table with entries params, custom_syntax, implicit_call, description, privs, and func

trie.new()

Creates (returns) a new trie (empty table).

trie.insert(trie, word, [value], [overwrite])

Inserts a word into a trie. value is optional (defaults to true). overwrite is optional as well and defaults to false. Returns previous value.

trie.remove(trie, word)

Removes word from trie. Returns previous value.

trie.get(trie, word)

Check if trie contains word and return corresponding value, or nil.

trie.search(trie, word)

Search for word in trie. Return value if found, else (nil, closest word, value) or nil if no closest word exists.

Invocation

Invoke a chatcommand by giving the params separated by whitespaces (like /cmd subcmd param1 param2).

Help

Use /help [query] to open the extremely useful formspec shown above.