
02-22-2005, 05:17 AM
|
|
Graal Administration
|
Join Date: Jan 2000
Location: Admins
Posts: 11,693
|
|
|
The "with" command is kinda changing the environment - by default variables and functions without prefix are either mapped onto the current npc or the current player. With "with" you can change the current npc or current player, so that functions without prefix are mapped onto other objects, in old scripting engine this was the only way to warp another player because "setlevel2" is always warping the "current" player.
Only a few variables were accessible with prefix (players[index].x etc.) in the old engine. In the new engine everything is accessible directly, so you can access numeric attributes like "x" or "y", string attributes like "account" or "nick", built-in functions like "setlevel2" or "setani" or even script functions of other objects, e.g. StatsDatabase.addStatsForPlayer(player), if you declare a function as "public function".
So the with-command is not really needed anymore, but often very useful if you want to do a lot of operations on an object, also it can sometimes be faster, although some script optimizations are disabled inside with-blocks (because the lookup of this. numeric variables is changed, this is different to old scripting engine). |
|
|
|