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.
Basic questions
Moderator: Event DM
- Dirk Cutlass
- Elder Sage
- Posts: 4691
- Joined: Mon Jan 27, 2003 9:42 am
- Location: GMT
-
- Lord of Blithering Idiots
- Posts: 124
- Joined: Thu Jun 12, 2003 5:56 pm
- Location: Littleton, CO
- Contact:
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
#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
- Dirk Cutlass
- Elder Sage
- Posts: 4691
- Joined: Mon Jan 27, 2003 9:42 am
- Location: GMT
Thanks. That makes sense. Does the toolset supply any predefined include files with useful functions / facilities ?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
About a billion of 'em. 
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.

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.
-
- Apprentice Scholar
- Posts: 966
- Joined: Wed Jan 15, 2003 4:39 am
- Location: DE, USA (GMT -4/-5)
- Contact:
Best scripters resource ever... I've referred to it numerous times.Actually wrote:About a billion of 'em.
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.