1
0

sleep_simple.qsrc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # sleep_simple
  2. $sleep_loc = 'sleep_simple'
  3. menu_off = 1
  4. if $ARGS[0] = 'simple':
  5. !! to avoid sleeping the whole day I decide to calculate the duration of the sleep in advance
  6. !! the quality of the sleep depends on many factors, so the time of sleep can be modify later, especially the part when the time of sleep is shortened
  7. sleepVars['time_to_full'] = (100 - pcs_sleep) * 6
  8. !! fully exhausted Sveta can recover in 420 minutes = 7 hours of sleep
  9. !! healthy Sveta can hardly sleep more then 10 hours = 600 minutes
  10. !! so we can add about 3 hours to time to full as a limit
  11. sleepVars['time_to_full'] += 150 + rand(0, 60)
  12. sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut
  13. if alarmVars['alarmOn'] = 1:
  14. if alarmVars['alarm_holiday'] = 1 and kanikuli ! 0 or ((hour < alarmVars['timerEndH'] and (week = 6 or week = 7)) or (hour => alarmVars['timerEndH'] and (week = 5 or week = 6))):
  15. !! use weekend time alarm
  16. sleepVars['alarm_time'] = daystart * 1440 + alarmVars['timerEndH'] * 60 + alarmVars['timerEndM']
  17. if sleepVars['time_now'] >= sleepVars['alarm_time']: sleepVars['alarm_time'] += 1440
  18. sleepVars['minutes_to_wakeup'] = min(sleepVars['time_to_full'], sleepVars['alarm_time'] - sleepVars['time_now'])
  19. else
  20. sleepVars['alarm_time'] = daystart * 1440 + alarmVars['timerH'] * 60 + alarmVars['timerM']
  21. if sleepVars['time_now'] >= sleepVars['alarm_time']: sleepVars['alarm_time'] += 1440
  22. sleepVars['minutes_to_wakeup'] = min(sleepVars['time_to_full'], sleepVars['alarm_time'] - sleepVars['time_now'])
  23. end
  24. else
  25. sleepVars['minutes to wakeup'] = sleepVars['time_to_full']
  26. end
  27. InSleep = 1
  28. :sleep_simple_loop
  29. minut += 1
  30. sleepVars['stime'] += 1
  31. sleepVars['minutes to wakeup'] -= 1
  32. if recuperation = 0: pcs_health += 5
  33. if sleepVars['stime'] >= 60:
  34. sleepVars['stime'] = 0
  35. pcs_sleep += 15
  36. gs 'stat'
  37. end
  38. gs 'sleep_simple', 'mod_triggers'
  39. if sleepVars['minutes to wakeup end'] > 0: jump 'sleep_simple_loop'
  40. killvar 'sleep_simple_loop'
  41. sleepVars['time_now'] = daystart * 1440 + hour * 60 + minut
  42. InSleep = 0
  43. gs 'stat'
  44. end
  45. if $ARGS[0] = 'mod_triggers':
  46. !! This location is here to allow mods to hook into the system.
  47. !! Check for: if $sleep_loc = 'pre_sleep' and $ARGS[0] = 'mod_triggers'
  48. !!
  49. !! This is NOT for events!!
  50. gs 'stat'
  51. end
  52. if $ARGS[0] = 'nap_bed':
  53. act 'Take a nap (1:00)':
  54. cla
  55. if pcs_sleep < 10:
  56. gt 'sleep', 'prepare_sleep'
  57. elseif pcs_sleep <= 90:
  58. InSleep = 1
  59. pcs_sleep += 10
  60. pcs_health += 5
  61. minut += 60
  62. gs 'stat'
  63. *nl
  64. 'You sleep about an hour.'
  65. act 'Get up': InSleep = 0 & gt 'bed_get_out', 'start'
  66. else
  67. minut += 5
  68. gs 'stat'
  69. *nl
  70. 'You are not tired enough to sleep, even for a short nap.'
  71. act 'Get up': gt 'bed_get_out', 'start'
  72. end
  73. end
  74. end
  75. --- sleep_simple ---------------------------------