Page 1 of 1

initialize variables onmoduleload

PostPosted: Fri Apr 07, 2006 2:39 pm
Author: girlysprite
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.

PostPosted: Fri Apr 07, 2006 2:41 pm
Author: Alphonse
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

PostPosted: Fri Apr 07, 2006 2:44 pm
Author: girlysprite
Well I need something that defines object oPC.
Something like 'object that entered the module'
However I didnt find that in the lexicon yet.

PostPosted: Fri Apr 07, 2006 3:46 pm
Author: Bruno Knotslinger
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.