From a900fd834c1fde07726d0bb18aa982587a35c827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20P=C3=A9rez-Cerezo?= Date: Sun, 29 Mar 2020 20:24:27 +0200 Subject: Use space instead of comma as an argument separator --- init.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index efac9f3..29507aa 100644 --- a/init.lua +++ b/init.lua @@ -38,7 +38,7 @@ local whisper_color = "#aaaaaa" -- Whisper color override -- ${message} the actual message that is to be sent -- ${time} the current time in 24 hour format, as returned from os.date("%X") -- -local channel_invitation_string = "|#${channel_name}| Channel invite from (${from_player}), to join the channel, do /jc ${channel_name},${channel_password} after which you can send messages to the channel via #${channel_name}: message" +local channel_invitation_string = "|#${channel_name}| Channel invite from (${from_player}), to join the channel, do /jc ${channel_name} ${channel_password} after which you can send messages to the channel via #${channel_name}: message" local channel_invited_string = "|#${channel_name}| Invite sent to ${to_player}" local channel_created_string = "|#${channel_name}| Channel created" local channel_deleted_string = "|#${channel_name}| Channel deleted" @@ -123,10 +123,9 @@ minetest.register_on_leaveplayer(function(player) end) local create_channel = { - params = ",,", + params = " ", description = "Create a channel named with optional and hexadecimal ".. - "starting with # (e.g. #00ff00 for green). Use comma's to separate the arguments, e.g. ".. - "/cc my secret channel,#0000ff for a blue colored my secret channel without password", + "starting with # (e.g. #00ff00 for green). Use spaces to separate the arguments." func = function(lname, param) local lowner = lname @@ -134,9 +133,9 @@ local create_channel = { return false, "ERROR: Invalid number of arguments. Please supply the channel name as a minimum" end - local str = string.split(param, ",") + local str = string.split(param, " ") if #str > 3 then - return false, "ERROR: Invalid number of arguments. 4 parameters passed, maximum of 3 allowed: ,," + return false, "ERROR: Invalid number of arguments. 4 parameters passed, maximum of 3 allowed: " end local lchannel_name = string.trim(str[1]) @@ -247,14 +246,14 @@ local my_channels = { } local join_channel = { - params = ",", + params = " ", description = "Join channel named . After joining you will see messages sent to that channel (in addition to the other channels you have joined)", func = function(name, param) if not param or param == "" then return false, "ERROR: Invalid number of arguments. Please supply the channel name as a minimum" end - local str = string.split(param, ",") + local str = string.split(param, " ") local channel_name = str[1] if not channels[channel_name] then @@ -267,7 +266,7 @@ local join_channel = { if channels[channel_name].password and channels[channel_name].password ~= "" then if #str == 1 then - return false, "ERROR: This channel requires that you supply a password. Supply it in the following format: /jc my channel,password01" + return false, "ERROR: This channel requires that you supply a password. Supply it in the following format: /jc my channel password01" end if str[2] ~= channels[channel_name].password then return false, "ERROR: Invalid password" @@ -318,7 +317,7 @@ local leave_channel = { } local invite_channel = { - params = ",", + params = " ", description = "Invite player named to channel named . You must be the owner of the channel in order to do invites", func = function(name, param) local owner = name @@ -327,7 +326,7 @@ local invite_channel = { return false, "ERROR: Invalid number of arguments. Please supply the channel name and the player name" end - local channel_name, player_name = string.match(param, "(.*),(.*)") + local channel_name, player_name = string.match(param, "(%S+)%s+(.*)") if not channel_name or channel_name == "" then return false, "ERROR: Channel name is empty" -- cgit v1.2.3