User talk:Void Singer

From Second Life Wiki
Revision as of 21:39, 14 October 2007 by Void Singer (talk | contribs) (playing with / learning wiki formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About Me

  • Born: 1975
  • Name: Void is fine, you majesty works too ;)
  • Location: Utah, for the moment
  • History: Started off making webpages, then scripting for webpages (jscript), went to college for 3 years, studied programming and networking. I do a little of everything, from digital art, to running my own web and streaming media servers, to anything you can think of in SL.

I'm easy-going, love to help, pretty non-judgmental, and love interesting scripting challenges =) I know a little about alot, and alot about very little. I'm also kinda random, rather shy, and occasionally bouncy so.... beware!

Void 21:39, 14 October 2007 (PDT)

Coding Practices: part 1

this is a listing of how I format code, for readability and self documentation, not everyone likes it, but if you use something and stick with it, others will thank you, and you'll thank yourself later when you look at it and your eyes want to glaze over thinking "WTF was I doing?"

  1. variables:
    1. all user variables are prefixed with "v" (for variable) [so we can quickly Id variables]
    2. all variables have their type included in 3 letters (eg. vStrData) [so we know the type, saves debugging typcast problems]
    3. all variables denote what they are for (eg. key vKeyOwner = llGetOwner();) [saves on comments, makes it esay to know what we're doing]
    4. all States prefixed "vs" -eg vsStateName [so we can id states]
    5. all user defined functions prefixed "vf" and return type -eg vfFunctionName [so we can Id functions and their return types]
    6. All Globals are prefixed with "vg" (for variable-global) [makes it easy to spot globals]
    7. All Constants are prefixed "c" and placed in all caps to distinguish from ll -eg cSTR_TITLE [easier to spot non ll constants]
    8. Bitmasks and booleans are given type "vBit" and "vBoo" [so we know how they are being used]
  2. Comments: [help us remember/see what code is trying to do]
    1. Sections/Headers: "//--// text //--//"
    2. Code: " //-- the line below does X" (note the extra space indent
    3. Edit/Notes: " //-- the line to the left is editable or could use changes"
  3. Brackets/Whitespace:
    1. Functions: space away from the container -eg. llRound( vIntNumber ); [makes it different from grouping]
    2. math: always separate math -eg 2 + 2, exception increments --x, ++x [easier to read/debug]
    3. Grouping: do not space inside, or out -eg. ((vIntNumber + 2) * 5 ) [makes it different from functions]
    4. Events: follow function rules + { -eg state_entry(){
    5. If/Loop: follows grouping rules with a space before group, and trailing { -eg if (TRUE){
  4. General WhiteSpace:
    1. blank line between event [easier to read]
    2. blank line between sections of code doing different things [groups like actions]
    3. tabs are 2 spaces, to reduce wrapping for nested items [saves wrapping, eaiser to read]
  5. Special Cases:
    1. Long tests/function calls: wrap each variable/container to the next line with level spacing -eg see below [easier to read, less sloppy than built in wrapping]
//--// this is an example script //--//

string   cSTR_TITLE = "example script" //-- something to tell the user later
integer  vgIntTotalTouches = 0;

string vfStrFunctionExample( key vKeyOwner ){
  return llKey2Name( vKeyOwner );
}

default{
  state_entry(){
    llOwnerSay( "Hi, " + vfStrFunctionExample( llGetOwner() ) );
  }

  touch_start( integer vIntTouchCount ){
    do{
       //-- below is the example of wrapping functions parameters
      llSay( 0,
             cSTR_TITLE + " has been touched "           //-- this is an example of
                        + (string)(++vgIntTotalTouches)  //-- string wrapping, always
                        + " times" );                    //-- has + in the front
    }while (--vIntTouchCount > -1);
  }

  changed( integer vBitChanged ){
    if (vBitChanged & CHANGED_OWNER){
      state vsReset
    }
  }
}

state vsReset{
  state_entry(){
    llSay( 0, "New Owner " + vfStrFunctionExample( llGetOwner() ) + " detected; reseting" );
    llResetScript();
  }
}

Void 21:39, 14 October 2007 (PDT) PS I'm still learning wiki formatting, bear with me