Use Minetest 5.3 'minetest.is_creative_enabled' API (#2795)

This commit is contained in:
Maksim 2020-12-13 18:59:19 +01:00 committed by GitHub
parent 9c29019301
commit e6aec880de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 34 additions and 65 deletions

View file

@ -8,25 +8,16 @@ binoculars = {}
local S = minetest.get_translator("binoculars")
-- Detect creative mod
local creative_mod = minetest.get_modpath("creative")
-- Cache creative mode setting as fallback if creative mod not present
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
-- Update player property
-- Global to allow overriding
function binoculars.update_player_property(player)
local creative_enabled =
(creative_mod and creative.is_enabled_for(player:get_player_name())) or
creative_mode_cache
local new_zoom_fov = 0
if player:get_inventory():contains_item(
"main", "binoculars:binoculars") then
new_zoom_fov = 10
elseif creative_enabled then
elseif minetest.is_creative_enabled(player:get_player_name()) then
new_zoom_fov = 15
end