4th March 2004 15:43 UTC
New edit box in codable effects
I was thinking of an On KbMouse edit box in AVS' codable effects. Now we use getkbmouse on frame. OK. To get the key it's simple. But how to fix the result? Yes it's an easy code (when you know it), but more simple if we have an on kbmouse edit box which code is executed everytime a key is pressed (this also can save fps, i think).
So instead of (i took my mouse press detection):
ONFRAME:
*code locating mouse position*
in=cx&cy; //check if both coordinates are in range
mb=getkbmouse(3); //check if mouse is pressed
pip=in&mb; //check if mouse pressed in range
p=(p+pip)*pip; //is like when you press the button, it's keeps adding up, but when you release it becomes 0
reg10=if(equal(p,1),bnot(reg10),reg10); //if there is press, makes reg10, if 0 then 1, if 1 then 0 (bnot), if there is no press, then it remains what it was. you can't just use pip instead of p because it remains 1 all the time if there is press so it keeps bnot'ing.
We can use:
ONKBMOUSE:
*code locating mouse position*
in=cx&cy;
mb=getkbmouse(3);
pip=in&mb;
reg10=if(pip,bnot(reg10),reg10); //we removed p because this ONKBMOUSE executes only when key is pressed, when there is keydown or smth. it doesn't execute while key is pressed, it executes when it is pressed.
So we save 1 variable, and code doesn't execute every frame doing nothing (when key not pressed).