From 092e90fa2c10d207537dafed88b012af7c78efb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teodor=20Sp=C3=A6ren?= Date: Mon, 15 Oct 2012 13:36:24 +0200 Subject: [PATCH] Added /reply and upgraded conf.lua a lot. Adding a new command and updating the configuration file is not to bad :) This will need to be tested later when I get to my desktop PC. --- .gitignore | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 11 +++- conf.lua | 44 ++++++++------- init.lua | 35 +++++++++++- 4 files changed, 229 insertions(+), 24 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ebd21a --- /dev/null +++ b/.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/README.txt b/README.txt index 971ffbc..ed992f3 100644 --- a/README.txt +++ b/README.txt @@ -3,6 +3,9 @@ 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 ==== @@ -15,4 +18,10 @@ COMMANDS ======== /list - List out the players on the server. /kill - Lower your health to 0. -/msg - Talk to someone. \ No newline at end of file +/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/conf.lua b/conf.lua index 94f93bc..a5fc81f 100644 --- a/conf.lua +++ b/conf.lua @@ -1,26 +1,30 @@ --- Care about small and BIG letters? -careLetters = true +--[[ What do you want to be loaded? ]]-- --- List command -useList = true -listprivs = {shout = true} +useList = true -- List command +useMSG = true -- MSG command +useKill = true -- Kill command +useReply = true -- Reply command --- Kill command -useKill = true -killprivs = {shout = true} +useMOTD = true -- Message of the day +useDeathMSG = true -- Death messages +useReviveMSG = true -- Revive messages --- MSG command -useMSG = true -msgprivs = {shout = true} +--[[ GLOBAL OPTIONS ]]-- +careLetters = true -- Care about small and BIG letters? ---MOTD -useMOTD = true -MOTD = "Welcome %s! This is the default MOTD." +--[[ Privleges ]]-- +listprivs = {shout = true} -- List privleges +killprivs = {shout = true} -- kill privleges +msgprivs = {shout = true} -- msg privleges +replyprivs = {shout = true} -- reply privleges --- Death message -useDeathMSG = true -DEATH_MSG = "%s left this world :(" +--[[ 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 Phonix %s rises from the ashes." -- Revive message --- Revive message -useReviveMSG = true -REVIVE_MSG = "Like a Phonix %s rises from the ashes." \ No newline at end of file +--[[ What do you want after the / ]]-- +listcmd = "list" +msgcmd = "msg" +killcmd = "kill" +replycmd = "reply" \ No newline at end of file diff --git a/init.lua b/init.lua index 714850a..40217d8 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,5 @@ dofile(minetest.get_modpath("redsand").."/conf.lua") +lastspoke = {} -- !!! FUNCTIONS !!! -- @@ -32,7 +33,7 @@ end --[[ List function. ]]-- if useList then - minetest.register_chatcommand("list", { + minetest.register_chatcommand(listcmd, { params = "", -- short parameter description description = "List connected players", -- full description privs = listprivs, -- require the "privs" privilege to run @@ -51,7 +52,7 @@ end --[[ Kill command ]]--- if useKill then - minetest.register_chatcommand("kill", { + minetest.register_chatcommand(killcmd, { params = "", description = "Kills you :(", privs = killprivs, @@ -64,7 +65,7 @@ end --[[ MSG command ]]--- if useMSG then - minetest.register_chatcommand("msg", { + minetest.register_chatcommand(msgcmd, { params = " ", description = "Talk to someone!", privs = msgprivs, @@ -86,9 +87,37 @@ if useMSG then -- 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)) + lastspoke[target] = name + end + end, + }) +end + + -- !!! EVENTS !!! -- --[[ What happens when a player joins? ]]--