meko
Core Developers
- Messages
- 363
- Points
- 0
- IRC Nickname
- meko
- Github
- Helianthella
- Emulator
- Hercules
- Client Version
- ManaPlus
When a function is invoked, the arguments are pushed to the stack, but if an argument is a scope variable its reference is also pushed. This means you can access variables of the parent scope from within a function.
Code:
function do_something {
setarray(getarg(0), 69, 42, 1337);
return;
}
debugmes(.@var[0]); // <= 0
debugmes(.@var[1]); // <= 0
debugmes(.@var[2]); // <= 0
do_something(.@var[0]);
debugmes(.@var[0]); // <= 69
debugmes(.@var[1]); // <= 42
debugmes(.@var[2]); // <= 1337