fix typos and errors

This commit is contained in:
Thomas Rudin 2019-02-27 20:34:39 +01:00
parent 1606f8c2b8
commit 4d7c8bbdd2
7 changed files with 18 additions and 17 deletions

View File

@ -31,7 +31,7 @@ function mail.send(m) -- see: "Mail format"
m.subject = string.sub(m.subject,1,27) .. "..."
end
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

View File

@ -7,7 +7,7 @@ mail.getAttachmentInventory = function(playername)
end
mail.getAttachmentInventoryName = function(playername)
return "mail:" .. name
return "mail:" .. playername
end
@ -21,5 +21,7 @@ end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
invmap[name] = nil
minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name))
end)
if minetest.remove_detached_inventory then
minetest.remove_detached_inventory(mail.getAttachmentInventoryName(name))
end
end)

10
hud.lua
View File

@ -9,7 +9,7 @@ minetest.register_on_joinplayer(function(player)
hud_elem_type = "image",
name = "MailIcon",
position = {x=0.52, y=0.52},
text="email_mail.png",
text="",
scale = {x=1,y=1},
alignment = {x=0.5, y=0.5},
})
@ -18,7 +18,7 @@ minetest.register_on_joinplayer(function(player)
hud_elem_type = "text",
name = "MailText",
position = {x=0.55, y=0.52},
text= #inbox .. " /inbox",
text= "",
scale = {x=1,y=1},
alignment = {x=0.5, y=0.5},
})
@ -49,11 +49,11 @@ mail.hud_update = function(playername, messages)
end
if unreadcount == 0 then
player:hud_change(data.imageid, "image", "")
player:hud_change(data.imageid, "text", "")
player:hud_change(data.textid, "text", "")
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")
end
end
end

View File

@ -24,6 +24,7 @@ dofile(MP .. "/hud.lua")
dofile(MP .. "/storage.lua")
dofile(MP .. "/api.lua")
dofile(MP .. "/gui.lua")
dofile(MP .. "/onjoin.lua")
-- optional webmail stuff below

View File

@ -12,7 +12,7 @@ mail.migrate = function()
local oldmails = minetest.deserialize(data)
file:close()
for name, oldmessages in pairs(oldmails)
for name, oldmessages in pairs(oldmails) do
mail.setMessages(name, oldmessages)
end
@ -21,4 +21,4 @@ mail.migrate = function()
os.rename(minetest.get_worldpath().."/mail.db", minetest.get_worldpath().."/mail.db.old")
end
end
end

View File

@ -4,7 +4,7 @@ minetest.register_on_joinplayer(function(player)
local unreadcount = 0
for _, message in ipairs(messages) do
for _, message in pairs(messages) do
if message.unread then
unreadcount = unreadcount + 1
end
@ -12,7 +12,7 @@ minetest.register_on_joinplayer(function(player)
if unreadcount > 0 then
minetest.chat_send_player(name,
"(" .. unreadcount .. ") You have mail! Type /mail to recieve")
"(" .. unreadcount .. ") You have mail! Type /mail to read")
end
end, player:get_player_name())

View File

@ -6,11 +6,11 @@ function getMailFile(playername)
end
mail.getMessages = function(playername)
local file = io.open(getMailFile(playername),"w", "r")
local file = io.open(getMailFile(playername), "r")
local messages = {}
if file then
local json = file:read("*a")
messages = minetest.parse_json(json) or {}
messages = minetest.parse_json(json or "[]") or {}
mail.hud_update(playername, messages)
file:close()
end
@ -29,5 +29,3 @@ mail.setMessages = function(playername, messages)
return false
end
end