Pastes

Filter code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
			-------------------------------------------------------------------------------
			-- Check the class filter flags
			-------------------------------------------------------------------------------
			local class_filters = filter_db.classes

			toggled_off, toggled_on = 0, 0

			for class, flag in pairs(CLASS_FILTERS) do
				local bitfield = recipe.flags.class1

				if bitfield and bit.band(bitfield, flag) == flag then
					if class_filters[class] then
						toggled_on = toggled_on + 1
					else
						toggled_off = toggled_off + 1
					end
				end
			end

			if toggled_off > 0 and toggled_on == 0 then
				return false
			end

			------------------------------------------------------------------------------------------------
			-- Stage 2
			-- loop through nonexclusive (soft filters) flags until one is true
			-- If one of these is true (ie: we want to see trainers and there is a trainer flag) we display the recipe
			------------------------------------------------------------------------------------------------
			for filter, data in pairs(SOFT_FILTERS) do
				local bitfield = recipe.flags[private.flag_members[data.index]]

				if bitfield and bit.band(bitfield, data.flag) == data.flag and data.sv_root[filter] then
					return true
				end
			end

Facts

Date posted
07 Sep 2010
Language
Lua

Poster