Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Curiosity... (https://forums.graalonline.com/forums/showthread.php?t=81118)

Kristi 08-08-2008 05:57 PM

Curiosity...
 
Am I the only person that avoids using "with" as much as possible?

Whenever I create an object of any sort, I assign it a pointer. If the object is already created, I give it a pointer.

ex: temp.ani = showani(...);
temp.ani.prop = value;

When I have long lists of things, it seems easier to just glance at my code and see exactly what is going on, instead of tracing back with blocks.

What do you do and why? Discuss!

Crono 08-08-2008 06:00 PM

I never use with.

Stryke 08-08-2008 06:01 PM

I use with only with findimgs

DrakilorP2P 08-08-2008 06:33 PM

thiso. eww.

DustyPorViva 08-08-2008 06:49 PM

It depends on how many values of the object I am changing.

Chompy 08-08-2008 06:52 PM

Quote:

Originally Posted by DustyPorViva (Post 1412569)
It depends on how many values of the object I am changing.

Same here

cbk1994 08-08-2008 07:07 PM

Quote:

Originally Posted by Chompy (Post 1412570)
Same here

Agreed.

Crow 08-08-2008 07:12 PM

Quote:

Originally Posted by cbk1994 (Post 1412577)
Agreed.

Seconded.

LoneAngelIbesu 08-08-2008 07:24 PM

Quote:

Originally Posted by DustyPorViva (Post 1412569)
It depends on how many values of the object I am changing.

Yup, same here. As a rule of thumb, if I'm changing three or more values, I use with.

I mean, really... which one looks better? It may be more lines, but I guess I'm a block kind of guy. :cool:
PHP Code:

function TheParentObject.onMove(newxnewy) {
  
TheObject.newx TheParentObject.width 10;
  
TheObject.newy;
  
TheObject.text "Has been moved with parent object";
}
function 
TheParentObject.onMove(newxnewy) {
  
with(TheObject) {
    
this.newx TheParentObject.width 10;
    
this.newy;
    
this.text "Has been moved with parent object";
  }



Kristi 08-08-2008 07:27 PM

The top one looks better, and would look even better if you lined up your equal signs *tsktsk*

Dan 08-08-2008 07:30 PM

For me it kind of depends on the length of the object name, I found out (but never thought about).

Example;
PHP Code:

temp.object putnpc2(params[1][0],params[1][1],"");
temp.object.image params[2][0];
if (
params[2][1] == "")
  return;
temp.object.join(params[2][1]); 

or;
PHP Code:

with (@ genGUIName("Window_Scroll_EditMission_Scroll_List")) {
  
clearRows();
  for (
temp.1temp.<= mission.missionslist.size(); temp.++)
    
addRow(- 1,"Mission " temp.i);



Crow 08-08-2008 07:31 PM

Quote:

Originally Posted by Kristi (Post 1412587)
The top one looks better, and would look even better if you lined up your equal signs *tsktsk*

Lining up equal signs doesn't look cool if you ask me. I agree that the top one looks better in that case though. I only use with when I have to change more than 4 or 5 things.

LoneAngelIbesu 08-08-2008 07:31 PM

Quote:

Originally Posted by Kristi (Post 1412587)
The top one looks better, and would look even better if you lined up your equal signs *tsktsk*

I'm too lazy to press my space bar that many times. :) Another thing that I like about using with() is when there are really long object names. I try as hard as possible not make the horizontal scrollbar appear... but, I do that with everything.

Crow 08-08-2008 07:33 PM

Quote:

Originally Posted by LoneAngelIbesu (Post 1412590)
I'm too lazy to press my space bar that many times. :) Another thing that I like about using with() is when there are really long object names. I try as hard as possible not make the horizontal scrollbar appear... but, I do that with everything.

Tab key adds 2 spaces, and I don't think long object names are an excuse. You could just do something like this:

PHP Code:

temp.obj PrettyDamnLongObjectNameHere;
temp.obj.doStuff(); 


LoneAngelIbesu 08-08-2008 07:38 PM

Quote:

Originally Posted by Crow (Post 1412593)
Tab key adds 2 spaces, and I don't think long object names are an excuse. You could just do something like this:

PHP Code:

temp.obj PrettyDamnLongObjectNameHere;
temp.obj.doStuff(); 


Not when the object stuff is already nested four, five, six, etc. times. ;) The horizontal scrollbar is a personal challenge. I usually lose though... but when I do, I resize the window and it's like it never happened. /I'm crazy. I have mild symmetry compulsions. :'(

Besides, there are no excuses. Using with() is all about personal preference. Same about lining up equal signs.


All times are GMT +2. The time now is 10:27 PM.

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