Add telex reply n
.
This allows players to quickly respond to an existing message and send a quoted reply to the original user. The reply is a new draft that has the message quoted and subject prepended with "Re: ".
This commit is contained in:
parent
a1f484a2f2
commit
702639ea56
@ -74,6 +74,21 @@ function telex.list(player)
|
||||
return list
|
||||
end
|
||||
|
||||
-- returns a table
|
||||
function telex.get(player, no)
|
||||
local pmeta = player:get_meta()
|
||||
local mbox = telex.decode(pmeta:get_string("telex_mbox"))
|
||||
if not mbox then
|
||||
return { "You have no messages." }
|
||||
end
|
||||
local msg = mbox[no]
|
||||
if not msg then
|
||||
return { "No such message exists." }
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
-- returns an array of strings
|
||||
function telex.read(player, no)
|
||||
local pmeta = player:get_meta()
|
||||
|
@ -65,7 +65,8 @@ term.telex_help = {
|
||||
discard = "discard the current telex draft message",
|
||||
send = "send the current draft telex message to a recipient",
|
||||
remove = "remove a received telex message by number",
|
||||
read = "read a received telex message by number"
|
||||
read = "read a received telex message by number",
|
||||
reply = "create a draft reply to a message by number"
|
||||
}
|
||||
|
||||
local function make_formspec(output, prompt)
|
||||
@ -300,6 +301,23 @@ term.commands = {
|
||||
elseif h == "remove" then
|
||||
local player = minetest.get_player_by_name(c.name)
|
||||
return output .. "\n" .. table.concat(telex.delete(player, tonumber(p)), "\n")
|
||||
elseif h == "reply" then
|
||||
local player = minetest.get_player_by_name(c.name)
|
||||
local msg = telex.get(player, tonumber(p))
|
||||
if not msg.subject then
|
||||
return output .. "\n" .. table.concat(msg, "\n")
|
||||
end
|
||||
fsc.show(c.name, "size[12,8]" ..
|
||||
"field[0.5,0.5;11.5,1;subject;subject;" ..
|
||||
minetest.formspec_escape("Re: " .. msg.subject) .. "]" ..
|
||||
"textarea[0.5,1.5;11.5,7.0;text;text;" ..
|
||||
"\n\n> " ..
|
||||
minetest.formspec_escape(table.concat(msg.content, "\n> ")) .. "]" ..
|
||||
"button[5.2,7.7;1.6,0.5;exit;Save]",
|
||||
c,
|
||||
term.draft)
|
||||
|
||||
return false
|
||||
end
|
||||
else
|
||||
return output .. "\n" ..
|
||||
|
Loading…
x
Reference in New Issue
Block a user