Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-06-2007, 02:37 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Custom Classes!

Yea... I was talking with Stan, and I was like 'you can't make custom classes using the new operator'... And it dawned: A function call is what you need. Taking inspiration from Java, I created a custom-class.

class manager: (DB: Class )
PHP Code:
public function createClassclassNameclasses )
{
  if ( (@ 
className ) != null )
    (@ 
className ).destroy();

  
// Create what it means to be an object...
  
echo("Creating class" SPC className );
  
temp.newClass = new TStaticVar( (@className) );
  
temp.newClass.join"test_custom_class" );
  
temp.newClass.classes classes;
  
  
// Don't let the garabe collecter get this!
  
this.classes.addtemp.newClass );
}

public function 
getClasses()
{
  return 
this.classes;

custom class script: (test_custom_class)
PHP Code:
public function newInstanceobjectName )
{
  if ( (@ 
objectName ) != null )
    (@ 
objectName ).destroy();

  
temp.newInstance = new TStaticVar( @objectName );
  for ( 
temp.cjointhis.classes )
  {
    
temp.newInstance.jointemp.cjoin );
  }
  
  
temp.newInstance.class = this;
  return 
temp.newInstance;

Testing Class: (test_tnode)
PHP Code:
/**
 * Nodes Interface for PathFinder
 *
 * (+) void connect( Node node, ... );
 * (+) void disconnect( Node nodes );
 * (+) Node[] getNodes();
 * (+) Node[] findPath( Node goal );
 **/
 
/**
  * This connects a node to the node-list.
  *
  * @param node Node, any object that could be treated as a Node.
  *                If used to connect afterwards, add Node interface!
  **/
public function connect()
{
  for ( 
temp.nodeparams )
  {
    if ( 
temp.node == null )
      return;
    if ( 
temp.node in this.nodes )
      return;
  
    
this.nodes.addtemp.node );
  }
}

/**
  * This removes a node to the node-list.
  *
  * @param node, ... Node, any object that could be treated as a Node.
  **/
public function disconnectnode )
{
  
this.nodes.removenode );
}

/**
  * This obtains the nodes that are currently connected to the object.
  *
  * @return Node[] List of nodes attached to object
  **/

public function getNodes()
{
  return 
this.nodes;
}

/**
  * This calculates the shortest distance to a particular node.
  *
  * @return Node[] An ordered list of the nodes that need to be traveled
  *                    to reach given destination.
  **/
public function findPathendNode )
{
  
temp.nodeList.add( {this, new[0]} );
  
temp.nodeIndex 0;
  while ( 
temp.nodeList.size() > temp.nodeIndex )
  {
    
temp.node temp.nodeListtemp.nodeIndex ][0];
    
temp.nodePath temp.nodeListtemp.nodeIndex ][1];
    
temp.nodePath.addtemp.node );
    if ( 
temp.node == endNode )
      return 
temp.nodePath;

    for ( 
temp.subnodenode.getNodes() )
    {
      if ( 
temp.subnode in temp.nodeList )
          continue;

      
temp.nodeList.add( { temp.subnodetemp.nodePath } );
    }
    
temp.nodeIndex ++;
  }

  return 
null;

Example of Usage:
PHP Code:
function onCreated()
{
  Class.
createClass"TNode", {"test_tnode"} );

  
node1 TNode.newInstance("N1");
  
node2 TNode.newInstance("N2");
  
node3 TNode.newInstance("N3");
  
node4 TNode.newInstance("N4");

  
node1.connectnode2 );
  
node2.connectnode3node4 );
  
node3.connectnode4 );
  
  
nodePath node1.findPathnode4 );

  echo(
"Path:");
  for ( 
nodenodePath )
    echo( 
node.name );
}

/** Output **
The script of NPC Class has been updated by Novo
Creating class TNode
Path:
N1
N2
N4
**/ 

Reply With Quote
  #2  
Old 12-06-2007, 02:54 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Shouldn't this be in code gallery?
Reply With Quote
  #3  
