Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bullsei opened this issue Sep 2, 2017 · 3 comments
Open

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

bullsei opened this issue Sep 2, 2017 · 3 comments

Comments

@bullsei
Copy link

bullsei commented Sep 2, 2017

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.

@varren
Copy link
Owner

varren commented Sep 3, 2017

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

@bullsei
Copy link
Author

bullsei commented Sep 3, 2017

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.

@varren
Copy link
Owner

varren commented Sep 4, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants