View Single Post
  #17  
Old 07-24-2008, 07:49 PM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Well, in compilation with the Classes and Professions pieces of code I've shown here, I may as well show the beginning of the third and final part of the system. (Each of these systems work hand-in-hand to get the effect needed.);

PHP Code:
Test Script:

function 
onCreated() {
  
temp.pl findplayerbycommunityname("Clockwork");
  
temp.pl.mud.class = null;
  
temp.pl.mud.professions null;
  
temp.pl.mud.techniques null;
  
Classes.setClass(temp.pl.mud"apprentice");
  echo(
temp.pl.mud.name " Class: " temp.pl.mud.class);
  
Professions.addProfession(temp.pl.mud"biomechanics");
  echo(
temp.pl.mud.name " First Profession: " temp.pl.mud.professions[0]);
  
Techniques.addTechnique(temp.pl.mud"parasitebugs");
  echo(
temp.pl.mud.name " First Technique: " temp.pl.mud.techniques[0]);

PHP Code:
Adding A Technique:

public function 
addTechnique(objecttechnique) {
  
temp.neededprofessions null;
  
temp.yn null;
  
temp.null;
  
temp.techbasevars null;
  
temp.techbasevar null;
  
temp.finaldata null;
  
  if (!(
object.type in {"player"}) || object.objecttype() != "TMudObject") {
    
this.error("Mud Object (%s) is not valid!"object.name);
    return;
  }
  if (
technique == null) {
    
this.error("No technique given to set!");
    return;
  }
  if (
Classes.classIsSet(object)) {
    if (!
this.hasTechnique(objecttechnique)) {
      echo(
"Objects classes have been set.");
      
neededprofessions this.getTechniqueVar(technique"neededprofessions");
      
yn = new [neededprofessions.size()];
      echo(
"NEEDED PROFESSIONS: " neededprofessions);
      echo(
"YES/NO CHECK SIZE: " yn.size());
      for (
0neededprofessions.size(); i++) {
        if (
Professions.hasProfession(objectneededprofessions[i])) {
          
yn[i] = "y";
          continue;
        }
        
yn[i] = "n";
      }
      if (
yn.index("n") == -1) {
        echo(
"LETS GO!");
        
techbasevars = {"techid""techname""techtype""description"};
        for (
techbasevartechbasevars) {
          
finaldata.add(this.getTechniqueVar(techniquetechbasevar));
        }
        echo(
"FINAL TECHNIQUE DATA: " finaldata);
        
object.techniques.add(finaldata);
        echo(
object.name);
      }
    }
  }

PHP Code:
Output:

MudObject_player_Clockwork Class: apprentice,Apprentice,1,"An apprentice."
MudObject_player_Clockwork First Professionbiomechanics,Bio-Mechanics,"The study of combining human's with mechanized parts."
MudObject_player_Clockwork First Techniqueparasitebugs,"Parasite Bugs",parasitic,"Many microscopic steam-powered bugs flood the targets body and drains their energy." 
Again excuse me for so many "echo()"'s. As I just got finished with the function.
Reply With Quote