0
votes

logiteck api (http://www.wolfpack.pe.kr/attachment/1180489860.pdf) trying to make a mouse script that presses a button for a certain amount of time and then makes a turn 180 degrees ingame: However not being sure of what my mouse sensitivity will be i want to make it adapt to my mouse sensitivity so:

  1. when I press right button to begins to turn right until I release it stores the number of repeats for that turn in the i variable

  2. it holds that variable for the second function where the program initially press "w" for me to move (unimportant) and then has a small delay (the small for loop). My player walks for that delay and then the i variable is used to simulate that exact turn I made before

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
if IsMouseButtonPressed(3)then
i=1
                repeat
i=i +1
                    MoveMouseRelative(3,0)
                    Sleep(5)
                until not IsMouseButtonPressed(3)
                  end

end

function oniEvent(event, arg)
if IsKeyLockOn("numlock" )then
PressKey( "w" );

repeat
u=0
j=1

for k=1,999,1 do j=j/2 
////delay////
 end 

repeat
u=u + 1 
                    MoveMouseRelative(3,0)
                    Sleep(5)
                until  u==i




until  not IsKeyLockOn("numlock" )
ReleaseKey( "w" );


end
end

Problem: when I press numlock it does even start pressing "w"

1

1 Answers

0
votes

There seems to be a misunderstanding.

Defining a function does nothing but to define that function. The code in its body is only executed if you call the function.

As you only define oniEvent, but never call it, your code does what is to be expected: nothing.

If you want to react to mouse or key input you have to implement that in the OnEvent function which serves as the event handler and is called automatically whenever there is an event.

Please read the manual again. There are plenty of examples.