diff --git a/fs_initial_config.lua b/fs_initial_config.lua index e2499c9..771d5b1 100644 --- a/fs_initial_config.lua +++ b/fs_initial_config.lua @@ -28,12 +28,20 @@ yl_speak_up.input_fs_initial_config = function(player, formname, fields) end local error_msg = nil + -- remove leading and tailing spaces from the potential new NPC name in order to avoid + -- confusing names where a player's name (or that of another NPC) is beginning/ending + -- with blanks + if(fields.n_npc) then + fields.n_npc = fields.n_npc:match("^%s*(.-)%s*$") + end -- the player is trying to save the initial configuration -- is the player allowed to initialize this npc? if(not(yl_speak_up.may_edit_npc(player, n_id))) then error_msg = "You are not allowed to edit this NPC." elseif(not(fields.n_npc) or string.len(fields.n_npc) < 2) then error_msg = "The name of your NPC needs to be\nat least two characters long." + elseif(minetest.check_player_privs(fields.n_npc, {interact=true})) then + error_msg = "You cannot name your NPC\nafter an existing player." elseif(not(fields.n_description) or string.len(fields.n_description) < 2) then error_msg = "Please provide a description of your NPC!" -- sensible length limit