Creating a New Spec Oracle (Step by Step)

Jump to: navigation, search


He intermediate.png

This is an intermediate level tutorial, that should only be tackled by someone who already has basic familiarity with the DOM Editor, GUI Editor, and Script Editor


This page provides a step by step tutorial on how to create a Spec Oracle, showing which steps need to be handled on the Server, and which on the Client.

Creating a Spec Oracle involves:

This page covers the top three steps. For the others, see HotSpot Menu, and Spec Oracles.

On Server

(Note: all 3 classes here are Archetype Data)
1. Create a class "YourThing" + Spec which will have all the immutable data your spec will store.
For example: "InventoryItemSpec"
2. Add Parent class BaseSpec to the spec class you just created by editing the properties and selecting Parent Class under Name and then picking baseSpec
3. (optional) Instantiation classes are needed only for Spec Oracles which deal with instanced objects.
3a. (Optional) Create YourThing instantiation class.
3b. (Optional) Add Parent class SpecDerivedObject to the YourThing class. (not the spec)
3c. (Optional) Override the getMySpecOracle in the YourThing instantiation class.

// example
method getMySpecOracle() as NodeRef of Class SpecOracle
  return getPrototype( "YourThingSpecOracle" )
4. Add fields displayName and displaydescription (optional) if you want name and description to appear in the spec browser.
5. Create class "YourThing" + SpecOracle which is the oracle.
For example: "InventoryItemSpecOracle"
6. Add Parent class SpecOracle to your Spec Oracle class defined in the previous step.
7. Create Prototype based on YourThingSpecOracle on server.

  // example command
  \cpfc YourThingSpecOracle, YourThingSpecOracle; description="The YourThing Spec Oracle"
8. Create YourThingSpecOracleClassMethods script from the template TemplateSpecOracleClassMethods and adjust the following methods
a. getValidBaseClasses()

  // example
  method getValidBaseClasses() as List of String
    valid as List of String
    add back "YourThingSpec" to valid
    return valid
b. getSpecDecoratorClasses()

  // example
  method getSpecDecoratorClasses() as List of String
    valid as List of String
    return valid
c. getSpecOracleClass()

  // example
  method getSpecOracleClass() as String
    return "YourThingSpecOracle"
d. getSpecFileExtension()

  // example
  method getSpecFileExtension() as String
    return ".YourThingSpec"
e. getSpecClass()

  // example
  method getSpecClass() as String
    return "YourThingSpec"
9. Create YourThingSpecClassMethods using template TemplateBaseSpecClassMethods and change getMySpecOracle to return "YourThingSpecOracle". Also change CreateFromSpec to name the node class created in step 3, if you made one.

On Client

10. Repeat steps 1 thru 6 above, creating client side copies of your spec and Spec Oracle classes.
11. Add Parent CollectionOrderedSet to your Spec Oracle class
12. Add Parent ObsSubject to your Spec Oracle class.
13. Follow these directions for overriding the $SPECORACLEUTILS system node with a game-specific version. Assuming your game-specific client script is called MyGame_SpecOracleUtilsClassMethods, we will now adjust a few methods in that script.
a. The singleton getter method

  // example
  method GetYourThingSpecOracle() as NodeRef of Class YourThingSpecOracle
    yourThingSpecOracle as NodeRef of Class YourThingSpecOracle = $SPECORACLEUTILS._GetSpecOracleByClass( "YourThingSpecOracle")
    return yourThingSpecOracle
b. The class test for your SpecOracle class in HE_GetSpecOracleByClass

  // example
  is "yourthingspecoracle"
    if otest is kindof YourThingSpecOracle
      specOracle = otest
c. Add call to singleton getter to HE_GetAllSpecOracles

  // example
  add back me.GetYourThingSpecOracle() to oracles
14. Create client-side script YourThingSpecOracleClassMethods from template TemplateSpecOracleClassMethods, changing strings returned as needed.
15. Create client side YourThingSpecClassMethods from the template TemplateBaseSpecClassMethods, and change getMySpecOracle() to return "YourThingSpecOracle".

Adding Header Fields to your Spec List

To add a column to your spec listings, you can perform the following bit of HSL code once on the server:

var oracle = GetPrototype("YourSpecOracle")
where oracle is kindof YourSpecOracle

Next steps

See also

Personal tools