[Mod] ChatCmdBuilder [0.1.1][chatcmdbuilder] - No regex!

Post Reply
User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

[Mod] ChatCmdBuilder [0.1.1][chatcmdbuilder] - No regex!

by rubenwardy » Post

Easily create complex chat commands with no regex.

Thank you to Sobralia for the inspiration.

License: MIT
Github: https://github.com/rubenwardy/ChatCmdBuilder
Download: https://github.com/rubenwardy/ChatCmdBu ... master.zip

See README.md for more documentation.

Code: Select all

ChatCmdBuilder.new("admin", function(cmd)
	cmd:sub("kill :target", function(name, target)
		local player = minetest.get_player_by_name(target)
		if player then
			player:set_hp(0)
			return true, "Killed " .. target
		else
			return false, "Unable to find " .. target
		end
	end)

	cmd:sub("move :target to :pos:pos", function(name, target, pos)
		local player = minetest.get_player_by_name(target)
		if player then
			player:setpos(pos)
			return true, "Moved " .. target .. " to " .. minetest.pos_to_string(pos)
		else
			return false, "Unable to find " .. target
		end
	end)
end, {
	description = "Admin tools",
	privs = {
		kick = true,
		ban = true
	}
})
A player could then do /admin kill player1 to kill player1, or /admin move player1 to 0,0,0 to teleport a user.
Last edited by rubenwardy on Sun Jul 23, 2017 23:35, edited 3 times in total.

User avatar
ynong123
Member
Posts: 20
Joined: Fri Mar 11, 2016 13:24
GitHub: ynong123
IRC: ynong123
In-game: ynong123
Location: Malaysia

Re: [Mod] ChatCmdBuilder [0.1] - Complex cmds with no regex

by ynong123 » Post

Nice work! I like your mod. I think others will like it too.
Take a look of my mods:
Password Chest
Color Decoration Block
Trapplus

Forgive me for my bad English.

User avatar
SonosFuer
Member
Posts: 104
Joined: Sun Jul 09, 2017 00:32
GitHub: apachano
IRC: SonosFuer
In-game: SonosFuer

Re: [Mod] ChatCmdBuilder [0.1][chatcmdbuilder] - No regex!

by SonosFuer » Post

I think upgrading the chat command api in the engine to include this by default would be cool.
Working on a content database for minetest mods, servers, and etc Check it out and give me feedback at viewtopic.php?f=14&t=18137

User avatar
rubenwardy
Moderator
Posts: 6381
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: [Mod] ChatCmdBuilder [0.1.1][chatcmdbuilder] - No regex!

by rubenwardy » Post

Would be cool! Needs more stability and auto generation of documentation first.

also:

0.1.1 released!

Match command until EOS (fixes /foo bar matching when /foo bar baz is provided)
Fix bug in pattern matching
Fix invalid ChatCmdBuilder call, fix invalid mod name
Add metadata, change license
Make ChatCmdBuilder global
Only run func if func is defined
Allow calling sub after originally creating chatcmd

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests