Browse Source

fetch day_night overrides from daynight mod

main
Hendrik Langer 3 years ago
parent
commit
b76d531f3b
  1. 2
      mod.conf
  2. 18
      player.lua

2
mod.conf

@ -1,4 +1,4 @@
name = creative_regions
description = Toggle privs in areas
depends = default, sfinv
optional_depends = areas, unified_inventory, hunger_ng, vehicles, playerfactions
optional_depends = areas, unified_inventory, hunger_ng, vehicles, playerfactions, daynight

18
player.lua

@ -60,13 +60,30 @@ local DAYNIGHT_AUTO = -1
local DAYNIGHT_UNSET = -2
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 = DAYNIGHT_AUTO 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 name = player:get_player_name()
local current_day_night_ratio = player:get_day_night_ratio()
if minetest.get_modpath("daynight") then
local daynight_prefs = {}
local daynight_file = io.open(minetest.get_worldpath()..DIR_DELIM.."daynight.txt", "r")
if daynight_file then
local data = daynight_file:read("*all")
daynight_prefs = minetest.deserialize(data)
daynight_file:close()
player:override_day_night_ratio(daynight_prefs[name])
end
end
return current_day_night_ratio
--[[
local pmeta = player:get_meta()
local current_day_night_ratio = player:get_day_night_ratio()
local saved_day_night_ratio = pmeta:get_int("creative_regions_day_night_ratio")
@ -76,6 +93,7 @@ function creative_regions:restore_player_day_night_ratio(player)
pmeta:set_int("creative_regions_day_night_ratio", DAYNIGHT_UNSET)
end
return current_day_night_ratio
--]]
end
function creative_regions:player_enter_region(player, new_privs_table, initialize)

Loading…
Cancel
Save