Quote:
Originally Posted by Devil_Lord2
 I don't get it...
|
You should think in terms of expressions. When a script runs, it evaluates/reduces expressions.
Let's start with some hypothetical weapon script:
PHP Code:
function test(temp.x) {
return temp.x+2;
}
function onWeaponFired() {
temp.x = this.test(10);
echo(temp.x);
}
And now, say this weapon is fired. This means we will be running the code:
PHP Code:
temp.x = this.test(10);
echo(temp.x);
Let's see what happens...
Step 1
On the first line, we need to call the
test function with the value
10.
When a function is run, we can replace the spot it was called at with the value it returns.
So, after
test runs, this is what we have:
PHP Code:
temp.x = 12;
echo(temp.x);
Step 2
And of course, this step is fairly simple...
So we get:
Step 3
That code will be executed and will display
12 in the F2 console.
This method of evaluating scripts by hand can be very useful when trying to understand how one works (though it's normally done in your head).