gsusfrk Posted June 25, 2009 Share Posted June 25, 2009 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: void main() { AssignCommand(GetFirstPC(), ActionTakeItem("some_item", GetFirstPC())); SendMessageToPC(GetFirstPC(), "Removed Item from inventory"); } ...the same as this? 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! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.