Old 12-06-2007, 03:18 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
Yea... I was talking with Stan, and I was like 'you can't make custom classes using the new operator'
The new operator can be used with an object name or the name of an object type, and when used with an existing object it copies all variables to the new object including this.joinedclasses, causing the classes in the copied object to be joined to the new object.
PHP Code:
public function onCreated() {
  
temp.0;
  
this.scriptlogmissingfunctions false;
  
this.types null;
  
// MudObjects
  
maketype("MudObject"null, {"util_triggerall""util_schedulefunction""type_mudobject"});
  
maketype("MudPlayer"TMudObject, {"type_mudplayer"});
  
maketype("MudItem"null, {"util_schedulefunction""type_muditem"});
  
// Dialog
  
maketype("DialogTopic"null, {"type_dialogtopic"});
  
maketype("DialogResponse"null, {"type_dialogresponse"});
  
maketype("DialogCondition"null, {"type_dialogcondition"});
  
// Misc
  
maketype("IniFile"null, {"type_inifile"});
  
maketype("DataFile"null, {"type_datafile"});
  
maketype("Rectangle"null, {"type_rectangle"});
  
this.created true;
}
public function 
maketype(typenamesuperclasses) {
  
temp.0;
  if (
makevar("T"@typename) != null) {
    
makevar("T"@typename).destroy();
  }
  
this.(@ "type_" typename) = new TStaticVar("T"@typename);
  if (
super.type() == 2) {
    
this.(@ "type_" typename).joinedclasses super.joinedclasses;
  }
  for (
iclasses) {
    
this.(@ "type_" typename).join(i);
  }
  if (
this.types.index("T"@typename) < 0) {
    
this.types.add("T"@typename);
  }

PHP Code:
// Use
function onCreated() {
  
temp.obj 0;

  
obj = new TIniFile();
  
obj.load("data/news.ini");
  
// More Stuff
  
obj.destroy();

  
obj = new TRectangle();
  
obj.20;
  
obj.20;
  
obj.32;
  
obj.32;
  if (
obj.contains(player.xplayer.y))
    echo(
"Yep!");
  else
    echo(
"Nope");
  
obj.destroy();

__________________
Reply With Quote
  #4  
Old 12-06-2007, 04:19 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Inverness View Post
...
Hrm! That's a bit weird. Ohwell. Either way.
Reply With Quote
  #5  
Old 12-06-2007, 12:50 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Though I'd like if there was a function called in the class when it was joined and had to be completed before the next class could be joined.

onCreated does not work like this
__________________
Reply With Quote
  #6  
Old 12-06-2007, 04:07 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Osnap, Inver beat you to it, Novo.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #7  
Old 12-06-2007, 10:19 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by coreys View Post
Osnap, Inver beat you to it, Novo.
O,o; We're racing?
Reply With Quote
  #8  
Old 12-06-2007, 11:57 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
O,o; We're racing?
Racing is fun, yes?
__________________
Reply With Quote
  #9  
Old 12-07-2007, 12:44 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Inverness View Post
Racing is fun, yes?
I agree!
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #10  
Old 12-09-2007, 05:46 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Inverness View Post
onCreated does not work like this
PHP Code:
public function newInstanceparamobjectName )
{
  if ( 
objectName != "" )
    if ( (@ 
objectName ).type() == )
      (@ 
objectName ).destroy();

  
// Initialize Class
  
if ( objectName == "" )
    
temp.newInstance = new TStaticVar();
  else 
temp.newInstance = new TStaticVar( @objectName );

  
temp.newInstance.class = this;
  
temp.newInstance.join( ("class_"this.name).lower() );

  
// Initialize Object
  
if ( this.name in temp.newInstance.getfunctions() )
    
temp.newInstance.(@ this.name )( param );

  return 
temp.newInstance;

I made a turnaround for that onCreated problem. Basically, the newInstance() would call the constructor for the class ( thus, TNode )

PHP Code:
public function TNode() { foo; } 
Makes sure that the initialize variables are initialized immediately.

Such as:
PHP Code:
function onCreated()
{
 array = 
TMap.newInstance( {{"Test3""333"}} );
 array.
put("Test"123);
 array.
put("Test2"123);
 array.
put("Test"321);
 echo( array.
toString() ); // output: "Test3,333","Test,321","Test2,123"

EDIT: I'm thinking of having an inheritance system working out... So one could probably do an object.class.instanceof( otherclass )... Something along the lines of:
PHP Code:
public function instanceOf( class )
{
  if ( 
this == class )
    return 
true;
  
// for ( superClass: superClasses )
  //   if ( superClass.instanceOf( class ) )
  //      return true;
  
return false;

Reply With Quote
  #11  
Old 12-09-2007, 07:20 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
You're overdoing it as far as Graal goes :P

I tried doing something like that for my Mud system and making it modular and stuff, but its easier to just make a class that does everything at once.
__________________
Reply With Quote
  #12  
Old 12-09-2007, 07:28 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
I actually went ahead and did it anyways... So I added inheritance and static functions... :: hums ::

Bah. For some reason, I can't sent it over forums. It says there's a bad request that the server can't understand.
Reply With Quote
  #13  
Old 12-09-2007, 07:33 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Novo View Post
I actually went ahead and did it anyways... So I added inheritance and static functions... :: hums ::

Bah. For some reason, I can't sent it over forums. It says there's a bad request that the server can't understand.
If you have percent sign in a post, you get a bad request error.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #14  
Old 12-09-2007, 08:54 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Novo View Post
I actually went ahead and did it anyways... So I added inheritance and static functions... :: hums ::

Bah. For some reason, I can't sent it over forums. It says there's a bad request that the server can't understand.
Use "Quick Reply" instead, never got a Bad Request with that.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 12-09-2007, 08:59 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Custom Classes (Database):
PHP Code:
function onCreated()
{
  
createClass"TObject" );
  
createClass"TMap"TObject );
  
createClass"TMapMod"TMap );
  
createClass"TNode"TObject );
}

