Softrix / SmartBuff-Retail

Smartbuff Retail
1 stars 3 forks source link

Lua Error when toggling fix casting option #28

Closed srtzero closed 1 year ago

srtzero commented 1 year ago

Hi,

I receive this Lua error from Bugsack in Dragonflight Retail 10.1.0.

1x bad argument #2 to '?' (Usage: local success = C_CVar.SetCVar(name [, value])) [string "=[C]"]: in function SetCVar' [string "@SmartBuff/SmartBuff.lua"]:3477: in functionSMARTBUFF_ToggleFixBuffing'

Locals: (*temporary) = "bad argument #2 to '?' (Usage: local success = C_CVar.SetCVar(name [, value]))"

MyTechnoHunter commented 1 year ago

the first question i have.. is do you require toggling that? (before working on why its giving that error..)

image

srtzero commented 1 year ago

Yes. I do, otherwise using the macro doesnt work. I normally have the option to hide the smart action button on. But even then it doesnt work like normal. Each time I login, I have to show the action button and click it once to buff. Then the macro will work. Without doing that, the macro will do nothing.

speedwaystar commented 1 year ago

based on the line number of the error, you are not using the latest build, which specifically addresses that problem. let me know if you are still getting the error after installing the latest build.

srtzero commented 1 year ago

I installed it using the curseforge app. I will download from your github and install manually.

MyTechnoHunter commented 1 year ago

unless i am reading it wrong, the problem is that you get a bool and try to set a bool instead of getting the value itself in this case "1" or "0" so when you go to set it, it fails as it takes a 1 or 0 not a true or false.. i took the single instance (during init) of GetCVarBool and changed it to GetCVar and it worked fine in testing..

https://wowpedia.fandom.com/wiki/API_C_CVar.SetCVar says takes a string or a number doesnt mention a bool

srtzero commented 1 year ago

Ok, Downloaded from Github and installed latest. TOC file is showing: ## Interface: 100100 ## Version: 20.100100

When I don't have the fix casting option checked, clicking the action button or the made macro does nothing. No spells cast, No errors given. When I have the option selected clicking the action button works, but when attempting to use the macro "/click SmartBuff_KeyButton" it throws the following Lua error:

1x bad argument #2 to '?' (Usage: local success = C_CVar.SetCVar(name [, value])) string "=[C]": in function SetCVar' [string "@SmartBuff/SmartBuff.lua"]:2280: in functionSMARTBUFF_BuffUnit' [string "@SmartBuff/SmartBuff.lua"]:1674: in function SMARTBUFF_Check' [string "@SmartBuff/SmartBuff.lua"]:4265: in function <SmartBuff/SmartBuff.lua:4217> [string "=[C]"]: in functionClick' [string "@FrameXML/ChatFrame.lua"]:1626: in function `?' [string "@FrameXML/ChatFrame.lua"]:5216: in function <FrameXML/ChatFrame.lua:5182>

string "=[C]": in function ChatEdit_ParseText' [string "@FrameXML/ChatFrame.lua"]:4894: in function <FrameXML/ChatFrame.lua:4893> [string "=[C]"]: in functionChatEdit_SendText' [string "@FrameXML/ChatFrame.lua"]:3138: in function <FrameXML/ChatFrame.lua:3131> string "=[C]": in function UseAction' [string "@FrameXML/SecureTemplates.lua"]:364: in functionhandler' [string "@FrameXML/SecureTemplates.lua"]:690: in function <FrameXML/SecureTemplates.lua:672> [string "@FrameXML/SecureTemplates.lua"]:704: in function <FrameXML/SecureTemplates.lua:697> [string "@FrameXML/SecureTemplates.lua"]:746: in function <FrameXML/SecureTemplates.lua:730>

[string "@FrameXML/SecureHandlers.lua"]:266: in function <FrameXML/SecureHandlers.lua:263>

[string "@FrameXML/SecureHandlers.lua"]:296: in function <FrameXML/SecureHandlers.lua:279>

Locals: (*temporary) = "bad argument #2 to '?' (Usage: local success = C_CVar.SetCVar(name [, value]))"

MyTechnoHunter commented 1 year ago

same issue.. you cant Set the CVar with a bool.. it MUST be a string or a number.. in this case

since the initial problem was magnified (4 or 5 calls now), find all instances of C_CVar.GetCVarBool and change it to C_CVar.GetCVar or let the dev work on it.. they are aware of it on discord so fix should be incoming

speedwaystar commented 1 year ago

hopefully https://github.com/Softrix/SmartBuff-Retail/pull/29 will resolve this. can somebody test it before it's pushed to curse?

srtzero commented 1 year ago

Well I downloaded it from GitHub. And there is progress. So now at least I do not receive any LUA errors. And clicking the smart buff action button still works. But the macro does not work at all. Regardless of whether I have the fix casting option selected or not. And it does not provide any LUA errors.

speedwaystar commented 1 year ago

i'm not able to reproduce this, sorry. @Softrix?

Softrix commented 1 year ago

I can confirm the macro is failing here also, im currently in retail working on a fix as we speak, hence why its not been released to curse yet.

speedwaystar commented 1 year ago

is it all macros, or just the ones which are around weapon buff items (like, for instance, Completely Safe Rockets)? i've currently have them on my to-fix list.

Softrix commented 1 year ago

No, he is referring to the call to /click SmartBuff_KeyButton - basically when the cvar is set to 1 via the fix casting workaround then the macro side of it fails - the macro is fine with the cvar set to 0.

Softrix commented 1 year ago

The problem is, the scroll mouse, the macro and the action button are all the same so its a pain in the a**

Softrix commented 1 year ago

You can test this by turning off fix casting, use /run SetCVar("ActionButtonUseKeyDown",0 ); to ensure its the game client default and then run /click SmartBuff_KeyButton from a macro - it will cast correctly (or at least it is here) but going back to normal with the fix casting on (i.e. the auto switch to value 1) kills the macro.

srtzero commented 1 year ago

Thanks for tackling this and the support provided so far. Im glad you at least know where the issue lies. Personally for me, I do not use nor like the scroll casting option. Messes up my camera zoom in and out. I prefer much more the macro, that I can assign to an actionbar keybind.

I will test above and report back.

srtzero commented 1 year ago

Ok well, with this latest revision, might have fixed everything. I ran the code as you instructed and the macro does indeed work. And so does the smart action button, and this is without having the fix casting option turned on now. Its the first time pressing the action button or macro has worked without having that option on. I will continue to try it out using different characters and let you know. And yes SmartBuff addon is the only addon I'm currently running to ensure no other addons where causing the issues.

One side note: neither the macro or action button worked after running that code, until after I died. Once I died once it started working.

Softrix commented 1 year ago

Yes, i failed to mention a reloadui would be needed, but the death did that for you :)
I always work on my addons without any other addon loaded - the only time i load another is if theres a conflict between the two i need to fix.

MyTechnoHunter commented 1 year ago

The default, according to the game console, is 1.. not 0 If you add -console to your game launch args in the game settings in the bnet client it enables the in game console command. Once enabled hit the ` key in game (the key just left of the 1 on the top row) Type the CVar in question and it will show the current value. Hover it and it will show the default value

Softrix commented 1 year ago

Correct, realised after i replied regarding the default value and intended to edit but got side tracked lol.

Softrix commented 1 year ago

But anyway, ive resolved the problem here - just busy testing futher.

MyTechnoHunter commented 1 year ago

Nice

srtzero commented 1 year ago

Everything seems to be working now. Ive logged on to multiple characters and the macro and smart action button work as expected without having the fix cast option on. When I logged into the first alt character it did ask me if I wished to reset all. I clicked yes. Addon didnt ask again for any other character except that first alt character.

Softrix commented 1 year ago

Seems to be fine now, i'll close the report for now - thanks for the headsup on the macro issue.

srtzero commented 1 year ago

Yes everything is working as it should. Action button and macro all work without have the fix cast option on. No LUA errors caught by Bugsack.

Thank you all for the help in correcting this issue. SmartBuff has become one of my must have mods, and it was driving me crazy not being able to use it.