Advertisement
Kovitikus

Possible Time Cycle

Sep 6th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.02 KB | None | 0 0
  1. def start_time_cycle():
  2.     gametime.schedule(begin_time, repeat=False, hour=0, min=0, sec=0)
  3.  
  4. def begin_time():
  5.     change_time = gametime.schedule(time_cycle, repeat=True, min=20, sec=0)
  6.     change_time.attributes.add('day', True)
  7.     change_time.attributes.add('phase', 6)
  8.     change_time.key = 'time_cycle'
  9.  
  10. def time_cycle():
  11.     change_time = search_script('change_time')
  12.     day = change_time.db.day
  13.     phase = change_time.db.phase
  14.  
  15.     # Check if it's the end of the final phase of night.
  16.     # Strings are placeholders until better alternatives can be writ.
  17.     if not day and phase == 6:
  18.         change_time.db.day = True
  19.         change_time.db.phase = 1
  20.         string = "The sun rises above the eastern horizon."
  21.     elif day and phase == 1:
  22.         change_time.db.phase = 2
  23.         string = "It's now mid-morning."
  24.     elif day and phase == 2:
  25.         change_time.db.phase = 3
  26.         string = "It's now early-noon."
  27.     elif day and phase == 3:
  28.         change_time.db.phase = 4
  29.         string = "It's now high-noon."
  30.     elif day and phase == 4:
  31.         change_time.db.phase = 5
  32.         string = "It's now mid-afternoon."
  33.     elif day and phase == 5:
  34.         change_time.db.phase = 6
  35.         string = "It's now dusk."
  36.     elif day and phase == 6:
  37.         change_time.db.day = False
  38.         change_time.db.phase = 1
  39.         string = "The sun has set and the moon begins to glow."
  40.     elif not day and phase == 1:
  41.         change_time.db.phase = 2
  42.         string = "It's now early-evening."
  43.     elif not day and phase == 2:
  44.         change_time.db.phase = 3
  45.         string = "It's now late-evening."
  46.     elif not day and phase == 3:
  47.         change_time.db.phase = 4
  48.         string = "It's now midnight."
  49.     elif not day and phase == 4:
  50.         change_time.db.phase = 5
  51.         string = "It's now early-morning."
  52.     elif not day and phase == 5:
  53.         change_time.db.phase = 6
  54.         string = "The break of dawn approaches."
  55.  
  56.     for room in Room.objects.all():
  57.             room.msg_contents(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement