Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-22-2005, 03:09 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
Quote:
Originally Posted by ApothiX
That is so redundant.

with() is what you use so you don't have to use the prefix.
I personally find it easier to use the prefix.
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
  #2  
Old 02-22-2005, 05:17 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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).
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.