Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
744 views
in Technique[技术] by (71.8m points)

lua - How can I make this no recoil script do an additional movement of my mouse?

Im brand new at scripting and have no idea what im doing. Found the below code online and want it to make adjustments. So basically, in fallout 4 lets say a gun's recoil goes to up and to the left originally, but then halfway into shooting it goes to the right. I want the script to initially be able to pull the mouse down and to the right, and then (when the guns recoil starts to go in the other direction) go to the left. Is this possible?


EnablePrimaryMouseButtonEvents (true);

function OnEvent(event,arg)
   if IsKeyLockOn("numlock")then
      if IsMouseButtonPressed(3)then
         repeat
            if IsMouseButtonPressed(1) then
               repeat
                  MoveMouseRelative(-1,13)
                  Sleep(75)
               until not IsMouseButtonPressed(1)
            end
         until not IsMouseButtonPressed(3)
      end
   end
end

Above is a script I use to move my mouse down when pressing the shooting buttons in Fallout 4 because I have problems which prevent me from countering recoil.

I want the script to not only move down and slightly to the left (MoveMouseRelative(-1,13)) but I want to be able to specify that after a certain amount of time, I then want the script to move in a different direction that again, I can specify.

How would I do this? I believe this is a LUA script or something, and im using a logitech mouse


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)

   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsMouseButtonPressed(3) and IsKeyLockOn("numlock") then
      -- first group of moves: 10 steps in direction (-1,13), total group time = 750 ms
      for i = 1, 10 do
         MoveMouseRelative(-1,13)
         Sleep(75)
         if not IsMouseButtonPressed(1) then return end
      end
      -- second group of moves: 5 steps in direction (1,12), total group time = 375 ms
      for i = 1, 5 do
         MoveMouseRelative(1,12)
         Sleep(75)
         if not IsMouseButtonPressed(1) then return end
      end
      -- you can add more groups
   end

   if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsMouseButtonPressed(3) and IsKeyLockOn("scrolllock") then
      -- first group of moves: 10 steps in direction (-1,13), total group time = 750 ms
      for i = 1, 10 do
         MoveMouseRelative(-1,13)
         Sleep(75)
         if not IsMouseButtonPressed(1) then return end
      end
      -- second group of moves: 5 steps in direction (1,12), total group time = 375 ms
      for i = 1, 5 do
         MoveMouseRelative(1,12)
         Sleep(75)
         if not IsMouseButtonPressed(1) then return end
      end
      -- you can add more groups
   end

end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...