From 82c8c4d3248731b5025b01092f6233b98f4d1cda Mon Sep 17 00:00:00 2001 From: OldCoder Date: Sun, 4 Sep 2022 22:03:25 -0700 Subject: [PATCH] Imported from trollstream "ContentDB" --- .gitignore | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE.txt | 26 +++++++++ README.txt | 16 ++++++ init.lua | 40 +++++++++++++ 4 files changed, 245 insertions(+) create mode 100755 .gitignore create mode 100755 LICENSE.txt create mode 100755 README.txt create mode 100755 init.lua diff --git a/.gitignore b/.gitignore new file mode 100755 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/LICENSE.txt b/LICENSE.txt new file mode 100755 index 0000000..8f7c046 --- /dev/null +++ b/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/README.txt b/README.txt new file mode 100755 index 0000000..05430c2 --- /dev/null +++ b/README.txt @@ -0,0 +1,16 @@ +ABOUT +====== +This once was redsand, but now only includes a tell/reply mechanism by @ character + +@player text +@player:text +sends private message to player + +@player1,player2 text +@player1,player2:text +sends private message to players + +@ text +like redsand's reply command, but with one important difference: sends message to the last player(s) that YOU spoke to privately. + +Since this was redsand, see license in license.txt \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100755 index 0000000..443b7a2 --- /dev/null +++ b/init.lua @@ -0,0 +1,40 @@ +--comments have not been removed +--[[ All code around the messaging system should be kept here. ]]-- +atchat_lastrecv = {} + +--now: new stuff: register_on_chat_message +minetest.register_on_chat_message(function(name, message) + local players, msg=string.match(message, "^@([^%s:]*)[%s:](.*)") + if players and msg then + if msg == "" then + minetest.chat_send_player(name, "You have to say something!") + else + if players=="" then--reply + -- We need to get the target + players = atchat_lastrecv[name] + end + if players and players ~= "" then + local sent_to_any + for target in string.gmatch(","..players..",", ",([^,]+),") do + -- Checking if the target exists + if not minetest.get_player_by_name(target) then + minetest.chat_send_player(name, ""..target.." is not online!") + else + -- Sending the message + minetest.chat_send_player(target, string.format("(%s) %s", name, msg)) + sent_to_any = true + end + end + if sent_to_any then + -- Register the chat in the target persons lastspoke tabler + atchat_lastrecv[name] = players + -- echo back to sender + minetest.chat_send_player(name, string.format("(@%s) %s", players, msg)) + end + else + minetest.chat_send_player(name, "Nobody you've spoken to yet!") + end + end + return true + end +end)