Added licence and /msg command.
parent
cda8a7545b
commit
8646940e06
|
@ -0,0 +1,26 @@
|
|||
Copyright (c) 2012, Teodor Spæren
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
11
conf.lua
11
conf.lua
|
@ -1,10 +1,17 @@
|
|||
-- Care about small and BIG letters?
|
||||
careLetters = true
|
||||
|
||||
-- List command
|
||||
useList = true
|
||||
listprivs = {shout=true}
|
||||
listprivs = {shout = true}
|
||||
|
||||
-- Kill command
|
||||
useKill = true
|
||||
killprivs = {shout=true}
|
||||
killprivs = {shout = true}
|
||||
|
||||
-- MSG command
|
||||
useMSG = true
|
||||
msgprivs = {shout = true}
|
||||
|
||||
--MOTD
|
||||
useMOTD = true
|
||||
|
|
42
init.lua
42
init.lua
|
@ -7,15 +7,25 @@ function get_player_obj (name)
|
|||
goodname = string.match(name, "^([^ ]+) *$")
|
||||
if goodname == nil then
|
||||
print("ERROR!")
|
||||
return
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Looping trough all the players currently online
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local name = player:get_player_name()
|
||||
|
||||
-- Caring about letters or not?
|
||||
if not careLetters then
|
||||
if string.lower(name) == string.lower(goodname) then
|
||||
return player
|
||||
end
|
||||
else
|
||||
if name == goodname then
|
||||
return player
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- !!! COMMANDS !!! ---
|
||||
|
@ -51,6 +61,34 @@ if useKill then
|
|||
end,
|
||||
})
|
||||
end
|
||||
|
||||
--[[ MSG command ]]---
|
||||
if useMSG then
|
||||
minetest.register_chatcommand("msg", {
|
||||
params = "<target> <text>",
|
||||
description = "Talk to someone!",
|
||||
privs = msgprivs,
|
||||
func = function(name, param)
|
||||
if string.match(param, "([^ ]+) (.+)") == nil then
|
||||
minetest.chat_send_player(name, "Missing parameters")
|
||||
return
|
||||
end
|
||||
|
||||
-- Generating the variables out of the parameters
|
||||
local targetName, msg = string.match(param, "([^ ]+) (.+)")
|
||||
target = get_player_obj(targetName)
|
||||
|
||||
-- Checking if the target exists
|
||||
if not target then
|
||||
minetest.chat_send_player(name, "The target was not found")
|
||||
return
|
||||
end
|
||||
|
||||
-- Sending the message
|
||||
minetest.chat_send_player(target:get_player_name(), string.format("From %s: %s", name, msg))
|
||||
end,
|
||||
})
|
||||
end
|
||||
-- !!! EVENTS !!! --
|
||||
|
||||
--[[ What happens when a player joins? ]]--
|
||||
|
|
Loading…
Reference in New Issue