Advertisement
jbrocky

Untitled

Apr 7th, 2020
693
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.17 KB | None | 0 0
  1. custom_require.call(%w[common common-items])
  2.  
  3. no_pause_all
  4. no_kill_all
  5.  
  6. start_script('afk') if !Script.running?('afk')
  7. start_script('log') if !Script.running?('log')
  8.      
  9. class AutoLog
  10.   include DRC
  11.   include DRCI
  12.    
  13.   def initialize
  14.     @time_in = Time.now
  15.     @time_limit = variable[1]*60 # Convert minutes to seconds
  16.  
  17.     message('Beginning Autolog.  Exiting in ' + args.timer.to_s + ' minutes.')
  18.     main_loop
  19.     shutdown
  20.   end
  21.  
  22.   def main_loop
  23.     elapsed_time = 0
  24.     time_remaining = 0
  25.     counter = 0
  26.  
  27.     while ( (@time_in + @time_limit) < Time.now ) )
  28.       pause(30)
  29.      
  30.       counter += 1
  31.      
  32.       elapsed_time = counter*30 #already in seconds
  33.       time_remaining = @time_limit - elapsed_time
  34.  
  35.       # convert counter to minutes
  36.       # ex. 1 iteration; 30/60 = .5, half a minute
  37.       message("AUTOLOG:: Elapsed: #{elapsed_time/60} min    Remaining: #{time_remaining} min")
  38.     end
  39.   end
  40.  
  41.   def shutdown
  42.     stow_hands
  43.     result = ''
  44.  
  45.     until result =~ /Stow what?/i
  46.       bput('stow feet', 'Stow what?', /^You/i)
  47.     end
  48.  
  49.     fput('exit')
  50.   end
  51. end
  52.  
  53. before_dying do
  54.     echo 'AutoLog closing...'
  55. end
  56.  
  57. AutoLog.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement