diff options
| author | Carter Kolwey <cheapiephp@gmail.com> | 2016-04-25 02:41:55 -0500 | 
|---|---|---|
| committer | Carter Kolwey <cheapiephp@gmail.com> | 2016-04-25 02:41:55 -0500 | 
| commit | 4827d2064ffc1b93afd4da8a85c09c3d479bd81c (patch) | |
| tree | 3b8a68568e32f81b35672078f74b1bfe698484e9 | |
| parent | f6fedd97e781eeaa3b911074002fbbe69ed07221 (diff) | |
Add reply/delete buttons to the message window
| -rw-r--r-- | README | 2 | ||||
| -rw-r--r-- | init.lua | 16 | 
2 files changed, 14 insertions, 4 deletions
@@ -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. @@ -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  | 
