Originally Posted by yssaril
would you mind showing us a codesample (its alot easier to figure out that what you wrote :P)
|
Well sure! It'll take a little context but it's not bad.
Code:
function EX_CheckExtraFilter(extraFilterString)
if extraFilterString == "" or extraFilterString == nil then return true end
local argumentPattern = "[^&|()!][^&|()]*"
extraFilterString = gsub(extraFilterString, argumentPattern, EX_ExtraFilterGsub)
return EX_Evaluator(extraFilterString)
end
function EX_ExtraFilterGsub(eachArgument)
return tostring(EX_ExtraFilterHandler(eachArgument))
end
This function is called on each "extra filter". An extra filter is something that is not event based but relevant, like whether or not the player is in combat or in an arena. I define how those filters are handled, but a good example would be:
The above functions would, if the player is in an arena, pass "false|true" to the EX_Evaluator function, which is here below:
Code:
function EX_Evaluator(argString)
argString = gsub(argString, "&", " and ")
argString = gsub(argString, "!", "not ")
argString = gsub(argString, "%||", " or ")
return loadstring("return "..argString)
end
It just converts the logical operators to what Lua expects and then returns the result. This function would receive the "false|true", convert it to "false or true" then loadstring("return false or true"), which would be true. This step is creating a function, though, which seems to be adding to my garbage.