1
votes

I'm trying to have two inputs that will lead to one output. This is so I can use an ability in a game thanks if you can help.

function OnEvent(event, arg) 
     if event == "MOUSE_BUTTON_PRESSED" and arg == 2 then --set flag for mb2
            mb2_pressed = true
    elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 then --set flag for mb2=false
        mb2_pressed = false
    else if event == "LSHIFT_BUTTON_PRESSED" and arg == 1 then
    leftshift_pressed = true
    else if event == "LSHIFT_BUTTON_RELEASED" and arg == 1 then
    leftshift_pressed = false
    end
end

if leftshift_pressed and  if mb2_pressed then
presskey("9")
        Sleep(50)
        releasekey("9")
end
end

https://gyazo.com/7e7f2139fabb22d1e06f8f3f169cb4bb

1
And where do you have a problem?Tsahi Asher
theres a syntax error im getting gyazo.com/3e9daf401e4a4baaf219f01f96fd0a7cShane

1 Answers

1
votes
function OnEvent(event, arg)
   if event == "MOUSE_BUTTON_PRESSED" and arg == 2 and IsModifierPressed("lshift") then
      PressAndReleaseKey("lshift")
      PressAndReleaseKey("9")
   end
end

You should know the following:

  • LGS/GHUB has a bug in line numbering, "line 12" in error message actually means line#13 in your code (and red stripe is also set at wrong position)
  • if leftshift_pressed and if mb2_pressed then is a syntax error, you should write if leftshift_pressed and mb2_pressed then
  • if/elseif/else/end must be balanced. Yours are not. Use indentation in the code to make it obvious.
  • There is no event LSHIFT_BUTTON_PRESSED, you receives events only from G-buttons (all buttons on Logitech mouse and special G-buttons on Logitech keyboard).
  • Uppercase is different from lowercase: PressKey is not the same as presskey