Server Totals
Deglos - (1)
Le'Or - (1)
Elysia - (1)
Ferrell - (0)
M'Chek - (0)
Mikona - (0)
Wilderness - (0)
Visimontium - (0)
Underdark - (0)
Total players: 3
Gallery
  • Winter Ball 2015
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Sat Jan 03, 2015 4:38 pm

Links Menu

Basic questions

Moderators: Nighthawk4, Dungeon Masters

Basic questions

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

PostAuthor: 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

Maelstrom
Lord of Blithering Idiots
 
Posts: 124
Joined: Thu Jun 12, 2003 5:56 pm
Location: Littleton, CO

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

PostAuthor: 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.

Actually
Sage
 
Posts: 1823
Joined: Sat Dec 14, 2002 10:11 pm
Location: Red Zone: Cuba

PostAuthor: 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.

subspace1011
Apprentice Scholar
 
Posts: 966
Joined: Wed Jan 15, 2003 4:39 am
Location: DE, USA (GMT -4/-5)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Frannie Mouze, Google [Bot], Pekarion, Trigger