randomscreenshot: make it nice :)

wsc-master-rebase
cora 2020-11-16 12:40:45 +01:00 committed by Schmappie Eldress
parent 96e1367839
commit b88f3fd140
2 changed files with 21 additions and 4 deletions

View File

@ -4,16 +4,30 @@
randomscreenshot = {}
local interval=10 -- minimum number of minutes to wait til next screenshot
local rnd=10 --random time
local nextsc=0
local function init_settings(setting_table)
for k, v in pairs(setting_table) do
if minetest.settings:get(k) == nil then
if type(v) == "boolean" then
minetest.settings:set_bool(k, v)
else
minetest.settings:set(k, v)
end
end
end
end
init_settings({
randomscreenshot_interval = 10,
randomscreenshot_rnd = 10
})
local nextsc=0
minetest.register_globalstep(function()
if not minetest.settings:get_bool("randomsc") then return end
if os.time() < nextsc then return end
math.randomseed(os.clock())
nextsc=os.time() + ( interval * 60 ) + math.random(rnd * 60)
nextsc=os.time() + ( minetest.settings:get('randomscreenshot_interval') * 60 ) + math.random(minetest.settings:get('randomscreenshot_rnd') * 60)
minetest.after("15.0",function()
minetest.hide_huds()
minetest.display_chat_message("\n\n\n\n\n\n\n\n\n")

View File

@ -1 +1,4 @@
randomsc (Enable Autoscreenshot) bool false
randomscreenshot_interval ( Minimum time to wait between screenshots in minutes ) int 10
randomscreenshot_rnd (Random time between screenshots in minutes ) int 10