View Single Post
  #1  
Old 10-19-2006, 08:54 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Function library efficiency

Which of the following cases would be more efficient? I'm pretty sure I know which, but I'd like some input from eithers.
Both cases are clientside.

The first case (a) is to create a class to hold groups of functions, then join it to NPCs that require functions that deal with certain objects.
i.e.
PHP Code:
// Class - mudfunctions
//#CLIENTSIDE
function GetItemPower(itemid) {
  return (@
"item-" itemid).power;

PHP Code:
// Some other weapon
//#CLIENTSIDE
function onCreated() {
  
join("mudfunctions");
  echo(
GetItemPower(3324));

The second case (b) is to create a weapon for each group of functions and refer a global variable to itself in the onCreated block.
i.e.
PHP Code:
// Weapon - MUD Library Functions
//#CLIENTSIDE
function onCreated() {
  
mud this;
}

public function 
GetItemPower(itemid) {
  return (@
"item-" itemid).power;

PHP Code:
// Some other weapon
//#CLIENTSIDE
function onCreated() {
  echo(
mud.GetItemPower(3324));

Reply With Quote