View Single Post
  #1  
Old 01-12-2008, 05:43 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
A Few Functions For Checking

PHP Code:
/*
  This is an object class meaning it needs to be joined to a prior created object such as a TStaticVar() or a weaponNPC.

  And is called as such:

  obj.(function right here without parenthesis)(params)

*/

public function hasFunc(func) {
  if (
func in this.getfunctions())
    return 
true;
  return 
false;
}
public function 
isDynamicFunc(func) {
  if (
func in this.getdynamicvarnames())
    return 
true;
  return 
false;
}
public function 
hasVar(var) {
  if (var 
in this.getdynamicvarnames()) {
    if (
isValidVar(var))
      return 
true;
  }
  return 
false;
}
public function 
isValidVar(var) {
  if (
this.(@ var) != null)
    return 
true;
  return 
false;

Hopefully, these will make it easier for scripters here and there to code their systems with ease and not get confuse when doing a crap load of var checks, and etc etc.

I often get confused when doing a crapload of checks and I've always found it easier to do:

PHP Code:
if (!obj.hasVar(var))
  continue; 
As opposed to:

PHP Code:
if (obj.(@ var) == null)
  continue; 
I think it looks nicer/neater but maybe I'm just being picky. Use as you feel necessary.
__________________
Stan.
Reply With Quote