• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

G-Series Script Problem After G Hub Update (1 Viewer)

Logitech G-Series (e.g. G HUB)

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
Hello all,
Can anyone help me to fix this error?

I am not familiar with LUA Script writing. I am trying to learn and am asking for some help with a script that was made to assist ppl with online games that utilize a recoil system. This particular script is written for a game called Players Unknown Battlegrounds. It helps me to correct the recoil as I am disabled and cannot do the proper pull down that is required with a mouse in order to compete and enjoy this game. I have used this script for a couple of years now and after the last G HUB update, I cannot get it to work anymore.

The error I am getting is this: [string "LuaVM"]:212: attempt to call a nil value (field 'pow').

Code:
--------------------------------------------------------------------------
----------------          Function          ------------------------------
--------------------------------------------------------------------------


function convert_sens(unconvertedSens) 
    return 0.002 * math.pow(10, unconvertedSens / 50)
end

I attached the entire lua script for reference.

Thanks in advance. I do hope someone can help as I really enjoy playing this game.
 

Attachments

  • PUBG.lua
    15.7 KB · Views: 3

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
The last G HUB update upgraded to Lua 5.4.

Lua's math.pow was deprecated as of Lua 5.3

Therefore, use Lua's built-in ^ exponentiation operator instead of the math.pow function.

In other words, do this:
Code:
return 0.002 * 10^(unconvertedSens / 50)

Instead of this:
Code:
return 0.002 * math.pow(10, unconvertedSens / 50)
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
The last G HUB update upgraded from Lua 5.3 to Lua 5.4.

Lua's math.pow was deprecated as of Lua 5.3

Therefore, use Lua's built-in ^ exponentiation operator instead of the math.pow function.

In other words, do this:
Code:
return 0.002 * 10^(unconvertedSens / 50)

Instead of this:
Code:
return 0.002 * math.pow(10, unconvertedSens / 50)
Awesome I will give it a try. Thank You.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
That was it...I believe it is working now. I got no error!
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
The last G HUB update upgraded from Lua 5.3 to Lua 5.4.

Lua's math.pow was deprecated as of Lua 5.3

Therefore, use Lua's built-in ^ exponentiation operator instead of the math.pow function.

In other words, do this:
Code:
return 0.002 * 10^(unconvertedSens / 50)

Instead of this:
Code:
return 0.002 * math.pow(10, unconvertedSens / 50)
Darn.
That got rid of an error showing but the script isn't working now.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
There are other areas that refer to math in the script. Should i replace them with ^ where "math" is or will this work?
I have found:
math.floor
math.random
in a couple of areas when searching for the word "math"
 

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
Awesome I will give it a try. Thank You.
That was it...I believe it is working now. I got no error!
Darn.
That got rid of an error showing but the script isn't working now.
There are other areas that refer to math in the script. Should i replace them with ^ where "math" is or will this work?
No, only math.pow should be changed to the ^ operator.

It's hard to say why the script isn't working if there are no error messages.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
the script is supposed to create a pull down for the mouse at different speeds while in game. it doesn't have any effect now. Not sure what to do at this point.
 

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
the script is supposed to create a pull down for the mouse at different speeds while in game. it doesn't have any effect now. Not sure what to do at this point.
The first line in the onEvent function is:
Code:
OutputLogMessage("event = %s, arg = %d\n", event, arg)

This line logs what the event and arg is.

When you press the desired button, what does it log?

Please add the entire log here.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
The only area I see a log is when I am editing the lua script within G Hub. Is this what you mean?
I attached a screenshot of the log. I pressed a few of the mouse buttons.
 

Attachments

  • Screenshot 2021-07-13 085703.jpg
    Screenshot 2021-07-13 085703.jpg
    140.7 KB · Views: 1

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
What arg code do you get when you press the desired button and recoil should happen?

Edit: Does pressing/releasing 'M' have something to do with recoil?

Douile/logitech-toggle-keys
 
Last edited:

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
Not sure where to find this. The only log I am able to see is when i am in editing mode within G Hub and that is what I posted previously. Where can I find this? The only thing I can notice is that when the script is working, my cursor will move down the screen when not in game.
 

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
Not sure where to find this. The only log I am able to see is when i am in editing mode within G Hub and that is what I posted previously. Where can I find this? The only thing I can notice is that when the script is working, my cursor will move down the screen when not in game.
I meant the arg (equal to some number) in the log.

It works correctly outside PUBG? In that case, run the script (G Hub) as an administrator if you're on Windows.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
All I get is what was shown in the previous log from within the editing screen of the LUA script. It did work outside of PUBG (before the GHUB Update) . So if I have NUMlock on, And press one of the mouse buttons that is set to a specific weapon, then my cursor will move down my screen or in an application. there is a "Set Off" button that is assigned so I can stop the script from working. I do not see any other reference to arg than in the log. It does not work at all after the G Hub update (In or out of game).
 

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
All I get is what was shown in the previous log from within the editing screen of the LUA script. It did work outside of PUBG (before the GHUB Update) . So if I have NUMlock on, And press one of the mouse buttons that is set to a specific weapon, then my cursor will move down my screen or in an application. there is a "Set Off" button that is assigned so I can stop the script from working. I do not see any other reference to arg than in the log. It does not work at all after the G Hub update (In or out of game).
The easiest would probably be to uninstall G HUB and download an earlier version of G HUB.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
The easiest would probably be to uninstall G HUB and download an earlier version of G HUB.
YES that would be great if I could do that. I just gat a new gaming PC and I cannot get the previous version to install. I have spent hours trying to get it to install. I re installed windows yesterday just to see if that would work and still cannot install. I have tried a few older versions of GHub and all of them get stuck during install. I even had a tech from MainGear (who built my PC) Try and he could not figure out what the issue is.
 

Latem

Newcomer
Joined
Jul 12, 2021
Messages
12
Reaction score
1
I was reading another post where someone was getting the same error as me and he had mentioned that he may have to new a new function.
The interesting thing is your fix worked to clear the error and it also shows as if it is functioning except for the actual mouse movement. When the script is on, the scroll lock is supposed to light up and it does.
 

225559

Newcomer
Joined
Nov 17, 2020
Messages
15
Reaction score
4
YES that would be great if I could do that. I just gat a new gaming PC and I cannot get the previous version to install. I have spent hours trying to get it to install. I re installed windows yesterday just to see if that would work and still cannot install. I have tried a few older versions of GHub and all of them get stuck during install. I even had a tech from MainGear (who built my PC) Try and he could not figure out what the issue is.
Are you getting any errors when it gets stuck? Is there any installation log file you can check?

I was reading another post where someone was getting the same error as me and he had mentioned that he may have to new a new function.
The interesting thing is your fix worked to clear the error and it also shows as if it is functioning except for the actual mouse movement. When the script is on, the scroll lock is supposed to light up and it does.
Did you try running G HUB with administrator rights? PUBG probably runs with administrator rights by default. If it does, the script won't have sufficient privileges to move the mouse inside PUBG, unless it has administrator rights as well.

Your first task is to just get the script do anything inside PUBG. Next, you can find out which part of the script is broken (if any).
 
Top