Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a chat command to execute a chat command multiple times #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ minetest.register_chatcommand("run_as", {
end,
})

minetest.register_chatcommand("repeat", {
params = "<repetitions> /<command>",
description = "Run a chatcommand multiple times",
func = function(name, param)
local repetitions, msg = param:match"^([0-9]+) *(/.*)"
if not repetitions then
return false, "Invalid arguments (see /help run_as)."
end
repetitions = tonumber(repetitions)
if repetitions > 5
and not minetest.check_player_privs(name, "server") then
return false,
"More than 5 repetitions require the server privilege."
end
for _ = 1, repetitions do
execute_chatcommand(name, msg)
end
end,
})

minetest.register_chatcommand("grantme", {
params = "<privilege>|all",
description = "Give privilege to yourself",
Expand Down