More development on the new API

This commit is contained in:
Tercioo
2019-04-09 14:05:18 -03:00
parent 4bd7bbc6df
commit 2ff8108c83
11 changed files with 756 additions and 45 deletions
+38 -20
View File
@@ -48,7 +48,8 @@ Details.API_Description = {}
--[=[
Details.SegmentElapsedTime (segment)
--=]=]
Details.API_Description.SegmentElapsedTime = {
tinsert (Details.API_Description, {
name = "SegmentElapsedTime",
desc = "Return the total elapsed time of a segment.",
parameters = {
{
@@ -65,7 +66,8 @@ Details.API_Description.SegmentElapsedTime = {
desc = "Number representing the elapsed time of a combat.",
}
},
}
type = 1, --damage
})
function Details.SegmentElapsedTime (segment)
segment = segment or 0
@@ -81,7 +83,8 @@ end
--[=[
Details.UnitDamage (unitId, segment)
--=]=]
Details.API_Description.UnitDamage = {
tinsert (Details.API_Description, {
name = "UnitDamage",
desc = "Query the damage of a unit.",
parameters = {
{
@@ -104,7 +107,8 @@ Details.API_Description.UnitDamage = {
desc = "Number representing the unit damage.",
}
},
}
type = 1, --damage
})
function Details.UnitDamage (unitId, segment)
segment = segment or 0
@@ -128,7 +132,8 @@ end
--[=[
Details.UnitSpellDamage (unitId, spellId, segment)
--=]=]
Details.API_Description.UnitSpellDamage = {
tinsert (Details.API_Description, {
name = "UnitSpellDamage",
desc = "Query the total damage done of a spell casted by the unit.",
parameters = {
{
@@ -157,7 +162,8 @@ Details.API_Description.UnitSpellDamage = {
desc = "Number representing the spell damage done.",
}
},
}
type = 1, --damage
})
function Details.UnitSpellDamage (unitId, spellId, segment)
segment = segment or 0
@@ -198,7 +204,8 @@ end
--[=[
Details.UnitSpells (unitId, segment)
--=]=]
Details.API_Description.UnitSpells = {
tinsert (Details.API_Description, {
name = "UnitDamageSpells",
desc = "Return a numeric table with spells IDs used by the unit.",
parameters = {
{
@@ -221,9 +228,10 @@ Details.API_Description.UnitSpells = {
desc = "Number representing the spell damage done.",
}
},
}
type = 1, --damage
})
function Details.UnitSpells (unitId, segment)
function Details.UnitDamageSpells (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
@@ -251,7 +259,8 @@ end
--[=[
Details.UnitDamageTaken (unitId, segment)
--=]=]
Details.API_Description.UnitDamageTaken = {
tinsert (Details.API_Description, {
name = "UnitDamageTaken",
desc = "Query the unit damage taken.",
parameters = {
{
@@ -274,7 +283,8 @@ Details.API_Description.UnitDamageTaken = {
desc = "Number representing the damage taken by the unit.",
}
},
}
type = 1, --damage
})
function Details.UnitDamageTaken (unitId, segment)
segment = segment or 0
@@ -297,7 +307,8 @@ end
--[=[
Details.UnitDamageOnUnit (unitId, targetUnitId, segment)
--=]=]
Details.API_Description.UnitDamageOnUnit = {
tinsert (Details.API_Description, {
name = "UnitDamageOnUnit",
desc = "Query the unit damage done on another unit.",
parameters = {
{
@@ -326,7 +337,8 @@ Details.API_Description.UnitDamageOnUnit = {
desc = "Number representing the damage done by the unit on the target unit.",
}
},
}
type = 1, --damage
})
function Details.UnitDamageOnUnit (unitId, targetUnitId, segment)
segment = segment or 0
@@ -350,7 +362,8 @@ end
--[=[
Details.UnitDamageTakenFromSpell (unitId, spellId, segment)
--=]=]
Details.API_Description.UnitDamageTakenFromSpell = {
tinsert (Details.API_Description, {
name = "UnitDamageTakenFromSpell",
desc = "Query the unit damage taken from a spell.",
parameters = {
{
@@ -379,7 +392,8 @@ Details.API_Description.UnitDamageTakenFromSpell = {
desc = "Number representing the damage taken by the unit from a spell.",
}
},
}
type = 1, --damage
})
function Details.UnitDamageTakenFromSpell (unitId, spellId, segment)
segment = segment or 0
@@ -413,7 +427,8 @@ end
--[=[
Details.UnitDamageInfo (unitId, segment)
--=]=]
Details.API_Description.UnitDamageInfo = {
tinsert (Details.API_Description, {
name = "UnitDamageInfo",
desc = "Return a table with damage information.",
parameters = {
{
@@ -436,7 +451,8 @@ Details.API_Description.UnitDamageInfo = {
desc = "Table containing damage information, keys are: .total, .totalWithoutPet, .damageAbsorbed, .damageTaken, .friendlyFire and .activityTime",
}
},
}
type = 1, --damage
})
function Details.UnitDamageInfo (unitId, segment)
segment = segment or 0
@@ -476,7 +492,8 @@ end
--[=[
Details.UnitSpellInfo (unitId, spellId, segment)
--=]=]
Details.API_Description.UnitSpellInfo = {
tinsert (Details.API_Description, {
name = "UnitDamageSpellInfo",
desc = "Return a table with the spell damage information.",
parameters = {
{
@@ -505,9 +522,10 @@ Details.API_Description.UnitSpellInfo = {
desc = "Table containing damage information, keys are: '.total', '.spellId', '.count', '.name', '.casted', '.regularMin', '.regularMax', '.regularAmount', '.regularDamage', '.criticalMin', '.criticalMax', '.criticalAmount', '.criticalDamage'",
}
},
}
type = 1, --damage
})
function Details.UnitSpellInfo (unitId, spellId, segment)
function Details.UnitDamageSpellInfo (unitId, spellId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
+2
View File
@@ -21,6 +21,8 @@ function SlashCmdList.DETAILS (msg, editbox)
elseif (command == "api") then
_detalhes.OpenAPI()
elseif (command == Loc ["STRING_SLASH_NEW"] or command == "new") then
_detalhes:CriarInstancia (nil, true)
+56 -2
View File
@@ -168,6 +168,55 @@
local tick_time = 0
--from weakauras, list of functions to block on scripts
--source https://github.com/WeakAuras/WeakAuras2/blob/520951a4b49b64cb49d88c1a8542d02bbcdbe412/WeakAuras/AuraEnvironment.lua#L66
local blockedFunctions = {
-- Lua functions that may allow breaking out of the environment
getfenv = true,
getfenv = true,
loadstring = true,
pcall = true,
xpcall = true,
getglobal = true,
-- blocked WoW API
SendMail = true,
SetTradeMoney = true,
AddTradeMoney = true,
PickupTradeMoney = true,
PickupPlayerMoney = true,
TradeFrame = true,
MailFrame = true,
EnumerateFrames = true,
RunScript = true,
AcceptTrade = true,
SetSendMailMoney = true,
EditMacro = true,
SlashCmdList = true,
DevTools_DumpCommand = true,
hash_SlashCmdList = true,
CreateMacro = true,
SetBindingMacro = true,
GuildDisband = true,
GuildUninvite = true,
securecall = true,
--additional
setmetatable = true,
}
local functionFilter = setmetatable ({}, {__index = function (env, key)
if (key == "_G") then
return env
elseif (blockedFunctions [key]) then
return nil
else
return _G [key]
end
end})
--> starting a combat
function _detalhes:TimeDataCreateCombatTables()
@@ -189,13 +238,18 @@
if (type (t [INDEX_FUNCTION]) == "string") then
--> user
local func = loadstring (t [INDEX_FUNCTION])
local func, errortext = loadstring (t [INDEX_FUNCTION])
if (func) then
setfenv (func, functionFilter)
tinsert (exec, { func = func, data = data, attributes = table_deepcopy (t [INDEX_MATRIX]), is_user = true })
else
_detalhes:Msg ("|cFFFF9900error compiling script for time data (charts)|r: ", errortext)
end
else
--> plugin
tinsert (exec, { func = t [INDEX_FUNCTION], data = data, attributes = table_deepcopy (t [INDEX_MATRIX]) })
local func = t [INDEX_FUNCTION]
setfenv (func, functionFilter)
tinsert (exec, { func = func, data = data, attributes = table_deepcopy (t [INDEX_MATRIX]) })
end
end