comparison core.lua @ 28:a7376e6de73c

Drycoded rebroadcast of entire days/bosses, finally.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Sun, 09 Oct 2011 15:51:24 +0000
parents 68d7b903ee17
children 7d2742727869
comparison
equal deleted inserted replaced
27:68d7b903ee17 28:a7376e6de73c
1065 end 1065 end
1066 end 1066 end
1067 end 1067 end
1068 1068
1069 -- Generic helpers 1069 -- Generic helpers
1070 -- Returns index and entry at that index, or nil if not found.
1070 function addon._find_next_after (kind, index) 1071 function addon._find_next_after (kind, index)
1071 index = index + 1 1072 index = index + 1
1072 while index <= #g_loot do 1073 while index <= #g_loot do
1073 if g_loot[index].kind == kind then 1074 if g_loot[index].kind == kind then
1074 return index, g_loot[index] 1075 return index, g_loot[index]
1075 end 1076 end
1076 index = index + 1 1077 index = index + 1
1077 end 1078 end
1079 end
1080 -- Essentially a _find_next_after('time'-or-'boss'), but if KIND is
1081 -- 'boss', will also stop upon finding a timestamp. Returns nil if
1082 -- appropriate fencepost is not found.
1083 function addon._find_timeboss_fencepost (kind, index)
1084 local fencepost
1085 local closest_time = addon._find_next_after('time',index)
1086 if kind == 'time' then
1087 fencepost = closest_time
1088 elseif kind == 'boss' then
1089 local closest_boss = addon._find_next_after('boss',index)
1090 if not closest_boss then
1091 fencepost = closest_time
1092 elseif not closest_time then
1093 fencepost = closest_boss
1094 else
1095 fencepost = math.min(closest_time,closest_boss)
1096 end
1097 end
1098 return fencepost
1078 end 1099 end
1079 1100
1080 -- Iterate through g_loot entries according to the KIND field. Loop variables 1101 -- Iterate through g_loot entries according to the KIND field. Loop variables
1081 -- are g_loot indices and the corresponding entries (essentially ipairs + some 1102 -- are g_loot indices and the corresponding entries (essentially ipairs + some
1082 -- conditionals). 1103 -- conditionals).