Archive: New edit box in codable effects


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).


4th March 2004 20:57 UTC

As far as saving variables goes, the limit was removed in the latest version of AVS so don't worry about that. And executed code in the frame box really shouldn't slow AVS down noticably unless you are using very large loops. I should know--one of my presets has about 200 lines of code in the frame box (although I'll admit that not all lines are executed each frame, but the majority are). When I removed the code, I saw no increase in speed at all, at most it was .1 or .2 frames per second (and the framerate was about 100fps, so small changes should have been noticable).