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(object, technique) {
temp.neededprofessions = null;
temp.yn = null;
temp.i = 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(object, technique)) {
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 (i = 0; i < neededprofessions.size(); i++) {
if (Professions.hasProfession(object, neededprofessions[i])) {
yn[i] = "y";
continue;
}
yn[i] = "n";
}
if (yn.index("n") == -1) {
echo("LETS GO!");
techbasevars = {"techid", "techname", "techtype", "description"};
for (techbasevar: techbasevars) {
finaldata.add(this.getTechniqueVar(technique, techbasevar));
}
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 Profession: biomechanics,Bio-Mechanics,"The study of combining human's with mechanized parts."
MudObject_player_Clockwork First Technique: parasitebugs,"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.