-- 设置休息时间段(24小时制) local start_night = 0 -- 晚上8点 local end_night = 4 -- 晚上10点 -- 设置提醒时间间隔(秒) local reminder_interval = 60 -- 每60秒检查一次 -- 主循环 while true do -- 获取当前时间 local current_time = os.date("*t") -- 获取当前时间表 -- 判断当前时间是否在设定的休息时间段内 if current_time.hour >= start_night and current_time.hour < end_night then -- 在设定的休息时间段内 gg.alert("现在是晚上休息时间。建议你停下来休息一下。") end -- 显示当前时间 gg.toast(string.format("当前时间: %02d:%02d:%02d", current_time.hour, current_time.min, current_time.sec)) -- 等待一段时间再进行下一次检查 gg.sleep(reminder_interval * 1000) -- 转换为毫秒 end