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

Links Menu

initialize variables onmoduleload

Moderators: Nighthawk4, Dungeon Masters

initialize variables onmoduleload

PostAuthor: girlysprite » Fri Apr 07, 2006 2:39 pm

What is the best way to initalize local variables on the PC when the module is started for the first time?

Now I have these lines in the OnLoadModule script:

object oPC= GetPCSpeaker();

SetLocalInt(oPC, "bookquest", 0);
SetLocalInt(oPC, "water", 0);


of course, I guess it only works when a PC speaks? The variables are made, but they can only have the value 0 in this way it seems. When I added a variable with the value 9, it had the value 0 in the game.

so what can I do about that?

I tried some other things instead GetPCSpeaker() but it doesnt work.
Gaming doesn't make people voilent, lag does

<Dimotane> I think deep down, when we're honest with ourselves... we're all a pregnant male elf.
User avatar
girlysprite
Silver Contributor
 
Posts: 3661
Joined: Mon Apr 12, 2004 2:38 pm
Location: In my little pony ranch

PostAuthor: Alphonse » Fri Apr 07, 2006 2:41 pm

it only appears to work with value 0 because 0 s the default uninitialised value.

you need to assign oPC properly, but i'm not sure how as I'm not at the toolset
Irreverence Awards 05 :most Ineffectual PC, honourable mention for most likely to give/recieve Spite

Islands of the Lost Head DM
User avatar
Alphonse
Master Sage
 
Posts: 5306
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

PostAuthor: girlysprite » Fri Apr 07, 2006 2:44 pm

Well I need something that defines object oPC.
Something like 'object that entered the module'
However I didnt find that in the lexicon yet.
Gaming doesn't make people voilent, lag does

<Dimotane> I think deep down, when we're honest with ourselves... we're all a pregnant male elf.
User avatar
girlysprite
Silver Contributor
 
Posts: 3661
Joined: Mon Apr 12, 2004 2:38 pm
Location: In my little pony ranch

PostAuthor: Bruno Knotslinger » Fri Apr 07, 2006 3:46 pm

girlysprite wrote:Well I need something that defines object oPC.
Something like 'object that entered the module'
However I didnt find that in the lexicon yet.


I believe you're wanting the OnClientEnter script. The function you're wanting would be something like:

object oPC = GetEnteringObject();

But, yes, defining those variables to be 0 is not needed. Undefined variables always return 0 (for ints), 0.0f (for floats), "" (for strings), etc.

Bruno Knotslinger
Prince of Bloated Discourse
 
Posts: 210
Joined: Thu Aug 11, 2005 9:10 pm
Location: Lubbock, TX


Return to NWN Scripting

Who is online

Registered users: Akai, Bing [Bot], Google [Bot]