summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2016-04-25 02:41:55 -0500
committercheapie <no-email-for-you@example.com>2016-04-25 02:41:55 -0500
commit6f190464fd1dc3d439958003622d6341ebf51d72 (patch)
tree3b8a68568e32f81b35672078f74b1bfe698484e9
parenta9664c6eec1915ca3dd72fbf4645fea15606043b (diff)
downloadmail-6f190464fd1dc3d439958003622d6341ebf51d72.tar
mail-6f190464fd1dc3d439958003622d6341ebf51d72.tar.gz
mail-6f190464fd1dc3d439958003622d6341ebf51d72.tar.bz2
mail-6f190464fd1dc3d439958003622d6341ebf51d72.tar.xz
mail-6f190464fd1dc3d439958003622d6341ebf51d72.zip
Add reply/delete buttons to the message window
-rw-r--r--README2
-rw-r--r--init.lua16
2 files changed, 14 insertions, 4 deletions
diff --git a/README b/README
index cc371d2..7bbeda4 100644
--- a/README
+++ b/README
@@ -13,7 +13,7 @@ Instructions:
The inbox can be accessed by using the /mail command or by pressing the "Mail" button in unified_inventory if that mod is installed. In that window, all messages that the player currently has have the sender and subject (truncated if necessary) shown in a list. Unread messages are shown in red, while read messages are shown in white. The "Mark Read" and "Mark Unread" buttons will change this status, as well as viewing the message.
-To view a message, either single-click on it and press "Read", or just double-click on it. A window will then open showing the sender, subject, and body of the message, with a button to return to the inbox.
+To view a message, either single-click on it and press "Read", or just double-click on it. A window will then open showing the sender, subject, and body of the message, with buttons to return to the inbox, reply to the message, or delete it.
Single-clicking a message and pressing the "delete" button will remove the message from the inbox.
diff --git a/init.lua b/init.lua
index 164dc6b..3a7c918 100644
--- a/init.lua
+++ b/init.lua
@@ -75,7 +75,7 @@ end
function mail.showmessage(name,msgnumber)
local message = mail.messages[name][msgnumber]
- local formspec = "size[8,6]label[0,0;From: %s]label[0,0.5;Subject: %s]textarea[0.25,1;8,4;body;;%s]button[3,5;2,1;back;Back]"
+ local formspec = "size[8,6]label[0,0;From: %s]label[0,0.5;Subject: %s]textarea[0.25,1;8,4;body;;%s]button[1,5;2,1;back;Back]button[3,5;2,1;reply;Reply]button[5,5;2,1;delete;Delete]"
local sender = minetest.formspec_escape(message.sender)
local subject = minetest.formspec_escape(message.subject)
local body = minetest.formspec_escape(message.body)
@@ -85,7 +85,7 @@ end
function mail.showcompose(name,defaulttgt,defaultsubj,defaultbody)
local formspec = "size[8,8]field[0.25,0.5;4,1;to;To:;%s]field[0.25,1.5;4,1;subject;Subject:;%s]textarea[0.25,2.5;8,4;body;;%s]button[1,7;2,1;cancel;Cancel]button[5,7;2,1;send;Send]"
- formspec = string.format(formspec,defaulttgt,defaultsubj,defaultbody)
+ formspec = string.format(formspec,minetest.formspec_escape(defaulttgt),minetest.formspec_escape(defaultsubj),minetest.formspec_escape(defaultbody))
minetest.show_formspec(name,"mail:compose",formspec)
end
@@ -126,7 +126,17 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
end
return true
elseif formname == "mail:message" then
- mail.showinbox(player:get_player_name())
+ local name = player:get_player_name()
+ if fields.back then
+ mail.showinbox(name)
+ elseif fields.reply then
+ local message = mail.messages[name][mail.highlightedmessages[name]]
+ local replyfooter = "Type your reply here."..string.char(10)..string.char(10).."--Original message follows--"..string.char(10)..message.body
+ mail.showcompose(name,message.sender,"Re: "..message.subject,replyfooter)
+ elseif fields.delete then
+ if mail.messages[name][mail.highlightedmessages[name]] then table.remove(mail.messages[name],mail.highlightedmessages[name]) end
+ mail.showinbox(name)
+ end
return true
elseif formname == "mail:compose" then
if fields.send then