ViragDevTool

ViragDevTool

19.4k Downloads

Tried to set a font today with SetFont(), didn't work

bullsei opened this issue ยท 3 comments

commented

Hi, i tried to use this addon to call a function with arguments today. I typed "Fonts\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME" into the arguments field and pressed enter. Since this Function doesn't give any feedback if the font was successfully changed i called GetFont() afterwards. It showed me that the SetFont() wasn't successful. Calling the same function per /run with the same arguments worked. I guess it has something todo with the handling of the \ character.

commented

Hi, i had a little use for this feature so it is in pretty early state and can parse only comma separated values. One exception is table that should be specified as t=TableName. Tablename can be dot separateed.
t=Frame, 12, a12 => someFunction(_G.Frame (table) , 12 (number), a12 (string))
t=Frame.Frame2.Frame3 => someFunction(_G.Frame.Frame2.Frame3 (table))

So you use quotes and my parser will just parse them as is and pass string with quotes down the function and you also have comma inside a string so my parser will just create 4 args instead of 3. I'll try to fix this as soon as i can. Thank you for reporting.

And right now you can hack it yourself if you want to
Here is relative code.

ViragDevTool/ViragDevTool.lua

Lines 1021 to 1044 in 6c26ac8

function ViragDevTool:SetArgForFunctionCallFromString(argStr)
local args = self.split(argStr, ",") or {}
local trim = function(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
for k, arg in pairs(args) do
arg = trim(arg)
if tonumber(arg) then
args[k] = tonumber(arg)
elseif arg == "nil" then
args[k] = nil
elseif arg == "true" then
args[k] = true
elseif arg == "false" then
args[k] = false
end
end
self.settings.tArgs = args
self:Add(args, "New Args for function calls")
end

Table parsing part:

local args = { unpack(self.settings.tArgs) }
for k, v in pairs(args) do
if type(v) == "string" and self.starts(v, "t=") then
local obj = self:FromStrToObject(string.sub(v, 3))
if obj then
args[k] = obj
end
end
end

Where FromStrToObject is

function ViragDevTool:FromStrToObject(str)
if str == "_G" then return _G end
local vars = self.split(str, ".") or {}
local var = _G
for _, name in pairs(vars) do
if var then
var = var[name]
end
end
return var
end

commented

don't use quotes, try Fonts\FRIZQT__.TTF, 17 i don't have access to wow/windows pc right now, will fix this as soon as i can

commented

Thanks for reply. I tried to pass only "Fonts\FRIZQT__.TTF", 17 into the arguments field, didn't work either. So the problem is not only to related to commas being inside strings. I am not really sure what exactly is the problem tho.