sleep_simple.qsrc 2.7 KB

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