function intersect(t1,t2) local function make_lookup(t) local res={} for _,v in ipairs(t) do res[v]=true end return res end local smaller,larger if (#t1>#t2) then larger=t1 smaller=t2 else larger=t2 smaller=t1 end local lookup=make_lookup(smaller) local res={} for _,v in ipairs(larger) do if lookup[v] then res[#res+1]=v end end return res end function table_has_value(t, n) for _,v in ipairs(t) do if v == n then return true end end return false end function ini_lines_to_table(ini, section) local tmp = {} lc = ini:line_count(section) for li=0,lc-1 do local result, sq, count = ini:r_line(section,li,"","") table.insert(tmp, sq) end return tmp end function spawn_template_lines_to_table(ini, section) local tmp = {} lc = ini:line_count(section) for li=0,lc-1 do local result, sq, count = ini:r_line(section,li,"","") tmp[sq] = tonumber(count) or 1.0 end return tmp end function read_spawn_template_ln(ini, section, line) local result, sq, count = ini:r_line(section,line,"","") local weight = tonumber(count) or 1.0 return sq, weight end