From 5dd4000034004c3ca792587e24554891351207e9 Mon Sep 17 00:00:00 2001 From: Brett O'Donnell Date: Fri, 9 Nov 2012 00:33:51 +1030 Subject: [PATCH] added redsand http://minetest.net/forum/viewtopic.php?id=3412 --- mods/redsand/.gitignore | 163 +++++++++++++++++++++++++++++++++++++ mods/redsand/LICENSE.txt | 26 ++++++ mods/redsand/README.txt | 27 ++++++ mods/redsand/conf.lua | 29 +++++++ mods/redsand/depends.txt | 1 + mods/redsand/events.lua | 29 +++++++ mods/redsand/functions.lua | 26 ++++++ mods/redsand/general.lua | 33 ++++++++ mods/redsand/init.lua | 11 +++ mods/redsand/messages.lua | 55 +++++++++++++ 10 files changed, 400 insertions(+) create mode 100644 mods/redsand/.gitignore create mode 100644 mods/redsand/LICENSE.txt create mode 100644 mods/redsand/README.txt create mode 100644 mods/redsand/conf.lua create mode 100644 mods/redsand/depends.txt create mode 100644 mods/redsand/events.lua create mode 100644 mods/redsand/functions.lua create mode 100644 mods/redsand/general.lua create mode 100644 mods/redsand/init.lua create mode 100644 mods/redsand/messages.lua diff --git a/mods/redsand/.gitignore b/mods/redsand/.gitignore new file mode 100644 index 0000000..5ebd21a --- /dev/null +++ b/mods/redsand/.gitignore @@ -0,0 +1,163 @@ +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.vspscc +.builds +*.dotCover + +## TODO: If you have NuGet Package Restore enabled, uncomment this +#packages/ + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp + +# ReSharper is a .NET coding add-in +_ReSharper* + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Others +[Bb]in +[Oo]bj +sql +TestResults +*.Cache +ClientBin +stylecop.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + + + +############ +## Windows +############ + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg + +# Mac crap +.DS_Store diff --git a/mods/redsand/LICENSE.txt b/mods/redsand/LICENSE.txt new file mode 100644 index 0000000..8f7c046 --- /dev/null +++ b/mods/redsand/LICENSE.txt @@ -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. \ No newline at end of file diff --git a/mods/redsand/README.txt b/mods/redsand/README.txt new file mode 100644 index 0000000..ed992f3 --- /dev/null +++ b/mods/redsand/README.txt @@ -0,0 +1,27 @@ +ABOUT +====== +Redsand is a collection of utilites for servers. It is not aimed at adding new blocks to the game, +but rather add more chat commands and so on. + +Another goal is to activly develope a configuration file. + +This is a version is made by Teodor Spæren ( TheRedMood ) +==== +FEATURES +==== +- Event messages( Respawn, death...) +- MOTD +- Commands like /msg, /list... +- A lot of config options. + +COMMANDS +======== +/list - List out the players on the server. +/kill - Lower your health to 0. +/msg - Talk to someone. +/reply - Reply to the last person who talked to you. + +=== +LICENCE +=== +READ LICENCE.txt now! \ No newline at end of file diff --git a/mods/redsand/conf.lua b/mods/redsand/conf.lua new file mode 100644 index 0000000..3d1888c --- /dev/null +++ b/mods/redsand/conf.lua @@ -0,0 +1,29 @@ +--[[ What do you want to be loaded? ]]-- +useList = true -- List command +useMSG = true -- Message command +useKill = true -- Kill command +useReply = true -- Reply command + +useMOTD = true -- Message of the day +useDeathMSG = true -- Death messages +useReviveMSG = true -- Revive messages + +--[[ GLOBAL OPTIONS ]]-- +careLetters = true -- Care about small and BIG letters? + +--[[ Privleges ]]-- +listprivs = {shout = true} -- List privleges +killprivs = {shout = true} -- kill privleges +msgprivs = {shout = true} -- message privleges +replyprivs = {shout = true} -- reply privleges + +--[[ Message strings ]]-- +MOTD = "Welcome %s! This is the default MOTD." -- Message of the day +DEATH_MSG = "%s left this world :(" -- Death message +REVIVE_MSG = "Like a Phoenix %s rises from the ashes." -- Revive message + +--[[ What do you want after the / ]]-- +listcmd = "list" +msgcmd = "msg" +killcmd = "kill" +replycmd = "reply" diff --git a/mods/redsand/depends.txt b/mods/redsand/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/redsand/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/redsand/events.lua b/mods/redsand/events.lua new file mode 100644 index 0000000..217f7df --- /dev/null +++ b/mods/redsand/events.lua @@ -0,0 +1,29 @@ +--[[ + All code that is triggered when an event happens should reside + here :D +]]-- + +-- !!! EVENTS !!! -- + +--[[ What happens when a player joins? ]]-- +if useMOTD then + minetest.register_on_joinplayer( function(player) + minetest.after( 2.0, function(param) + minetest.chat_send_player(player:get_player_name(), string.format(MOTD, player:get_player_name())) + end ) + end ) +end + +--[[ What happens when a player die? ]]-- +if useDeathMSG then + minetest.register_on_dieplayer( function(player) + minetest.chat_send_all(string.format(DEATH_MSG, player:get_player_name())) + end ) +end + +--[[ What happens when a player respawn ]]-- +if useReviveMSG then + minetest.register_on_respawnplayer( function(player) + minetest.chat_send_all(string.format(REVIVE_MSG, player:get_player_name())) + end ) +end diff --git a/mods/redsand/functions.lua b/mods/redsand/functions.lua new file mode 100644 index 0000000..5495cec --- /dev/null +++ b/mods/redsand/functions.lua @@ -0,0 +1,26 @@ +-- !!! FUNCTIONS !!! -- +-- Getting the player object. +function get_player_obj (name) + goodname = string.match(name, "^([^ ]+) *$") + if goodname == nil then + print("ERROR!") + 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() + + -- 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 \ No newline at end of file diff --git a/mods/redsand/general.lua b/mods/redsand/general.lua new file mode 100644 index 0000000..574e6c9 --- /dev/null +++ b/mods/redsand/general.lua @@ -0,0 +1,33 @@ +--[[ Single functions or non set commands should go in here ]]-- + +-- !!! COMMANDS !!! -- +--[[ List function. ]]-- +if useList then + minetest.register_chatcommand(listcmd, { + params = "", -- short parameter description + description = "List connected players", -- full description + privs = listprivs, -- require the "privs" privilege to run + func = function(name, param) + local namelist, count = "", 0 + for _,player in ipairs(minetest.get_connected_players()) do + local name = player:get_player_name() + namelist = namelist .. string.format("%s, ", name) + count = count + 1 + end + minetest.chat_send_player(name, string.format("\nCurrent players online: %d\nNames: \[%s\]", count, namelist)) + end, + }) +end + +--[[ Kill command ]]--- +if useKill then + minetest.register_chatcommand(killcmd, { + params = "", + description = "Kills you :(", + privs = killprivs, + func = function(name, param) + local player = get_player_obj(name) + player:set_hp(0.0) + end, + }) +end \ No newline at end of file diff --git a/mods/redsand/init.lua b/mods/redsand/init.lua new file mode 100644 index 0000000..0fc9f42 --- /dev/null +++ b/mods/redsand/init.lua @@ -0,0 +1,11 @@ +--[[ This mod was made by Teodor Spæren (TheRedMood) ]]-- + +-- Let the loading begin + +-- Essential components +dofile(minetest.get_modpath("redsand").."/conf.lua") +dofile(minetest.get_modpath("redsand").."/functions.lua") + +dofile(minetest.get_modpath("redsand").."/messages.lua") +dofile(minetest.get_modpath("redsand").."/events.lua") +dofile(minetest.get_modpath("redsand").."/general.lua") \ No newline at end of file diff --git a/mods/redsand/messages.lua b/mods/redsand/messages.lua new file mode 100644 index 0000000..e12efa4 --- /dev/null +++ b/mods/redsand/messages.lua @@ -0,0 +1,55 @@ +--[[ All code around the messaging system should be kept here. ]]-- +lastspoke = {} + +--[[ MSG command ]]--- +if useMSG then + minetest.register_chatcommand(msgcmd, { + params = " ", + 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)) + -- Register the chat in the target persons lastspoke tabler + lastspoke[target:get_player_name()] = name + end, + }) +end + +--[[ REPLY command]] -- +if useReply then + minetest.register_chatcommand(replycmd, { + params = "", + description = "Reply the last peron that messaged you.", + privs = replyprivs, + func = function(name, param) + -- We need to get the target + target = lastspoke[name] + + -- Make sure I don't crash the server. + if not target then + minetest.chat_send_player(name, "No one has spoke to you :(") + elseif param == "" then + minetest.chat_send_player(name, "You need to say something.") + else + -- We need to send the message and update the targets lastspoke[] status. + minetest.chat_send_player(target, string.format("From %s: %s", name, param)) + end + end, + }) +end \ No newline at end of file