function 
createClassclassNamesuperClass )
{
  if ( 
"class" in serverr.debug )
    echo(
"Creating class" SPC className );

  if ( (@ 
className ).type() == )
    (@ 
className ).destroy();

  
// Create class object
  
temp.newClass = new TStaticVar( (@className) );
  
temp.newClass.super superClass;

  
// Add Static Functions
  
temp.classes = { temp.newClass };
  if ( 
superClass != null )
    
temp.classes.addarraysuperClass.getClasses() );

  for ( 
temp.class: temp.classes )
    
temp.newClass.join( ("class_"temp.class.name @"_static").lower() );
  
temp.newClass.join"class_tclass" );
  
  
// Don't let the garabe collecter get this!
  
this.classes.addtemp.newClass );
  return 
temp.newClass;
}

public function 
getClasses()
{
  return 
this.classes;

class_tclass (Class):
PHP Code:
/** Class object **
(+) Class[] getClasses();
(+) Class getSuperclass();
(+) String getName();
(+) String toString();
(+) Object newInstance( objectName );
**/

public function getName()
{
  return 
this.name;
}

public function 
toString()
{
  return 
getName();
}

public function 
newInstanceparamobjectName )
{
  if ( 
objectName != "" )
    if ( (@ 
objectName ).type() == )
      (@ 
objectName ).destroy();

  
// Initialize Class
  
if ( "class" in serverr.debug )
    echo(
"Initializing class" SPC this.name );

  if ( 
objectName == "" )
    
temp.newInstance = new TStaticVar();
  else 
temp.newInstance = new TStaticVar( @objectName );
  
temp.newInstance.class = this;

  
temp.classes getClasses();
  for ( 
temp.class: temp.classes )
  {
    if ( 
"class" in serverr.debug )
      echo(
"Joining gClass" SPC temp.class.getName() );
    
temp.newInstance.join( ("class_"temp.class.getName() ).lower() );
  }

  
// Call constructor!
  
for ( temp.class: temp.classes )
  {
    if ( 
temp.class.getName() in temp.newInstance.getfunctions() )
    {
      
temp.newInstance.(@ temp.class.getName() )( param );
      break;
    }
  }


  return 
temp.newInstance;
}

public function 
getClasses()
{
  
temp.classes = {this};

  
temp.super getSuperclass();
  if ( 
temp.super != null )
    
temp.classes.addarraytemp.super.getClasses() );

  return 
temp.classes;
}

public function 
getSuperclass()
{
  return 
this.super;

class_tobject (Class):
PHP Code:
/** General Object **
(+) void TObject();

(+) boolean instanceOf( Class class );
(+) String toString();
(+) Class getClass();
**/

public function TObject()
{
  if ( 
"class" in serverr.debug )
    echo( 
"Initialized Object" SPC toString() );
}

public function instanceOf( class )
{
  return ( class 
in getClass().getClasses() );
}

public function 
toString()
{
  return 
this.name @"-"this.class.getName();
}

public function 
getClass()
{
  return 
this.class;

And... As a bonus class to this great deal, TMap! (Call now, and get TNode for free!) Only fifty-five payments of 9.99$:
PHP Code:
/** TMap inherits TObject **
// Constructor
(+) void TMap( String[][] contents );

// Object Manipulation
(+) Object get( String key );
(+) void put( String key, Object value );
(+) void putAll( String[][] contents );
(+) void removeKey( String key ); * can't override .remove
(+) void clearMap();

// Testing
(+) boolean containsKey( String key );
(+) boolean containsValue( Object value );

(+) String[] keySet();
(+) Object[] values();

(+) int mapSize();
(+) boolean isEmpty();

(+) String[][] toArray();
**/

public function TMapinitialContents )
{
  
TObject();
  if ( 
this.init )
    return;

  
this.init true;
  
putAllinitialContents );
}

