From ef41cfd978bb863ac5035ec654e57941929db8e5 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sat, 19 Oct 2013 07:54:11 +0000 Subject: [PATCH] Allow for custom functions in scripts to support the usual parameters. The new syntax is: AddFunction FuncName param1=value1 param2=value2 { ... } Where the parameter=value pairs can be used to determine if that function meets the current conditions, e.g., mastery=1 to only have that function be valid in the first specialization. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1079 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleCompile.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 4bf920a..cab9f5b 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -586,12 +586,16 @@ local function ParseCommands(text) return nodeId end -local function ParseAddFunction(name, text) +local function ParseAddFunction(name, params, text) local nodeId = ParseCommands(text) local node = self_pool:Get() node.type = "customfunction" node.name = name + node.params = ParseParameters(params) node.a = self_node[tonumber(nodeId)] + if not TestConditions(node.params) then + return nil + end return AddNode(node) end @@ -716,8 +720,8 @@ local function CompileScript(text) text = CompileDeclarations(text) text = CompileInputs(text) - for name, t in strgmatch(text, "AddFunction%s+(%w+)%s*(%b{})") do - local node = ParseAddFunction(name, t) + for name, p, t in strgmatch(text, "AddFunction%s+(%w+)%s*(.-)%s*(%b{})") do + local node = ParseAddFunction(name, p, t) if node then self_customFunctions[name] = node end -- 1.7.9.5