-
Notifications
You must be signed in to change notification settings - Fork 4
Header File
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:
- 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
- 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.
- Method definitions. Ex:
#define mfpMainMethod$helloWorld 1 // (key)sender - Sends a hello world message with sender's display name - Event definitions. Ex:
#define mfpMainEvt$helloWorldResponse 1 // (key)sender, (string)response - Raised when a hello world response is received - Config definitions. Ex:
#ifndef mfpMainConf$allowOnlyOwner #define mfpMainConf$allowOnlyOwner 0 // Allow only owner #endif
- 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
- 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
- Same as ALL definitions, script suffixed with Evt. Ex:
gotBridgeEvt$playerData
- 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 bothmpfMain$helloWorld("uuidHere")andmpfMain$helloWorld(LINK_ROOT)
- 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
- Use the standard prefix, ex
mfpMainConf$. Anything else is up to you.