PDA

View Full Version : Boolean and Number Tutorial

harIII
11-24-2009, 09:50 AM
Would anybody know of a good tutorial teaching people how to create, operate, and execute booleans and numbers in the globalcat.2da?

Exile007
11-24-2009, 10:26 PM

^Well, that's on Local Variables, but Local and Global Variables have similar principles, the only difference is that Global Variables are... global :p, while Local Variables exist only within the module that it is set in.

Global Variables/Booleans are set with two fairly simple functions

SetGlobalNumber(nGlobalNumber, "Value")
//The "value" is a range between -128 and 127. You can use values to keep track of completed tasks in game.

SetGlobalBoolean(nGlobalBoolean, TRUE);
//Booleans always start out FALSE

You also should check via

if (GetGlobalNumber("your global number") == Value)
//Value is again, -128 through 127
//You can also use other inequality symbols instead of "==" like ">"

//This checks if your global boolean returns TRUE

There are a whole bunch of great examples in silveredge's Brotherhood of Shadow mod, specifically the first module of the Orion.

//sales_person8.nss
int StartingConditional() {
int i = GetGlobalNumber("Tar_PazNik");
if (i == 4){
return TRUE;
}
return FALSE;
}

Hope this helped a bit ;)

Qui-Gon Glenn
11-27-2009, 03:10 PM
On this subject, I have been wondering something for a bit, perhaps Exile007 or another friendly forumite might illuminate me.

Would it be possible to add to the global numerics something that other mods by one modder, or a team, could use so that one mod would *know* that another related mod is installed (installing any of the related mods would either create or modify the .2da in question)?

Example: Mod "A" is installed, and in that installation, a field is added to globalcat.2da, that is numeric in value, we'll call it 10. When Mod "B" is installed, the presence of the value 10 tells the patcher to change it to 30, 30 telling both mods that both mods are installed, thus changing the availability of certain dialogs.

This would create a sort of "unlockable" content situation. I think that the old KMM did something similar to what I am looking for, by creating an .kmm file, but I would like something that uses only in-game scripting/editing.

It doesn't seem too far out there to me, but I have not done any scripting in a while, and have not studied enough on globals and .2da's in general.

harIII
11-29-2009, 07:26 PM
I think that's why somebody created the TSLPatcher.

Qui-Gon Glenn
12-01-2009, 07:54 PM
I think that's why somebody created the TSLPatcher.
Right... except you missed my point. What I was talking about in my question would be 90% accomplished with the patcher.

I was not trying to hijack your thread, so I will abandon this question for the time being, and ask it another time.

Exile007
12-02-2009, 11:43 PM
I was not trying to hijack your thread, so I will abandon this question for the time being, and ask it another time.

Because this is a Global Number/Boolean thread, I say it's fair game to answer your question. :)

If I understand what you're saying, then the answer to your question is: YES. TSLRP, IIRC, has a "IS_TSLRP_INSTALLED" type global boolean that is set in 201TEL. The on-enter script of 201TEL sets the boolean to TRUE if the mod is installed. So technically speaking, someone could say, modify an on-enter script for deathdisco's Jedi Temple mod to check to see if it's installed by setting a global boolean. If the mod IS installed, then they could have a check in another dialog where the Exile could say something like "I've traveled to Coruscant, the temple is abandoned." Anything is possible with scripting, except for world peace. ;)

Qui-Gon Glenn
12-04-2009, 12:13 PM
^^^ Yeah... I forgot about that somehow, because TSLRP also installs a registry key... I simply forgot that it did both things. Thanks, Exile007!

My reason for thinking about this, is, if one were to release a mod in installments, or make a major mod out of several mini-mods, they could "interact" in KotOR/TSL with that .2da key. This is something I have been thinking about for some time, and could take away some fear of releasing some things that are not complete by themselves, but are still interesting/playable as stand-alone.