Improvement wieldview and other minor changes

This commit is contained in:
MoNTE48 2019-07-10 19:04:17 +02:00
parent 66632acec6
commit f47d29ceac
2 changed files with 19 additions and 22 deletions

View File

@ -118,10 +118,9 @@ core.builtin_auth_handler = {
}
end,
create_auth = function(name, password)
core.log("action", "Adding password entry for player " .. name)
core.log("action", "[AUTH] Adding password entry for player " .. name)
assert(type(name) == "string")
assert(type(password) == "string")
core.log('info', "Built-in authentication handler adding player '"..name.."'")
core.auth_table[name] = {
password = password,
privileges = core.string_to_privs(core.settings:get("default_privs")),
@ -132,17 +131,16 @@ core.builtin_auth_handler = {
assert(type(name) == "string")
assert(type(password) == "string")
if not core.auth_table[name] then
core.log("action", "Setting password for new player " .. name)
core.log("action", "[AUTH] Setting password for new player " .. name)
core.builtin_auth_handler.create_auth(name, password)
else
core.log("action", "Setting password for existing player " .. name )
core.log('info', "Built-in authentication handler setting password of player '"..name.."'")
core.log("action", "[AUTH] Setting password for existing player " .. name)
core.auth_table[name].password = password
end
return true
end,
set_privileges = function(name, privileges)
core.log("action", "Setting privileges for player " .. name )
core.log("action", "[AUTH] Setting privileges for player " .. name)
assert(type(name) == "string")
assert(type(privileges) == "table")
if not core.auth_table[name] then
@ -154,17 +152,16 @@ core.builtin_auth_handler = {
core.notify_authentication_modified(name)
end,
reload = function()
core.log("action", "Reading authentication data from disk")
core.log("action", "[AUTH] Writing authentication data to disk")
read_auth_file()
return true
end,
commit = function()
core.log("action", "Writing authentication data to disk")
core.log("action", "[AUTH] Writing authentication data to disk")
save_auth_file()
return true
end,
record_login = function(name)
core.log("action", "Recording login time for player " .. name )
assert(type(name) == "string")
assert(core.auth_table[name]).last_login = os.time()
end,
@ -219,21 +216,21 @@ core.register_on_prejoinplayer(function(name, ip)
local name_lower = name:lower()
for k in pairs(auth) do
if k:lower() == name_lower then
return string.format("\nCannot create new player called '%s'. "..
"Another account called '%s' is already registered. "..
return string.format("\nYou can not register as '%s'! "..
"Another player called '%s' is already registered. "..
"Please check the spelling if it's your account "..
"or use a different nickname.", name, k)
"or use a different name.", name, k)
end
end
end)
-- Autosave
if not core.is_singleplayer() then
local save_interval = tonumber(core.settings:get("server_map_save_interval"))
local save_interval = 600
local function auto_save()
core.auth_commit()
core.after(save_interval * 3, auto_save)
core.after(save_interval, auto_save)
end
core.after(60, auto_save)
core.after(save_interval, auto_save)
end

View File

@ -592,27 +592,27 @@ function core.item_eat(hp_change, replace_with_item)
return function(itemstack, user, pointed_thing) -- closure
if user then
local pos = user:get_pos()
pos.y = pos.y + 1.5
pos.y = pos.y + 1.3
local itemname = itemstack:get_name()
local texture = core.registered_items[itemname].inventory_image
core.sound_play("player_eat", {pos = pos, max_hear_distance = 10, gain = 0.3})
local dir = user:get_look_dir()
core.add_particlespawner({
amount = 20,
time = 0.1,
minpos = {x = pos.x, y = pos.y, z = pos.z},
maxpos = {x = pos.x, y = pos.y, z = pos.z},
minvel = {x = -1, y = 1, z = -1},
maxvel = {x = 1, y = 2, z = 1},
minpos = pos,
maxpos = pos,
minvel = {x = dir.x - 1, y = 2, z = dir.z - 1},
maxvel = {x = dir.x + 1, y = 2, z = dir.z + 1},
minacc = {x = 0, y = -5, z = 0},
maxacc = {x = 0, y = -9, z = 0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = true,
vertical = false,
texture = texture,
})
core.sound_play("player_eat", {pos = pos, max_hear_distance = 10, gain = 0.3})
return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
end
end