moreblocks/invsaw/api.lua

30 lines
785 B
Lua
Raw Normal View History

2022-06-20 00:26:05 +02:00
function invsaw.has_saw_in_inventory(player)
local inv = player:get_inventory()
return inv:contains_item("main", invsaw.settings.saw_item)
end
function invsaw.can_use_saw(player)
return (
minetest.check_player_privs(player, invsaw.settings.creative_priv) or
minetest.check_player_privs(player, invsaw.settings.priv)
)
end
function invsaw.allow_use_saw(player)
return (
minetest.check_player_privs(player, invsaw.settings.creative_priv) or
(minetest.check_player_privs(player, invsaw.settings.priv) and invsaw.has_saw_in_inventory(player))
)
end
2022-06-20 00:34:08 +02:00
function invsaw.check_use_status(player)
2022-06-20 00:26:05 +02:00
if invsaw.can_use_saw(player) then
2022-06-20 00:34:08 +02:00
invsaw.initialize_inventory(player)
2022-06-20 00:26:05 +02:00
else
invsaw.drop_inventory(player)
end
end
2022-06-20 00:34:08 +02:00
minetest.register_on_joinplayer(invsaw.check_use_status)