Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Anyone know how to check what planet you're currently on? TSL...

Page: 1 of 1
 mrdefender
01-08-2006, 8:34 PM
#1
I'm working on some options for my wrist console that would/should only to show up if the player is on a specific planet.... I want to check all of the rooms on that planet, if the player is in any of them, the option would show up....

Would this script work properly for the entire onderon planet?
I did a search for "*ond*.rim" , I found some ###ond.rim and some ###_s.rim but I used the names without the _s ....

(used the "c_area_ebonhawk" script as a point of reference...)
int StartingConditional() {
if ((GetModuleName() == "501OND") ||
(GetModuleName() == "502OND") ||
(GetModuleName() == "503OND") ||
(GetModuleName() == "504OND") ||
(GetModuleName() == "505OND") ||
(GetModuleName() == "506OND") ||
(GetModuleName() == "510OND") ||
(GetModuleName() == "511OND") ||
(GetModuleName() == "512OND") )
{ return TRUE; }
return FALSE;
}
 Prime
01-08-2006, 10:02 PM
#2
Yeah, I think that should work, and it looks like you have all the Onderon ones.

Note that if you want to find all the areas for a planet, you can just got to KOTOR II -> RIMs -> Modules and you can see them all.
 Darth333
01-08-2006, 10:02 PM
#3
Instead of listing all the modules on one planet, this is what I used in the USM random loot script:


string sModule = GetModuleName();
string sSub = GetSubString(sModule,3,3);

if (sSub=="OND")
{
blabla
}

It will apply to all the modules on Onderon.

Here is how it works:

I first get the module name with the GetModuleName() function.
Then, if you look at how the modules are named in TSL, you will notice that they all start with xxxABC (3 numbers followed by 3 letters). For a given planet, the numbers change but not the letters. Per example for Onderon,each module is named xxxOND .
This is where the GetSubString function comes in: you want to make your script applcable to all the modules that have OND as the 4th,5th and 6th characters in their name.

GetSubString(string sString, int nStart, int nCount);

nStart is after how many characters you want the check to begin and nCount how many characters you want to check.

If you use only GetModuleName you have to list all the modules on a planet.

Btw, for use with a dialogue, there is a script ready to use: c_mand_planet.nss It says it's for Mandalore but you can use it for whatever you want. You only need to specify the planet in the .dlg file.
 mrdefender
01-08-2006, 10:58 PM
#4
Cool! Thanks alot!! :)

Just another quick question, I took a look at that mand_planet script... If I'm not mistaken, "nPlanet" is associated with the "case #" ? So If I were to check if we're on telos, then nPlanet would have to be 2... ? right? :|

I've run into alot of these "case" scripts and never got to figguring out exactly how they work (though this is the first script that makes sense to me as far as cases go :lol:)

int StartingConditional()
{
int nPlanet = GetScriptParameter(1);
int nResult = FALSE;

string sCurModule = GetModuleName();
string sSubString = GetSubString(sCurModule,3,3);

AurPostString("Current Module = " + sCurModule + " Substring = " + sSubString,10,5,5.0);

switch(nPlanet)
{
case 2:
{
if(sSubString == "TEL")
nResult = TRUE;
} break;
 Darth333
01-09-2006, 12:10 AM
#5
For the switch and case statements, check this: http://library.thinkquest.org/C0111571/manual.php?tid=13)

In the .dlg file, you should see small boxes named P1, p2, P3, P4 , P5.

If you look at c_mand_planet.nss you should see the following line: int nPlanet = GetScriptParameter(1);
It refers to the first box (P1) . So just attach the script as you would normally do in the conditioanl script field and type the number for the planet you want in the P1 box of your .dlg branch (Telos would be 2).

Look at mandalores .dlg file if you want to see it in use (Entries 60, 63, 67, 69, 71, 73, 76)

The explanation is a bit messy but it's pass midnight here :p
 stoffe
01-09-2006, 7:15 AM
#6
Instead of listing all the modules on one planet, this is what I used in the USM random loot script:
(snip)
string sSub = GetSubString(sModule,3,3);


If you do this and you really want to be on the safe side you might want to check that the module name is in the default format first. Like...

string sModule = GetModuleName();

if (GetStringLength(sModule) == 6) {
int iNum = StringToInt(GetStringLeft(sModule, 3));
string sPlanet = GetStringRight(sModule, 3);

if ((iNum >= 501) && (iNum <= 520) && (sPlanet == "OND")) {
// We are probably on Onderon...
}
}


Otherwise this could potentially return a "false positive" if the player is in a non-standard module created by a modder that happen to contain "OND" at that place in the module name.

Granted, the risk of that happening is fairly small. :)
Page: 1 of 1