From 9aab85fe7a756e08124a0b500e3e34c70fc3d83f Mon Sep 17 00:00:00 2001 From: cheapie Date: Mon, 25 Apr 2016 03:05:29 -0500 Subject: Add forward function --- README | 2 +- init.lua | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README b/README index 7bbeda4..e9ed9e6 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 buttons to return to the inbox, reply to the message, or delete it. +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, forward it, 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 dd692fe..7b2a5a5 100644 --- a/init.lua +++ b/init.lua @@ -27,9 +27,11 @@ mail.inboxformspec = "size[8,9;]".. "button_exit[7.5,0;0.5,0.5;quit;X]".. "button[6.25,1;1.5,0.5;new;New Message]".. "button[6.25,2;1.5,0.5;read;Read]".. - "button[6.25,3;1.5,0.5;delete;Delete]".. - "button[6.25,4;1.5,0.5;markread;Mark Read]".. - "button[6.25,5;1.5,0.5;markunread;Mark Unread]".. + "button[6.25,3;1.5,0.5;reply;Reply]".. + "button[6.25,4;1.5,0.5;forward;Forward]".. + "button[6.25,5;1.5,0.5;delete;Delete]".. + "button[6.25,6;1.5,0.5;markread;Mark Read]".. + "button[6.25,7;1.5,0.5;markunread;Mark Unread]".. "button[6.25,8;1.5,0.5;about;About]".. "textlist[0,0.5;6,8.5;message;" @@ -90,7 +92,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[1,5;2,1;back;Back]button[3,5;2,1;reply;Reply]button[5,5;2,1;delete;Delete]" + local formspec = "size[8,6]button[7.5,0;0.5,0.5;back;X]label[0,0;From: %s]label[0,0.5;Subject: %s]textarea[0.25,1;8,4;body;;%s]button[1,5;2,1;reply;Reply]button[3,5;2,1;forward;Forward]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) @@ -126,6 +128,14 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) if mail.messages[name][mail.highlightedmessages[name]] then table.remove(mail.messages[name],mail.highlightedmessages[name]) end mail.showinbox(name) mail.save() + elseif fields.reply and mail.messages[name][mail.highlightedmessages[name]] 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.forward and mail.messages[name][mail.highlightedmessages[name]] then + local message = mail.messages[name][mail.highlightedmessages[name]] + local fwfooter = "Type your message here."..string.char(10)..string.char(10).."--Original message follows--"..string.char(10)..message.body + mail.showcompose(name,"","Fw: "..message.subject,fwfooter) elseif fields.markread then if mail.messages[name][mail.highlightedmessages[name]] then mail.messages[name][mail.highlightedmessages[name]].unread = false end mail.showinbox(name) @@ -152,6 +162,10 @@ minetest.register_on_player_receive_fields(function(player,formname,fields) 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.forward then + local message = mail.messages[name][mail.highlightedmessages[name]] + local fwfooter = "Type your message here."..string.char(10)..string.char(10).."--Original message follows--"..string.char(10)..message.body + mail.showcompose(name,"","Fw: "..message.subject,fwfooter) elseif fields.delete then if mail.messages[name][mail.highlightedmessages[name]] then table.remove(mail.messages[name],mail.highlightedmessages[name]) end mail.showinbox(name) -- cgit v1.2.3