Browse Source

disable custom day_night_ratio in survival

main
Hendrik Langer 3 years ago
parent
commit
167b8c4bed
  1. 22
      player.lua

22
player.lua

@ -56,6 +56,25 @@ function creative_regions:restore_player_inventory(player, listname)
end
end
function creative_regions:save_player_day_night_ratio(player)
local current_day_night_ratio = player:get_day_night_ratio()
if current_day_night_ratio == nil then current_day_night_ratio = -1 end
local pmeta = player:get_meta()
pmeta:set_int("creative_regions_day_night_ratio", current_day_night_ratio)
end
function creative_regions:restore_player_day_night_ratio(player)
local pmeta = player:get_meta()
local current_day_night_ratio = player:get_day_night_ratio()
local saved_day_night_ratio = pmeta:get_int("creative_region_day_night_ratio")
if saved_day_night_ratio ~= nil then
if saved_day_night_ratio == -1 then saved_day_night_ratio = nil end
player:override_day_night_ratio(saved_day_night_ratio)
pmeta:set_int("creative_regions_day_night_ratio", nil)
end
return current_day_night_ratio
end
function creative_regions:player_enter_region(player, new_privs_table, initialize)
local name = player:get_player_name()
local has_creative = minetest.check_player_privs(name, {creative=true})
@ -116,6 +135,7 @@ function creative_regions:player_enter_region(player, new_privs_table, initializ
-- player:get_meta():set_string("hunger_ng:hunger_disabled", 1)
hunger_ng.configure_hunger(name, 'disable')
end
creative_regions:restore_player_day_night_ratio(player)
elseif new_mode == "arena" then
local inv = player:get_inventory()
inv:set_list("main", {})
@ -123,6 +143,8 @@ function creative_regions:player_enter_region(player, new_privs_table, initializ
if minetest.get_modpath("hunger_ng") then
hunger_ng.configure_hunger(name, 'enable')
end
creative_regions:save_player_day_night_ratio(player)
player:override_day_night_ratio(nil)
end
end

Loading…
Cancel
Save