Improvement wieldview and other minor changes
This commit is contained in:
parent
dfa7d2df23
commit
b40d176021
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
MultiCraft Game mod: wieldview
|
||||
===========================
|
||||
|
||||
Makes hand wielded items visible to other players.
|
||||
|
||||
Authors of source code
|
||||
----------------------
|
||||
Copyright (C) 2013-2019 Stuart Jones - LGPLv3.0+ (with the permission of the author)
|
||||
|
||||
|
||||
Makes hand wielded items visible to other players.
|
||||
|
||||
Wield image transformation: To apply a simple transformation to the item in
|
||||
hand, add the group "wieldview_transform" to the item definition. The group
|
||||
rating equals one of the numbers used for the [transform texture modifier
|
||||
of the Lua API.
|
||||
|
|
|
@ -7,21 +7,19 @@ local wield_cubes = {}
|
|||
local wield_items = {}
|
||||
local wield_cycle = {}
|
||||
|
||||
wieldview = {
|
||||
transform = {},
|
||||
}
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")
|
||||
|
||||
local function init_wield_items()
|
||||
for name, def in pairs(minetest.registered_items) do
|
||||
if def.inventory_image and def.inventory_image ~= "" then
|
||||
wield_tiles[name] = def.inventory_image
|
||||
elseif def.tiles and type(def.tiles[1]) == "string" and
|
||||
def.tiles[1] ~= "" and def.drawtype and
|
||||
(def.drawtype == "normal" or def.drawtype == "allfaces" or
|
||||
def.drawtype == "glasslike" or def.drawtype == "liquid") then
|
||||
wield_cubes[name] = def.tiles[1]
|
||||
(def.drawtype == "normal" or def.drawtype:sub(1,8) == "allfaces" or
|
||||
def.drawtype:sub(1,5) == "glass" or def.drawtype == "liquid") then
|
||||
if not (def.tiles[3] ~= "" and type(def.tiles[3]) == "string") then
|
||||
wield_cubes[name] = def.tiles[1]
|
||||
else
|
||||
wield_cubes[name] = def.tiles[3]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -31,20 +29,9 @@ local function update_player_visuals(player, item)
|
|||
local animation = player_api.get_animation(player) or {}
|
||||
local textures = animation.textures or {}
|
||||
local skin = textures[1] and textures[1] or "character.png"
|
||||
local wield_tile = wield_tiles[item]
|
||||
if wield_tile then
|
||||
-- Get item image transformation, first from group, then from transform.lua
|
||||
local transform = minetest.get_item_group(item, "wieldview_transform")
|
||||
if transform == 0 then
|
||||
transform = wieldview.transform[item]
|
||||
end
|
||||
if transform then
|
||||
-- This actually works with groups ratings because transform1, transform2, etc.
|
||||
-- have meaning and transform0 is used for identidy, so it can be ignored
|
||||
wield_tile = wield_tile.."^[transform"..tostring(transform)
|
||||
end
|
||||
else
|
||||
wield_tile = "blank.png"
|
||||
local wield_tile = wield_tiles[item] or "blank.png"
|
||||
if not minetest.registered_tools[item] then
|
||||
wield_tile = wield_tile.."^[transformR270"
|
||||
end
|
||||
local wield_cube = wield_cubes[item] or "blank.png"
|
||||
if has_armor then
|
||||
|
@ -80,7 +67,7 @@ local function update_wielded_item(dtime, name)
|
|||
wield_cycle[name] = 0
|
||||
end
|
||||
|
||||
if not minetest.is_singleplayer() then
|
||||
if PLATFORM ~= "Android" or PLATFORM ~= "iOS" then
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
if name then
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
-- Wielded Item Transformations - http://dev.minetest.net/texture
|
||||
|
||||
wieldview.transform = {
|
||||
["default:torch"]="R270",
|
||||
["mesecons_torch:mesecon_torch_on"]="R270",
|
||||
["default:sapling"]="R270",
|
||||
["flowers:dandelion_white"]="R270",
|
||||
["flowers:dandelion_yellow"]="R270",
|
||||
["flowers:geranium"]="R270",
|
||||
["flowers:rose"]="R270",
|
||||
["flowers:tulip"]="R270",
|
||||
["flowers:viola"]="R270",
|
||||
["bucket:bucket_empty"]="R270",
|
||||
["bucket:bucket_water"]="R270",
|
||||
["bucket:bucket_lava"]="R270",
|
||||
["screwdriver:screwdriver"]="R270",
|
||||
["screwdriver:screwdriver1"]="R270",
|
||||
["screwdriver:screwdriver2"]="R270",
|
||||
["screwdriver:screwdriver3"]="R270",
|
||||
["screwdriver:screwdriver4"]="R270",
|
||||
["vessels:glass_bottle"]="R270",
|
||||
["vessels:drinking_glass"]="R270",
|
||||
["vessels:steel_bottle"]="R270",
|
||||
}
|
Loading…
Reference in New Issue