|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
DataVars = {} -- The proxy table
_DataVars = {} -- The real table where information is stored
DataVarsMT = { -- The metatable
__index = function (t, k)
if _DataVars[k] then
DEFAULT_CHAT_FRAME:AddMessage("Accessed index "..k)
return _DataVars[k]
end
end,
__newindex = function (t, k, v)
DEFAULT_CHAT_FRAME:AddMessage("Created new index "..k)
_DataVars[k] = v
end
}
-- Set the metatable
setmetatable(DataVars, DataVarsMT)
|
|
|
Source code |
1 |
try [skill|item|action etc] when [condition] with timer [timer] unless [condition] |
|
|
Source code |
1 2 |
target clear target select [prev|next] [enemy|friend] [normal|only players|no pets|custom] [custom function] |
|
|
Source code |
1 2 3 4 |
when [condition]
command
otherwise
command
|
|
|
Source code |
1 |
lua [function(parameters)] |
|
|
Source code |
1 |
invalidate [data variable name] |
|
|
Source code |
1 |
perform [sub-list name] |
Quoted from "Peryl;580653"
[INDENT]
![]()
Source code
1 try [skill|item|action etc] when [condition] with timer [timer] unless [condition]
The try command is the meat of the skill list and is directly related to the skill list entries in DIYCE 2.0. The with timer part is optional.[/INDENT]
|
|
Source 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 36 37 38 39 40 41 42 43 44 45 |
INVALIDATE_CACHE = -1 -- a constant to say cached data is invalid
CacheNum = 1 -- holds the current cache ID. Incremented each time FuzzyDIYCE is called
_DataVars = {} -- Table to hold the real data
-- Define the proxy table and required metamethods
DataVars = setmetatable({}, {
__index = function (t, k)
if _DataVars[k] then
if _DataVars[k].cache ~= CacheNum then
-- Data currently in cache is out of date, so update it
_DataVars[k].value = _DataVars[k].func()
_DataVars[k].cache = CacheNum
end
-- Send cached result back
return _DataVars[k].value
end
end,
__newindex = function (t, k, v)
assert(type(v) == "string" or type(v) == "function", "Must initialize cache data variables with a function or a string containing a function")
local f, err
-- if setting a data variable via a string, compile it into the required function
-- otherwise it is a function so just use it directly.
if type(v) == "string" then
f, err = loadstring(v)
assert(f, err)
else
f = v
end
-- Init the data variable entry
_DataVars[k] = { func = f, cache = INVALIDATE_CACHE, value = 0 }
end
})
|
|
|
Source code |
1 |
DataVars['thealth'] = 'return UnitHealth("target")'
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 |
-- Create or reuse existing FuzzyDIYCE environment table
FuzzyDIYCE = FuzzyDIYCE or {}
-- if the metatable isn't present on this table, create it.
if not getmetatable(FuzzyDIYCE) then
setmetatable(FuzzyDIYCE, {__index = _G} )
end
-- switch to our environment context
setfenv(1, FuzzyDIYCE)
|
|
|
Source 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 |
-- Flag to indicate if we should skip the function call or not (reset to false every call to FuzzyDIYCE)
Skip = false
-- The metatable to use for the skip-able commands
SkipMT = { __call = function (tbl, ...)
if not Skip then
return tbl.func(...)
end
end,
}
-- The command table (examples for testing)
Commands = {
-- example normal command
normal = function ()
DEFAULT_CHAT_FRAME:AddMessage("called normal command")
end,
-- example skip-able command. Note that the actual function is defined in "func" in the table
skipable = setmetatable( { func = function ()
DEFAULT_CHAT_FRAME:AddMessage("called skipable function")
end }, SkipMT),
}
|



Quoted from "ShaWalker;582671"
As for the memory footprint with source code and compiled code, dont worry.
But if you do worry, build a string table
With it all menu's, tooltips, functions, etc derive from same table, thus sourcecode eventualy will be a table of integers.
Taking this approach will be awesome for editing and modifying.
Quoted from "Dellenn;582815"
I don't understand about 9/10ths of what you write Peryl,
Quoted from "Dellenn;582815"
but I think the gist is, you want to make DiYCE easy for code-nubs like me, with a GUI and plugins and easy stuff we can deal with?
Quoted from "Dellenn;582815"
I <3 u Peryl![]()