Author Topic: Why does this work?  (Read 1056 times)

function autoClick(){cancel($autSch);mousefire(1);$autSch=schedule(30,0,mousefire,0);}
For some reason this is an autoclicker. I don't understand how it functions this way without recursion.

All that does is click and un-click. There is no recursion. Schedule autoClick within itself to add recursion.

hold on
http://youtu.be/gKaIqYU9z7A
i typed that code exactly. as you can see it is autoclicking.

Just add the function schedule like what Greek mentioned.

It does not autoclick for me. It clicks once.

I think I've got it. I do have some scripts which include "function autoclick" but I thought that by defining the function the old code would be overwritten. Apparently I was mistaken?

This function actually just clicks once and does nothing else. It should schedule a call to itself so that it repeats.

Code: [Select]
function autoClick()
{
    cancel($autSch);
    mousefire(1);
    schedule(30,0,mousefire,0);
    $autSch = schedule(60, 0, autoClick);
}

The "cancel" call will stop another cycle of auto clicks from continuing.

Okay. I'm still confused. If I type
Code: [Select]
function foo(%bar){echo(%bar * 2);}in a client.cs file, and package it and put it in Add-Ons, then boot up and type
Code: [Select]
function foo(%bar){echo(%bar / 2);}followed by foo(2); Do I get 4 or 1?

The second one, because it will overwrite the original. With packages the story would be different.

Suppose the first one is packaged. What then?

I just tested it and contrary to what I thought, the engine just ignores the redeclaration of a function already in a package.

Code: [Select]
package stuff{ function a() { echo("num1"); } }; activatepackage(stuff); function a() { echo("num2"); } a();

That's really interesting. Thanks Kalphiter.