rubenwardy
Moderator
Posts: 6381 Joined: Tue Jun 12, 2012 18:11
GitHub:
rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:
by rubenwardy » Mon Jun 13, 2016 21:09
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.
ynong123
Member
Posts: 20 Joined: Fri Mar 11, 2016 13:24
GitHub:
ynong123
IRC: ynong123
In-game: ynong123
Location: Malaysia
by ynong123 » Sun Jul 17, 2016 00:32
Post
Nice work! I like your mod. I think others will like it too.
SonosFuer
Member
Posts: 104 Joined: Sun Jul 09, 2017 00:32
GitHub:
apachano
IRC: SonosFuer
In-game: SonosFuer
by SonosFuer » Sun Jul 23, 2017 23:21
Post
I think upgrading the chat command api in the engine to include this by default would be cool.
rubenwardy
Moderator
Posts: 6381 Joined: Tue Jun 12, 2012 18:11
GitHub:
rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:
by rubenwardy » Sun Jul 23, 2017 23:39
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
Users browsing this forum: Bing [Bot] and 3 guests