Limited class choice creation script

//
// Simple demo character initialisation script
// Set Configuration, Instance, Instance.CharInitScript to the script name
//
// The theoretical set up is:
// two allegiances, (character groups of type allegiance)
// called goodies and baddies, bound to the Allegiance attribute.
// There are also 3 classes, warrior mage and thief,
// similarly bound to the Class attribute
// Goodies can pick warrior or mage, baddies can pick thief or mage.

// does the caller have an allegiance?
String allegiance=gsGetGroupByType(CALLER,"Allegiance");
if (allegiance=="") { // if no allegiance
  allegiance=gsGetChoice(CALLER,"Pick a side",["Goodies","Baddies"]);
  // initialise the allegiance
  Response r=gsAPIX(CALLER,"characters.initialise",["Allegiance",allegiance]);
}
// at this point allegiance is either read from the character
// or set by their choice.
// create a list of classes they may choose from
List classes=[];
if (allegiance=="Goodies") {
  classes=["Warrior","Mage"];
}
if (allegiance=="Baddies") {
  classes=["Thief","Mage"];
}
// get the current Class group
String class=gsGetGroupByType(CALLER,"Class");
if (class=="") { // if there isn't one
  class=gsGetChoice(CALLER,"Pick a class",classes);
  // have the user pick one and initialise the variable
  Response r=gsAPIX(CALLER,"characters.initialise",["Class",class]);
}

// Exiting the script will either
// a) Log the character in, if nothing was queried from the user or
// b) Re-run the login, if anything changed.
// As long as this script quietly exits on a run, login will complete
// A simple mistake is having this script pop up questions without checking
// if the user already chose, this will trap them in an infinite loop of the 
// same questions.  See the documentation.