Skip to content
JasXSL edited this page Nov 29, 2017 · 5 revisions

The header file is located within YourProjectDirectory/classes. An XOBJ header file should follow the following syntax:

Name

  • The file must be prefixed with your project shortcode, separated with a space. Ex: jas Dialog.lsl, ton Footsteps.lsl, got Bridge.lsl
  • The first letter after the prefix and script tag must be uppercase. Any subsequent letters can be capitalized.
  • The name of the script in SL must correspond to the name of the header file, minus .lsl, ex: jas Dialog, ton Footsteps, got Bridge

Basic Structure

  • The structure of the header file is split into the following blocks, in order from top to bottom. You must separate blocks by one or more blank lines.
  1. Method definitions. Ex: #define mfpMainMethod$helloWorld 1 // (key)sender - Sends a hello world message with sender's display name
  2. Event definitions. Ex: #define mfpMainEvt$helloWorldResponse 1 // (key)sender, (string)response - Raised when a hello world response is received
  3. Config definitions. Ex:
    #ifndef mfpMainConf$allowOnlyOwner
    #define mfpMainConf$allowOnlyOwner 0    // Allow only owner
    #endif
4. Method macros. Ex: `#define mfpMain$helloWorld( clicker, callback ) runOmniMethod("mfp Main", mfpMainMethod$helloWorld, [clicker], callback)` 5. Any other functions, macros, and constants you wish to share.

ALL Definitions

  • All definitions should begin with a contraction of the script name, followed by a dollar and a label. The label begins with a lowercase letter. Ex: jasDialogMethod$spawn, gotBridgeEvt$playerData
  • If it doesn't make sense to put a prefix on your definition, consider putting it in the _core.lsl file or a library file.
  • If you have constants directly related to an item, add them with one level of indentation. Ex:
	#define fx$HITFX 6			// [(vec)color, (int)flags]
		#define fxhfFlag$NOANIM 1		// Don't use standard takehit anim
		#define fxhfFlag$NOSOUND 2		// Don't use a default sound

Method Definitions

  • Same as ALL definitions, script suffixed with Method. Ex: jasDialogMethod$spawn
  • Add a comment after the definition with accepted arguments and explanation. Ex: // (key)sender - Sends a hello world message with sender's display name
  • If you need multiple lines to explain it, hit enter and tab to the start of the comment. Ex:
#define mfpMainMethod$helloWorld 1	// (key)sender - Sends a hello world message with sender's display name
					// This is some more info

Event Definitions

  • Same as ALL definitions, script suffixed with Evt. Ex: gotBridgeEvt$playerData

Macro Definitions

  • Script not suffixed. Prefix should be the same as the shorthand form of the script. Ex: jasDialog$spawn
  • Method name should represent the method being called. Ex: jasDialogMethod$spawn -> jasDialog$spawn
  • If you need multiple macros mapped to the same method, add additional info to the end. Ex: jasDialog$spawn(a), jasDialog$spawnWithAB(a, b)
  • If the macro should be callable both within the linkset and on a remote linkset, use target as (str)(target), ex: #define mfpMain$helloWorld( target, clicker, callback ) runMethod((str)(target), "mfp Main", mfpMainMethod$helloWorld, [clicker], callback). This will allow you to run both mpfMain$helloWorld("uuidHere") and mpfMain$helloWorld(LINK_ROOT)

Config Definitions

  • Same as ALL definitions, script suffixed with Conf. Ex: #define mfpMainConf$allowOnlyOwner
  • If your config constant is defined with no value, or doesn't need to be defined for your module to work. Just comment it out. Ex: // #define mfpMainConf$allowOnlyOwner // Allows only owner
  • If your config constant needs a default value, use #ifndef. Ex:
    #ifndef mfpMainConf$allowOnlyOwner
        #define mfpMainConf$allowOnlyOwner 0    // Allow only owner
    #endif

Other functions and constants

  • Use the standard prefix, ex mfpMainConf$. Anything else is up to you.

Clone this wiki locally