mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-08-20 21:44:06 +02:00
//multi: reduce code duplication
This commit is contained in:
parent
87b7254350
commit
e111decd3a
@ -26,11 +26,6 @@ local function explode(delim, str)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- From http://lua-users.org/wiki/StringTrim
|
|
||||||
local function trim(s)
|
|
||||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_chatcommand("/multi", {
|
minetest.register_chatcommand("/multi", {
|
||||||
params = "/<command_a> <args> //<command_b> <args> /<command_c> <args>.....",
|
params = "/<command_a> <args> //<command_b> <args> /<command_c> <args>.....",
|
||||||
description = "Executes multiple chat commands in sequence. Just prepend a list of space-separated chat commands with //multi, and you're good to go! The forward slashes at the beginning of each chat command must be the same as if you were executing it normally.",
|
description = "Executes multiple chat commands in sequence. Just prepend a list of space-separated chat commands with //multi, and you're good to go! The forward slashes at the beginning of each chat command must be the same as if you were executing it normally.",
|
||||||
@ -50,7 +45,7 @@ minetest.register_chatcommand("/multi", {
|
|||||||
local start_time = worldeditadditions.get_ms_time()
|
local start_time = worldeditadditions.get_ms_time()
|
||||||
local found, _, command_name, args = command:find("^([^%s]+)%s(.+)$")
|
local found, _, command_name, args = command:find("^([^%s]+)%s(.+)$")
|
||||||
if not found then command_name = command end
|
if not found then command_name = command end
|
||||||
command_name = trim(command_name)
|
command_name = worldeditadditions.trim(command_name)
|
||||||
if not args then args = "" end
|
if not args then args = "" end
|
||||||
|
|
||||||
worldedit.player_notify(name, "#"..i..": /"..command)
|
worldedit.player_notify(name, "#"..i..": /"..command)
|
||||||
|
Loading…
Reference in New Issue
Block a user