lfnetwork.com mark read register faq members calendar

Thread: Scripting Etiquette/Syntax
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 06-25-2009, 12:27 PM   #1
gsusfrk
Rookie
 
gsusfrk's Avatar
 
Join Date: Jun 2009
Location: Waiting to stage an ambush
Posts: 40
Current Game: COD:WAW and KOTOR II
Scripting Etiquette/Syntax

A very general question... When scripting, does it matter if I repeatedly make a call to a method/function instead of calling it once and assigning it to a variable? For example, is this:

Code:
void main()
{
    AssignCommand(GetFirstPC(), ActionTakeItem("some_item", GetFirstPC()));
    SendMessageToPC(GetFirstPC(), "Removed Item from inventory");
}
...the same as this?

Code:
void main()
{
    object oPlayer = GetFirstPC();
    AssignCommand(oPlayer, ActionTakeItem("some_item", oPlayer));
    SendMessageToPC(oPlayer, "Removed Item from inventory");
}
Does either one have the advantage over the other? Other than readability, the second script doesn't seem to have any advantage over the first. I've coded with Java before, and in Java the two scripts would be exactly the same (unless the value of GetFirstPC() changes between its calls, which in this case, wouldn't happen). Do the same principles apply here?

One more question: what kind of rules should I follow when naming a script? Is there anything I should avoid, such as starting script names with numbers/certain characters, or the length of the name, etc.? Thanks a lot!


gsusfrk is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Scripting Etiquette/Syntax

Thread Tools
Display Modes

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 -4. The time now is 06:49 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.