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

View File

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