Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 09:06 PM.


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