public function 
putAllnewContents )
{
  for ( 
temp.contentnewContents )
    
this.puttemp.content[0], temp.content[1] );
}

public function 
getkey )
{
  for ( 
temp.contentthis.contents )
  {
    if ( 
temp.content[0] == key )
      return 
temp.content[1];
  }

  return 
null;
}

public function 
putkeyvalue )
{
  for ( 
temp.contentthis.contents )
  {
    if ( 
temp.content[0] == key )
    {
      
temp.content[1] = value;
      return;
    }
  }

  
this.contents.add( {keyvalue} );
  return;
}

public function 
removeKeykey )
{
  for ( 
temp.0temp.this.contents.size(); temp.++ )
  {
    
temp.content this.contentstemp.];
    if ( 
temp.content[0] == key )
    {
      
this.contents.deletetemp.);
      return;
    }
  }
}

public function 
clearMap()
{
  
this.contents "";
}

public function 
mapSize()
{
  return 
this.contents.size();
}

public function 
isEmpty()
{
  return (
this.size() == 0);
}

public function 
containsKeykey )
{
  for ( 
temp.contentthis.contents )
    if ( 
temp.content[0] == key )
      return 
true;
  return 
false;
}

public function 
containsValuevalue )
{
  for ( 
temp.contentthis.contents )
    if ( 
temp.content[1] == value )
      return 
true;
  return 
false;
}

public function 
values()
{
  
temp.values = new[0];
  for ( 
temp.contentthis.contents )
    
temp.values.addtemp.content[1] );
  return 
temp.values;
}

public function 
keySet()
{
  
temp.keys = new[0];
  for ( 
temp.contentthis.contents )
    
temp.keys.addtemp.content[0] );
  return 
temp.keys;
}

public function 
toArray()
{
  return 
this.contents;

Reply With Quote
  #16  
Old 12-09-2007, 10:13 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
If we had support for global functions the way I wanted (including Control-NPC in the function lookup), it would be a simple and easy deal to have global functions (temp.var = TObjectType();) to return the new object instance.
__________________
Reply With Quote
  #17  
Old 12-09-2007, 10:32 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Inverness View Post
If...
Anyhow...

I made an addition to my TMap set. For those of you who want to use it, I've made a static function for it:

class_tmap_static (Class)
PHP Code:
public function mergemap1map2mergeRules )
{
  
// Sanity Check
  
if ( !map1.instanceOf( TMap ) || !map2.instanceOf( TMap ))
  {
    echo(
"Input aren't TMaps!");
    return 
null// Force programmer to input CORRECT Data!
  
}

  
// Change Merger to supplied one
  
temp.oldMerger this.mergeValue;
  if ( 
mergeRules != null )
    
this.mergeValue mergeRules;

  
// Copy first Map to a new map
  
temp.sum this.newInstancemap1.toArray() );
  
temp.keys temp.sum.keySet();

  
// Add second map to new map
  
temp.mapSet map2.toArray();
  for ( 
temp.mapValuetemp.mapSet )
  {
    
// If new map contains given key
    
if ( temp.mapValue[0in temp.keys )
    {
      
// Merge them together
      
temp.newValue mergeValue(
        
temp.mapValue[0], // key
          
temp.mapValue[1], // val1
          
temp.sum.gettemp.mapValue[0] ) // val2
        
);
      
      
temp.sum.puttemp.mapValue[0], temp.newValue );
    } else {
      
// Otherwise, put second map data to the new map.
      
temp.sum.puttemp.mapValue[0], temp.mapValue[1] );
    }
  }
  
  
// Revert back to old merger
  
this.mergeValue temp.oldMerger;  

  return 
temp.sum;
}

function 
mergeValuekeyval1val2 )
// Default
  // val1 + val2 should be the same as val2 + val1.
  
return (val1 val2);

Example of Usage:
PHP Code:
function onCreated()
{
  
mod1 TMap.newInstance({{"a",3}, {"b"1}} );
  
mod2 TMap.newInstance({{"a",2}, {"b"1}, {"c"1}} );

  
temp.merger = function( keyval1val2 ) {
    switch ( 
key )
    {
      case 
"a":
        return 
val1 val2;
      default:
        return 
val1 val2;
    }
  };

  
mod3 TMap.mergemod1mod2temp.merger );
  echo( 
mod3.toArray() ); // "a,6","b,2","c,1"

