Page 1 of 1

Basic questions

Posted: Thu Sep 04, 2003 1:32 pm
by Dirk Cutlass
OK, I thought I might finally open up the toolkit and play with a few scripts.

But first, I got some basic questions.

You have a script xyz. And I see that there is a main() entry point to that script. I also see you can have other functions defined inside xyz, so for instance I have some 'utility functions' like IsBady() IsGoody(). I'm fine with that so far.

Question: Can these utility functions be called from other scripts?

Taking it one step further, is it possible to have a script that contains nothing but utility functions (i.e. the main() does nothing or doesn't exist)?

If not, then does this mean that for each script you make, it has be completely self-contained? Even if functions IsBady() and IsGoody() where used by other scripts?

Anyother useful comments on the "architecture of scripting" would also be useful.

Thanks in advance.

Posted: Thu Sep 04, 2003 1:44 pm
by Maelstrom
You can put all your functions in a file, say "abc.inc", and then put the line

#include "abc.inc"

at the beginning of the script where you need to use one of those functions. The you can use any of those functions. It might make sense to break them up into categorical groups and have multiple #include lines.

Maelstrom

Posted: Thu Sep 04, 2003 3:28 pm
by Dirk Cutlass
Maelstrom76 wrote:You can put all your functions in a file, say "abc.inc", and then put the line

#include "abc.inc"

at the beginning of the script where you need to use one of those functions. The you can use any of those functions. It might make sense to break them up into categorical groups and have multiple #include lines.

Maelstrom
Thanks. That makes sense. Does the toolset supply any predefined include files with useful functions / facilities ?

Posted: Thu Sep 04, 2003 4:55 pm
by Actually
About a billion of 'em. :D

Go here: http://www.reapers.org/nwn/reference/

It's also a really good idea to open up the scripts from the OC's and read 'em to understand which .h files they include and when.

Bye Now,
Jerry Cornelius - Begginer scripter.

Posted: Thu Sep 04, 2003 5:09 pm
by subspace1011
Actually wrote:About a billion of 'em. :D

Go here: http://www.reapers.org/nwn/reference/

It's also a really good idea to open up the scripts from the OC's and read 'em to understand which .h files they include and when.

Bye Now,
Jerry Cornelius - Begginer scripter.
Best scripters resource ever... I've referred to it numerous times.