Tighten up interact checks.

This commit is contained in:
Aaron Suen 2019-11-28 08:55:09 -05:00
parent d016885364
commit a12d44c4f8
6 changed files with 13 additions and 11 deletions

View File

@ -103,7 +103,11 @@ function nodecore.fixedbox(x, ...)
end
function nodecore.interact(player)
if not player then return end
if type(player) ~= "string" then
if not (player.is_player and player:is_player()) then
return true
end
player = player:get_player_name()
end
return minetest.get_player_privs(player).interact

View File

@ -189,8 +189,7 @@ function nodecore.operate_door(pos, node, dir)
and to.z + 0.5 > op.z + cb[3] and to.z - 0.5 < op.z + cb[6]
then
local lua = obj.get_luaentity and obj:get_luaentity()
if not ((lua and lua.is_stack) or (obj:is_player()
and not minetest.check_player_privs(obj, "interact"))) then
if not ((lua and lua.is_stack) or (not nodecore.interact(obj))) then
return
end
end

View File

@ -48,7 +48,7 @@ end
local oldpos = {}
local qtys = {}
local function playercheck(dtime, player)
if not minetest.check_player_privs(player, "interact") then return end
if not nodecore.interact(player) then return end
local name = player:get_player_name()

View File

@ -1,6 +1,6 @@
-- LUALOCALS < ---------------------------------------------------------
local math, minetest, pairs
= math, minetest, pairs
local math, minetest, nodecore, pairs
= math, minetest, nodecore, pairs
local math_floor
= math.floor
-- LUALOCALS > ---------------------------------------------------------
@ -15,11 +15,10 @@ local function breathimg(br)
end
local function sethudflags(player, pname)
pname = pname or player:get_player_name()
local privs = minetest.get_player_privs(pname)
local interact = nodecore.interact(pname or player)
player:hud_set_flags({
wielditem = privs.interact or false,
hotbar = privs.interact or false,
wielditem = interact or false,
hotbar = interact or false,
healthbar = false,
breathbar = false,
minimap = false,

View File

@ -30,7 +30,7 @@ minetest.register_allow_player_inventory_action(function(_, action)
end)
local function privdropinv(player)
if minetest.check_player_privs(player, "interact") then return end
if nodecore.interact(player) then return end
local pos = player:get_pos()
pos.y = pos.y + player:get_properties().eye_height
local inv = player:get_inventory()

View File

@ -23,7 +23,7 @@ local function entprops(stack, conf, widx)
is_visible = false,
static_save = false
}
if not conf then return t end
if not (conf and conf.pname and nodecore.interact(conf.pname)) then return t end
if conf.slot then
t.is_visible = true
t.textures = {modname .. "_slot.png^[transformFX^[opacity:160", "[combine:1x1"}