Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-08-2008, 05:57 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
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!
__________________
Reply With Quote
  #2  
Old 08-08-2008, 06:00 PM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
I never use with.
__________________
Reply With Quote
  #3  
Old 08-08-2008, 06:01 PM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
I use with only with findimgs
Reply With Quote
  #4  
Old 08-08-2008, 06:33 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
thiso. eww.
Reply With Quote
  #5  
Old 08-08-2008, 06:49 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
It depends on how many values of the object I am changing.
Reply With Quote
  #6  
Old 08-08-2008, 06:52 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
It depends on how many values of the object I am changing.
Same here
__________________
Reply With Quote
  #7  
Old 08-08-2008, 07:07 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Chompy View Post
Same here
Agreed.
__________________
Reply With Quote
  #8  
Old 08-08-2008, 07:12 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
Agreed.
Seconded.
__________________
Reply With Quote
  #9  
Old 08-08-2008, 07:24 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by DustyPorViva View Post
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.
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";
  }

__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #10  
Old 08-08-2008, 07:27 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
The top one looks better, and would look even better if you lined up your equal signs *tsktsk*
__________________
Reply With Quote
  #11  
Old 08-08-2008, 07:30 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
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);

__________________
Reply With Quote
  #12  
Old 08-08-2008, 07:31 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Kristi View Post
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.
__________________
Reply With Quote
  #13  
Old 08-08-2008, 07:31 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Kristi View Post
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.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #14  
Old 08-08-2008, 07:33 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by LoneAngelIbesu View Post
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(); 
__________________
Reply With Quote
  #15  
Old 08-08-2008, 07:38 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Crow View Post
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.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
Reply


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 03:10 PM.


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