You are confusing local variables (set with
var) and global variables (set with
set). When you
var a local variable
%var, it is only available inside the alias/popup/event script in which it was created. When you
set a global variable
%set, it is available (viewable or changable) by any script that is looking for it. It is one of the main ways scripters pass information between events since the variable is not destroyed when the script ends.
/counting {
set %c 1.009
var %num = %c
%c = 2
variables
echo -a %num
}
When
/counting runs, it sets up a global variable
%c and sets it equal to 1.009. Next, the local variable
%num is created and set equal to
%c; both variables now equal 1.009. Next,
%c is changed to equal 2.
/variables is called to do it's job.
/variables {
var %num = %c
}
The
/variables alias will accomplish exactly nothing whatsoever. It will just create a local variable
%num, set its value to whatever is current stored in the global variable
%c (2), and that's it. It doesn't do anything with
%num, and
%num is destroyed as soon as
/variables ends. Note that
/variables does not know anything about the
%num that was set up in
/counting.
/variables only knows about its
own %num, though it can see
%c because
%c used
set, not
var.
Control is returned to
/counting with its
%c (2) and
%num (1.009) unchanged by anything done by
/variables. Therefore, when
/counting echoes out the current value of
%num, it will echo out 1.009.
When
/counting itself completes,
%num will be destroyed and
%c will retain its value of 2 until another script changes its value or unsets it.