logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Boolean True/False in GetPersistentInt and SetPersistentInt

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Lugoun



Joined: 18 May 2007
Posts: 36

PostPosted: Fri Jun 01, 2007 1:57    Post subject: Boolean True/False in GetPersistentInt and SetPersistentInt Reply with quote

Can we use NWN script style TRUE and FALSE when Setting and Getting Persistent Int's?

For example will this work?
SetPersistentInt(oPC, "Stuff", TRUE);

Or, do I have to do:
SetPersistentInt(oPC, "Stuff", 1);

Thanks,
Lug
_________________
Lugoun
www.hotta-rpg.org
Back to top
View user's profile Send private message
Grinning Fool



Joined: 12 Feb 2005
Posts: 264

PostPosted: Fri Jun 01, 2007 4:33    Post subject: Reply with quote

Yes. TRUE/FALSE are just int constants behind the scenese in nwscript.
_________________
Khalidine, a NWN2 persistent world

Looking for volunteers.
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Fri Jun 01, 2007 5:48    Post subject: Reply with quote

But remember TRUE = 0
So you can get some non-true true results if the variable is NOT set.
This is why you see a lot of code "if (!false)", true if not set OR =0.

Cheers
Gryphyn
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Fri Jun 01, 2007 9:25    Post subject: Reply with quote

Gryphyn wrote:
But remember TRUE = 0

Hmm?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Grinning Fool



Joined: 12 Feb 2005
Posts: 264

PostPosted: Fri Jun 01, 2007 20:41    Post subject: Reply with quote

Gryphyn wrote:
But remember TRUE = 0


Alright, you lost me with that one.
_________________
Khalidine, a NWN2 persistent world

Looking for volunteers.
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Jun 02, 2007 1:11    Post subject: Reply with quote

Code:
if (GetLocalInt(obj,"name"))

returns true if the local "name" is not set OR the value of the local "name" = 0
So when testing for the condition 'true' you need to know if it's because "name" has been set, or the default (0) is being used.

Cheers
Gryphyn
Back to top
View user's profile Send private message
Lugoun



Joined: 18 May 2007
Posts: 36

PostPosted: Sat Jun 02, 2007 2:16    Post subject: Reply with quote

Cool, thanks for the reminder that the TRUE/FALSE is really just a constant int and verifying I can stick to my old habits Smile

Hmm, I pretty much just use this:
if(GetLocalInt(obj, "name") == FALSE)
when testing to see if an int has not been set or is equal to 0. Usually for a 'do once' or a 'turn on/turn off' situation.

I can see how it would be easy leave the '== FALSE' off and not get the result you expected.
_________________
Lugoun
www.hotta-rpg.org
Back to top
View user's profile Send private message
FunkySwerve



Joined: 02 Jun 2005
Posts: 377

PostPosted: Sat Jun 02, 2007 2:32    Post subject: Reply with quote

Nwscript defaults to FALSE (0) not TRUE (nonzero) for nonset local ints, and 1 is TRUE. Unless you are talking about something else?
Funky
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Jun 02, 2007 5:35    Post subject: Reply with quote

FunkySwerve wrote:
Nwscript defaults to FALSE (0) not TRUE (nonzero) for nonset local ints, and 1 is TRUE. Unless you are talking about something else?
Funky

Sorry Folks, True=1, False=0 in NWScript.
Just a little confused with all other languages I've been dealing with recently.
--but my point was "watch out for the 'not-set' trap." just in case it makes a difference to your condition checking.

Cheers
Gryphyn

*I'll shut-up now Confused
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group