Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

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


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 04:51 AM.


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