daily pastebin goal
10%
SHARE
TWEET

Calculating breeding times for PoF

a guest Dec 8th, 2018 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local lang = mw.language.new('en')
  2.  
  3. local p = {}
  4.  
  5. --Cycles in the last 10 hours:
  6. --07 December 2018 22:00:00 (UTC): Chinchompa, Dragon, Zygomite
  7. --08 December 2018 00:30:00 (UTC): Chinchompa
  8. --08 December 2018 03:00:00 (UTC): Chinchompa
  9. --08 December 2018 05:30:00 (UTC): Chinchompa
  10. --08 December 2018 06:20:00 (UTC): Zygomite
  11. --Cycles in the next 10 hours:
  12. --08 December 2018 08:00:00 (UTC): Chinchompa
  13. --08 December 2018 10:30:00 (UTC): Chinchompa
  14. --08 December 2018 13:00:00 (UTC): Chinchompa
  15. --08 December 2018 14:40:00 (UTC): Dragon, Zygomite
  16. --08 December 2018 15:30:00 (UTC): Chinchompa
  17. function p.test()
  18.     return p.pof({'Chinchompa', 'Zygomite', 'Dragon'}, 10);
  19. end
  20.  
  21. function p.pof(animals, timespan_hours)
  22.     local timesPast = {};
  23.     local timesFuture = {};
  24.     for _,a in ipairs(animals) do
  25.         local g = p.pof_generate(a, timespan_hours);
  26.        
  27.         for _,t in ipairs(g.past) do
  28.             if timesPast[t] == nil then
  29.                 timesPast[t] = {};
  30.             end
  31.             table.insert(timesPast[t], a);
  32.         end
  33.        
  34.         for _,t in ipairs(g.future) do
  35.             if timesFuture[t] == nil then
  36.                 timesFuture[t] = {};
  37.             end
  38.             table.insert(timesFuture[t], a);
  39.         end
  40.     end
  41.    
  42.     local r = 'Cycles in the last ' .. timespan_hours .. (timespan_hours == 1 and ' hour:\n' or ' hours:\n');
  43.     local times = {};
  44.     for k in pairs(timesPast) do table.insert(times, k); end
  45.     table.sort(times);
  46.     for _,t in ipairs(times) do
  47.         local a = timesPast[t];
  48.         table.sort(a);
  49.         r = r .. lang:formatDate('d F Y H:i:s', '@' .. t, nil) .. ' (UTC): ' .. table.concat(a, ', ') .. '\n';
  50.     end
  51.  
  52.     r = r .. 'Cycles in the next ' .. timespan_hours .. (timespan_hours == 1 and ' hour:\n' or ' hours:\n');
  53.     times = {};
  54.     for k in pairs(timesFuture) do table.insert(times, k) end
  55.     table.sort(times);
  56.     for _,t in ipairs(times) do
  57.         local a = timesFuture[t];
  58.         table.sort(a);
  59.         r = r .. lang:formatDate('d F Y H:i:s', '@' .. t, nil) .. ' (UTC): ' .. table.concat(a, ', ') .. '\n';
  60.     end
  61.    
  62.     return r;
  63. end
  64.  
  65. function p.pof_generate(animal, timespan_hours)
  66.     local a = p.pof_animals()[animal];
  67.     local cycleInS = a.cycleLength * 60;
  68.     local lastCycleTime = math.floor(os.time() / cycleInS) * cycleInS;
  69.  
  70.     local timesPast = {};
  71.     local pastCutoff = os.time() - (timespan_hours * 3600);
  72.     local cycleTime = lastCycleTime;
  73.     while cycleTime >= pastCutoff do
  74.         table.insert(timesPast, cycleTime);
  75.         cycleTime = cycleTime - cycleInS;
  76.     end
  77.    
  78.     local timesFuture = {};
  79.     local futureCutoff = os.time() + (timespan_hours * 3600);
  80.     cycleTime = lastCycleTime + cycleInS;
  81.     while cycleTime <= futureCutoff do
  82.         table.insert(timesFuture, cycleTime);
  83.         cycleTime = cycleTime + cycleInS;
  84.     end
  85.    
  86.     return {past = timesPast, future = timesFuture};
  87. end
  88.  
  89. function p.pof_animals()
  90.     return {
  91.         ['Rabbit'] = {cycleLength = 5},
  92.         ['Chicken'] = {cycleLength = 50},
  93.         ['Chinchompa'] = {cycleLength = 150},
  94.         ['Sheep'] = {cycleLength = 100},
  95.         ['Spider'] = {cycleLength = 180},
  96.         ['Zygomite'] = {cycleLength = 500},
  97.         ['Cow'] = {cycleLength = 300},
  98.         ['Yak'] = {cycleLength = 400},
  99.         ['Dragon'] = {cycleLength = 1000},
  100.     };
  101. end
  102.  
  103. return p
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top