Reply With Quote
  #18  
Old 12-09-2007, 10:37 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
Anyhow...
Too complex for average use.
__________________
Reply With Quote
  #19  
Old 12-09-2007, 10:53 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Inverness View Post
Too complex for average use.
But Powerful for those who know how to use it. Additionally, the merger comes with a default way of merging. It isn't necessary to define your own function, but the power is there if you do!

PHP Code:
function onCreated()
{
  
mod1 TMap.newInstance({{"a",3}, {"b"1}} );
  
mod2 TMap.newInstance({{"a",2}, {"b"1}, {"c"1}} );

  
mod3 TMap.mergemod1mod2 );
  echo( 
mod3.toArray() ); // "a,5","b,2","c,1"

Simple for those who don't need more.
Reply With Quote
  #20  
Old 12-09-2007, 11:31 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
But Powerful for those who know how to use it. Additionally, the merger comes with a default way of merging. It isn't necessary to define your own function, but the power is there if you do!

PHP Code:
function onCreated()
{
  
mod1 TMap.newInstance({{"a",3}, {"b"1}} );
  
mod2 TMap.newInstance({{"a",2}, {"b"1}, {"c"1}} );

  
mod3 TMap.mergemod1mod2 );
  echo( 
mod3.toArray() ); // "a,5","b,2","c,1"

Simple for those who don't need more.
Can you tell me an instance where it would be used in-game?
__________________
Reply With Quote
  #21  
Old 12-09-2007, 11:37 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Sure... Phone-Address look-up. In Era.
PHP Code:
Phones.phoneMap TMap.newInstance();

// In various locations around the world
Phones.phoneMap.put("553-4234"this );


// To phone...
otherPhone Phones.phoneMap.get"553-4234" );
otherPhone.chat "*ring* *ring*"
Merger...
Item System:
PHP Code:
items TMap.newInstance();
items.putitemID, {quantstate});

merger = function( keyval1val2 ){ return {val1[0] + val2[0], val1[1] || val2[1]}; }
items TMap.mergeitemsTMap.newInstance( {{ itemIDquant}}, merger ); 
... There are many situations that it could come up.

What I use it for is to have a cumulative effects from the clothing that the player uses.
For instance, let's say 'Speed'...
PHP Code:
Special Boots TMap.newInstance( {{"Speed"5}});
Other Clothing TMap.n... ...

mods playerMods;
mods TMap.mergemodsracialMods );
for ( 
clothesall worn clothes )
  
mods TMap.mergemodsclothes.mods );

player.speed mods.get("Speed"); 
This is done FOR-ALL possible (and future) attributes:

PHP Code:
  temp.modList temp.mod.toArray();
  for ( 
temp.modtemp.modList )
    
clientr.(@ temp.mod[0] ) = temp.mod[1]; 
Reply With Quote
  #22  
Old 12-10-2007, 12:49 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
Sure... Phone-Address look-up. In Era.
That may 'work' but using a specialized function is much simpler and to the point.
Quote:
Originally Posted by Novo View Post
What I use it for is to have a cumulative effects from the clothing that the player uses.
I just scan equipped items in the mud object and add their affects to the player's.

You're really over-complicating things that are simple to do with regular scripts. Thats not a good way to bring new scripters into the scene.
__________________
Reply With Quote
  #23  
Old 12-10-2007, 01:05 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Quote:
Originally Posted by Inverness View Post
That may 'work' but using a specialized function is much simpler and to the point.
I just scan equipped items in the mud object and add their affects to the player's.

You're really over-complicating things that are simple to do with regular scripts. Thats not a good way to bring new scripters into the scene.
Inverness, I've provided quite a dynamic way to do a variety of things. If you don't appreciate it for whatever reason you have (which seems to be whatever you can seem to think of), then that's that. Otherwise... There are MANY ways to skin a cat. This is one of them...

I don't think introducing new programmers to concepts such as these will help... But alternatively, for those in the know, these techniques could be used with a wide range of successful usage. Ultimately, by my publishing the code, I didn't make it ANY HARDER to learn to script. In fact, that wasn't even my targeted audience. (Additionally, new programmers could learn by example, so they might not see the full utility, but something like that could let them see how reflective programming could be done )

