Author Topic: Getting your custom scripts to show details in the script assist  (Read 367 times)

Legacy_Tiggers.no.tail

  • Jr. Member
  • **
  • Posts: 82
  • Karma: +0/-0


                So I'm writing several 'generic' include files for my next module which have several custom functions that take varying parameters. I'm wondering how to make it so that when I do the whole 'double-click highlight' thing, it shows the function description in the bottom window inside the script editor. does anyone know how to do this? It works fine for the Gestalt Cutscene Scripitng System I'm using, and I don't see anything special about what he's done to make it work. Is there something I'm missing?
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Getting your custom scripts to show details in the script assist
« Reply #1 on: July 06, 2011, 06:40:35 pm »


               Use the // symbol in front of your text, have no spaced lines between your // line and your function.

Example:

// This information tells about my custom function
void MyCustomFunction()
{
// Code Here - can have spaced lines in this part
}
               
               

               


                     Modifié par _Knightmare_, 06 juillet 2011 - 05:44 .
                     
                  


            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Getting your custom scripts to show details in the script assist
« Reply #2 on: July 06, 2011, 07:18:34 pm »


               // This information tells about my custom function
void MyCustomFunction();

...

void MyCustomFunction()
{
// Code Here - can have spaced lines in this part
}
               
               

               
            

Legacy_Tiggers.no.tail

  • Jr. Member
  • **
  • Posts: 82
  • Karma: +0/-0
Getting your custom scripts to show details in the script assist
« Reply #3 on: July 06, 2011, 07:58:30 pm »


               LOL, i just figured it out
you cant have the opening curly on the same lines as the name of the function
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Getting your custom scripts to show details in the script assist
« Reply #4 on: July 06, 2011, 09:09:40 pm »


               

Tiggers.no.tail wrote...

LOL, i just figured it out
you cant have the opening curly on the same lines as the name of the function



Looking at the lexicon, just now, it seems like it is mixing its words up.   I have seen mix cases on the deffinitions of prototype and declaration in reguards to a function.  my explanation is not going to use the word prototype.  I woll call the prototype a 'forward delclaration'. 


a Function  declaration in NWN script takes the form of.   


type functionName([type Argument1,] [...,] [type ArgumentN])
{
     // code block ...
     return value;
}

an example would be.  

int  AreaOfRectangle( int nHight, int nLength)
{
   return nHight * nLenght;
}

in this example the first int is the data type that is returned by the function. 
followed by the functiom Name of 'AreaOfRectangle'
followed by two argument withing the '()" of nHight and nLength.  both having a data type of 'int'
the code block is a single return, that returns the product of the hight and length.

simple enough,  There are times however when the scripter needs or wants to use a function before it is declaired.   This is where the 'forward declaration come into play.   A forward declaration allows the scripter to give the main body of a script just enough information to be able to compile the script without supplying all the information about what the function does.  In short it is the same as the declaration but without the code block. the function does still have to be declared at some point in the scource code. IT just no longer has to be declaired befor it is used.   The forward declaration take the form:


type functionName([type Argument1,] [...,] [type ArgumentN]);

Note the simicolon after the forward declaration.   The simicolon basicly tells the compiler that the statment is copleate nothing else is comming.    hence we know this is a forward declaration and a full declaration of the function will follow at some later point in the code. .

Now to answer your question.   In order for the function to show up on the right side in the script editor, It has to have a forward declaration.  The forward declaration and all comment lines preceeding it is what will show up in the help section at the bottom of the editor when the function is clicked.

Having a forward declaration immediately followed by the full declaration would be a bit pointless in most languages.  In NWscript however you will notice it being done all the time, Just to have the forward declaration show up in the function list in the script editor.  So in nwscript if I wanted my above function to show up and i had no reason to put the forward declaration elswhere in the script already. I would just define it with the forward declaration at the same time i declared it. along with any comments that i wanted to show up with it. 

// Returns the area of the rectangle.
int  AreaOfRectangle( int nHight, int nLength);
int  AreaOfRectangle( int nHight, int nLength)
{
   return nHight * nLenght;
}
               
               

               


                     Modifié par Lightfoot8, 03 septembre 2011 - 04:02 .
                     
                  


            

Legacy_Tiggers.no.tail

  • Jr. Member
  • **
  • Posts: 82
  • Karma: +0/-0
Getting your custom scripts to show details in the script assist
« Reply #5 on: July 06, 2011, 10:05:22 pm »


               Thanks!