initialize variables onmoduleload

Moderator: Event DM

Post Reply
User avatar
girlysprite
Elder Sage
Posts: 3659
Joined: Mon Apr 12, 2004 2:38 pm
Location: In my little pony ranch
Contact:

initialize variables onmoduleload

Post by 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
Alphonse
Master Sage
Posts: 5302
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

Post by 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
girlysprite
Elder Sage
Posts: 3659
Joined: Mon Apr 12, 2004 2:38 pm
Location: In my little pony ranch
Contact:

Post by 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.
Bruno Knotslinger
Prince of Bloated Discourse
Posts: 210
Joined: Thu Aug 11, 2005 9:10 pm
Location: Lubbock, TX

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