Basic questions

Moderator: Event DM

Post Reply
User avatar
Dirk Cutlass
Elder Sage
Posts: 4691
Joined: Mon Jan 27, 2003 9:42 am
Location: GMT

Basic questions

Post by Dirk Cutlass » Thu Sep 04, 2003 1:32 pm

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.
Maelstrom
Lord of Blithering Idiots
Posts: 124
Joined: Thu Jun 12, 2003 5:56 pm
Location: Littleton, CO
Contact:

Post by Maelstrom » Thu Sep 04, 2003 1:44 pm

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
User avatar
Dirk Cutlass
Elder Sage
Posts: 4691
Joined: Mon Jan 27, 2003 9:42 am
Location: GMT

Post by Dirk Cutlass » Thu Sep 04, 2003 3:28 pm

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 ?
Actually
Sage
Posts: 1823
Joined: Sat Dec 14, 2002 10:11 pm
Location: Red Zone: Cuba

Post by Actually » Thu Sep 04, 2003 4:55 pm

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.
Everything I need to know in life, I learned from being an alcoholic.
subspace1011
Apprentice Scholar
Posts: 966
Joined: Wed Jan 15, 2003 4:39 am
Location: DE, USA (GMT -4/-5)
Contact:

Post by subspace1011 » Thu Sep 04, 2003 5:09 pm

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.
Post Reply