fix typos and errors
This commit is contained in:
parent
1606f8c2b8
commit
4d7c8bbdd2
2
api.lua
2
api.lua
@ -31,7 +31,7 @@ function mail.send(m) -- see: "Mail format"
|
|||||||
m.subject = string.sub(m.subject,1,27) .. "..."
|
m.subject = string.sub(m.subject,1,27) .. "..."
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(m.dst,
|
minetest.chat_send_player(m.dst,
|
||||||
string.format(m.receive_mail_message, m.src, m.subject))
|
string.format(mail.receive_mail_message, m.src, m.subject))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ mail.getAttachmentInventory = function(playername)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mail.getAttachmentInventoryName = function(playername)
|
mail.getAttachmentInventoryName = function(playername)
|
||||||
return "mail:" .. name
|
return "mail:" .. playername
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -21,5 +21,7 @@ end)
|
|||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
invmap[name] = nil
|
invmap[name] = nil
|
||||||
minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name))
|
if minetest.remove_detached_inventory then
|
||||||
end)
|
minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
10
hud.lua
10
hud.lua
@ -9,7 +9,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
name = "MailIcon",
|
name = "MailIcon",
|
||||||
position = {x=0.52, y=0.52},
|
position = {x=0.52, y=0.52},
|
||||||
text="email_mail.png",
|
text="",
|
||||||
scale = {x=1,y=1},
|
scale = {x=1,y=1},
|
||||||
alignment = {x=0.5, y=0.5},
|
alignment = {x=0.5, y=0.5},
|
||||||
})
|
})
|
||||||
@ -18,7 +18,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
name = "MailText",
|
name = "MailText",
|
||||||
position = {x=0.55, y=0.52},
|
position = {x=0.55, y=0.52},
|
||||||
text= #inbox .. " /inbox",
|
text= "",
|
||||||
scale = {x=1,y=1},
|
scale = {x=1,y=1},
|
||||||
alignment = {x=0.5, y=0.5},
|
alignment = {x=0.5, y=0.5},
|
||||||
})
|
})
|
||||||
@ -49,11 +49,11 @@ mail.hud_update = function(playername, messages)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if unreadcount == 0 then
|
if unreadcount == 0 then
|
||||||
player:hud_change(data.imageid, "image", "")
|
player:hud_change(data.imageid, "text", "")
|
||||||
player:hud_change(data.textid, "text", "")
|
player:hud_change(data.textid, "text", "")
|
||||||
else
|
else
|
||||||
player:hud_change(data.imageid, "image", "email_mail.png")
|
player:hud_change(data.imageid, "text", "email_mail.png")
|
||||||
player:hud_change(data.textid, "text", unreadcount .. " /mail")
|
player:hud_change(data.textid, "text", unreadcount .. " /mail")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
1
init.lua
1
init.lua
@ -24,6 +24,7 @@ dofile(MP .. "/hud.lua")
|
|||||||
dofile(MP .. "/storage.lua")
|
dofile(MP .. "/storage.lua")
|
||||||
dofile(MP .. "/api.lua")
|
dofile(MP .. "/api.lua")
|
||||||
dofile(MP .. "/gui.lua")
|
dofile(MP .. "/gui.lua")
|
||||||
|
dofile(MP .. "/onjoin.lua")
|
||||||
|
|
||||||
-- optional webmail stuff below
|
-- optional webmail stuff below
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ mail.migrate = function()
|
|||||||
local oldmails = minetest.deserialize(data)
|
local oldmails = minetest.deserialize(data)
|
||||||
file:close()
|
file:close()
|
||||||
|
|
||||||
for name, oldmessages in pairs(oldmails)
|
for name, oldmessages in pairs(oldmails) do
|
||||||
mail.setMessages(name, oldmessages)
|
mail.setMessages(name, oldmessages)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -21,4 +21,4 @@ mail.migrate = function()
|
|||||||
os.rename(minetest.get_worldpath().."/mail.db", minetest.get_worldpath().."/mail.db.old")
|
os.rename(minetest.get_worldpath().."/mail.db", minetest.get_worldpath().."/mail.db.old")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
|
|
||||||
local unreadcount = 0
|
local unreadcount = 0
|
||||||
|
|
||||||
for _, message in ipairs(messages) do
|
for _, message in pairs(messages) do
|
||||||
if message.unread then
|
if message.unread then
|
||||||
unreadcount = unreadcount + 1
|
unreadcount = unreadcount + 1
|
||||||
end
|
end
|
||||||
@ -12,7 +12,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
|
|
||||||
if unreadcount > 0 then
|
if unreadcount > 0 then
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
"(" .. unreadcount .. ") You have mail! Type /mail to recieve")
|
"(" .. unreadcount .. ") You have mail! Type /mail to read")
|
||||||
|
|
||||||
end
|
end
|
||||||
end, player:get_player_name())
|
end, player:get_player_name())
|
||||||
|
@ -6,11 +6,11 @@ function getMailFile(playername)
|
|||||||
end
|
end
|
||||||
|
|
||||||
mail.getMessages = function(playername)
|
mail.getMessages = function(playername)
|
||||||
local file = io.open(getMailFile(playername),"w", "r")
|
local file = io.open(getMailFile(playername), "r")
|
||||||
local messages = {}
|
local messages = {}
|
||||||
if file then
|
if file then
|
||||||
local json = file:read("*a")
|
local json = file:read("*a")
|
||||||
messages = minetest.parse_json(json) or {}
|
messages = minetest.parse_json(json or "[]") or {}
|
||||||
mail.hud_update(playername, messages)
|
mail.hud_update(playername, messages)
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
@ -29,5 +29,3 @@ mail.setMessages = function(playername, messages)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user