Whether it is overcomplicating something, or providing a bigger re-usability... It doesn't matter that much. Sure, some things just need a little function to work. Others will need more. And in the end, everything can be hard-coded as one massive monolith. In fact, you could program Graal in ONE FUNCTION.

Now, if you want to argue the value of TMap... I just provided it as a quick freebie and numerous incidents it could be used. If you're debating about Class System... I think you would already be in a level where you can use it if you considered that it is beneficial to use it in the first place. I provided quite a bit of flexibility.

Ultimately, I AM SORRY FOR GIVING YOU FREE CODE, go cry me a river. ( I refuse to feed your troll habits any further. )
Reply With Quote
  #24  
Old 12-10-2007, 01:21 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Novo View Post
I AM SORRY FOR GIVING YOU FREE CODE
You should be!
__________________
Reply With Quote
  #25  
Old 12-10-2007, 02:12 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
<snip>
My issue is because I did exact same thing about a year ago and found that it wasted too much time and CPU making things super flexible and modular rather than just scripting it to do what it needs to do in less time.

Though it seems our situations are different if you don't have something you need to be working on and are just scripting for fun. Though, if you do have something you need to do with this all (like making the system for a server) I wouldn't suggest such things.

I'm just trying to save you from wasting time overdoing it :P, redesigning systems and such can kill a server under construction.
Quote:
Originally Posted by cbkbud View Post
You should be!
Go away, the grown-up scripters are talking now.
__________________

Last edited by Inverness; 12-10-2007 at 02:31 AM..
Reply With Quote
  #26  
Old 12-10-2007, 03:55 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Inverness View Post
Go away, the grown-up scripters are talking now.
But...he...wasn't making any sort of scripting comment. ._.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #27  
Old 12-10-2007, 05:17 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by coreys View Post
But...he...wasn't making any sort of scripting comment. ._.
It wouldn't be far off.
You're supposed to nip it in the bud. *Shining aura of pure awesome*
__________________
Reply With Quote
  #28  
Old 12-10-2007, 05:42 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
Quote:
Originally Posted by Inverness View Post
*Shining aura of pure awesome*
I WANT ONE! D:
__________________
Stan.
Reply With Quote
  #29  
Old 12-10-2007, 06:22 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Kyranki View Post
I WANT ONE! D:
You'll never have one.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #30  
Old 12-10-2007, 05:34 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
Quote:
Originally Posted by Inverness View Post
Go away, the grown-up scripters are talking now.
Hi
__________________
Reply With Quote
  #31  
Old 12-10-2007, 08:09 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Dan View Post
Hi
Didnt you read what he said?
Reply With Quote
  #32  
Old 12-10-2007, 11:22 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Crow View Post
Didnt you read what he said?
Perhaps he is a super ninja-scripter whos talent has yet to be revealed.
__________________
Reply With Quote
  #33  
Old 12-11-2007, 12:24 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
Quote:
Originally Posted by Inverness View Post
Perhaps he is a super ninja-scripter whos talent has yet to be revealed.
Pffft. Urban Legend.
__________________
Stan.
Reply With Quote
  #34  
Old 12-11-2007, 12:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
Go away, the grown-up scripters are talking now.
PHP Code:
if ( weapon is fired )
  
shoot bullet at other players
i am 1337 now ?
__________________
Reply With Quote
  #35  
Old 12-11-2007, 01:21 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Welcome, brothers, to the secret thread of elite scripters! I've got some tea and biscuits on the table.

Hi Dan! Show us your 1337 skillz! I'm sure Inverness is no match to your prowess.
Reply With Quote
  #36  
Old 12-11-2007, 02:37 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Novo View Post
Welcome, brothers, to the secret thread of elite scripters! I've got some tea and biscuits on the table.

Hi Dan! Show us your 1337 skillz! I'm sure Inverness is no match to your prowess.
My true power has yet to be revealed.
Quote:
Originally Posted by Kyranki View Post
Pffft. Urban Legend.
No, I don't think Urban is one.
__________________
Reply With Quote
  #37  
Old 12-11-2007, 04:51 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
Quote:
Originally Posted by Inverness View Post
No, I don't think Urban is one.
Ohnoes, I made a syntaxing error.
__________________
Stan.
Reply With Quote
  #38  
Old 12-11-2007, 07:29 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Inverness View Post
My true power has yet to be revealed.
osht, inver can go super sayan 5
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #39  
Old 12-11-2007, 02:02 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Inverness View Post
Perhaps he is a super ninja-scripter whos talent has yet to be revealed.
Lets just not talk about it. Might hurt him.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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


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