dofile(path.."/version_send.lua")
dofile(path.."/colored_names/colored_names.lua")
dofile(path.."/fire_handling.lua")
+ dofile(path.."/sleeping.lua")
end
--we must delay initialization until the player exists in the world
--begin initial attempt
recursive_startup_attempt()
-
---leave mod channels on shutdown
---[[
-minetest.register_on_shutdown(function()
- weather_intake = nil
- weather = nil
- weather_type = nil
- player_movement_state = nil
- nether = nil
- aether = nil
- name = nil
- version_channel = nil
- fire_handling_channel = nil
-end)
-]]--
\ No newline at end of file
--- /dev/null
+local minetest,name = minetest,minetest.localplayer:get_name()
+local sleep_channel = minetest.mod_channel_join(name..":sleep_channel")
+local sleeping = 0
+local sleep_fade = 0
+local sleep_id = nil
+
+minetest.register_on_modchannel_message(function(channel_name, sender, message)
+ if sender == "" and channel_name == name..":sleep_channel" then
+ sleeping = tonumber(message)
+ end
+end)
+
+
+
+minetest.register_globalstep(function(dtime)
+ if sleeping == 0 and sleep_fade == 0 then
+ if sleep_id then
+ sleep_id = nil
+ end
+ return
+ elseif sleeping == 1 and sleep_fade < 255 then
+ if not sleep_id then
+ sleep_id = minetest.localplayer:hud_add({
+ hud_elem_type = "image", -- see HUD element types, default "text"
+ position = {x=0.5, y=0.5},
+ name = "", -- default ""
+ scale = {x=-100, y=-100}, -- default {x=0,y=0}
+ text = "sleep.png^[opacity:"..sleep_fade,
+ })
+ else
+ sleep_fade = sleep_fade + (dtime*100)
+ if sleep_fade >= 255 then
+ sleep_fade = 255
+ sleep_channel:send_all("true")
+ end
+ minetest.localplayer:hud_change(sleep_id, "text", "sleep.png^[opacity:"..sleep_fade)
+ end
+ elseif sleeping == 0 and sleep_fade > 0 then
+ if sleep_id then
+ sleep_fade = sleep_fade - (dtime*500)
+ if sleep_fade < 0 then
+ sleep_fade = 0
+ end
+ minetest.localplayer:hud_change(sleep_id, "text", "sleep.png^[opacity:"..sleep_fade)
+ if sleep_fade == 0 then
+ minetest.localplayer:hud_remove(sleep_id)
+ sleep_id = nil
+ end
+ end
+ end
+end)
\ No newline at end of file
local minetest,name = minetest,minetest.localplayer:get_name()
local version_channel = minetest.mod_channel_join(name..":client_version_channel")
minetest.after(2,function() -- this needs a few seconds for the mod channel to open up
- version_channel:send_all("0.05010")
+ version_channel:send_all("0.05011")
end)
\ No newline at end of file