lfnetwork.com mark read register faq members calendar

Thread: Conditional Script Help
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 04-01-2012, 05:48 PM   #1
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Conditional Script Help

Alright, so I've been using conditional scripts for a while now, but I've never actually had need for a conditional that checked for two globals to be certain values. Here's my attempt at making one:

Code:
int StartingConditional()
{
  int iResult = GetGlobalBoolean("DT_CHECK3");

  int iResult2 = GetGlobalBoolean("DT_CHECK4");

if(

    (iResult == TRUE) &&

    (iResult2 == FALSE) ) {

  return iResult && iResult2;  
 
}
}
Now I keep on getting an error saying that not all paths return a value. What should I change to fix this script?


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version
Fallen Guardian is offline   you may: quote & reply,
Old 04-01-2012, 05:55 PM   #2
JCarter426
Senior Member
 
JCarter426's Avatar
 
Join Date: Feb 2008
Location: Look to your left.
Posts: 1,636
I don't think you can return more than one thing. This should manage what you require:
Code:
int StartingConditional()
{
  int iResult = GetGlobalBoolean("DT_CHECK3");

  int iResult2 = GetGlobalBoolean("DT_CHECK4");

if(

    (iResult == TRUE) &&

    (iResult2 == FALSE) ) {

  return TRUE;

}

else return FALSE; 
 
}


JCarter426 is offline   you may: quote & reply,
Old 04-01-2012, 06:42 PM   #3
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Alright, thanks JC.


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version
Fallen Guardian is offline   you may: quote & reply,
Old 04-02-2012, 11:30 PM   #4
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Alright, I come here with a new conditional script woe today.

Basically, when doing Journal entries for a quest, a realized that if the PC were to do something in a certain order, a journal entry with a higher ID number would be added before a journal entry with a smaller ID number. Now, that means when the time came for the smaller ID'd journal entry to be given, it didn't fire. So, I created a duplicate of the smaller journal entry and gave it an ID higher than the entry that was causing problems. I then made this conditional script:

Code:
void main()
{

     object oPC=GetFirstPC();

object oPlaceable = GetObjectByTag("lockerlg001");

  int iResult = GetLocalBoolean(oPlaceable, 40);

if ( iResult == FALSE) {


  AddJournalQuestEntry("DT_MERC", 30);
  
if ( iResult == TRUE) {

  AddJournalQuestEntry("DT_MERC", 32);
  
}
}
}
Now everything works all fine and well if iResult == false. Yet, if iResult == True the higher journal entry doesn't get added. What am I doing wrong?


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version
Fallen Guardian is offline   you may: quote & reply,
Old 04-03-2012, 12:30 AM   #5
VarsityPuppet
Master of Puppets
 
VarsityPuppet's Avatar
 
Join Date: May 2009
Location: MN
Posts: 1,253
Current Game: Chrono Trigger
Contest winner - Modding Forum Veteran Veteran Modder Helpful! 
Booleans in nwscript are kinda weird.

You'll have better results if you put:

Code:
void main(){

	object oPC=GetFirstPC();
	object oPlaceable = GetObjectByTag("lockerlg001");

	if (GetLocalBoolean(oPlaceable, 40)) 
  		AddJournalQuestEntry("DT_MERC", 32);

	else
  		AddJournalQuestEntry("DT_MERC", 30);
}
That said, if you still want to use your original script, you have to make sure that you close the brackets for the if statement. To better illustrate the issue:

Code:
YOUR CODE
	if ( iResult == FALSE) {


		AddJournalQuestEntry("DT_MERC", 30);
  	
		if ( iResult == TRUE) {

			AddJournalQuestEntry("DT_MERC", 32);
  
		}
	}

	
SHOULD BE


	if ( iResult == FALSE) {


		AddJournalQuestEntry("DT_MERC", 30);
	}
  	
	if ( iResult == TRUE) {

		AddJournalQuestEntry("DT_MERC", 32);
  
	}

VarsityPuppet is offline   you may: quote & reply,
Old 04-03-2012, 01:33 AM   #6
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Thanks VP.


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version
Fallen Guardian is offline   you may: quote & reply,
Old 04-03-2012, 04:27 AM   #7
Hassat Hunter
Forumite
 
Join Date: Jan 2010
Posts: 560
Also (atleast for KOTOR2 that is) putting ", TRUE" behind the journal entry number allows lower entries from overriding the higher entries. Which can be very handy in non-linear quest progressions.

Example (from Kotor2 though);
Code:
void main()
{
int nDxnOpen;
if(GetGlobalNumber("500OND_Civil_War") > 1) nDxnOpen = 1; else nDxnOpen = 0;
int nDanOpen;
if(GetGlobalNumber("602DAN_End") > 0) nDanOpen = 1; else nDanOpen = 0;
int nDxnEst = GetGlobalNumber("301NAR_Geeda_Dxn");
int nDanEst = GetGlobalNumber("301NAR_Geeda_Dan");

int nJournal = GetJournalEntry("NewTradeRoutes");

if (nJournal == 0) return;

if(nDxnEst == 1 && nDanEst == 1)
    {
        AddJournalQuestEntry("NewTradeRoutes", 33, TRUE);
        return;
    }
if(nDxnEst == 1)
    {
		if(nDanOpen == 0)
		{
			AddJournalQuestEntry("NewTradeRoutes", 13, TRUE);
			return;
		}
		if(nDanOpen == 1)
		{
			AddJournalQuestEntry("NewTradeRoutes", 21, TRUE);
			return;
		}
    }
if(nDanEst == 1)
    {
		if(nDxnOpen == 0)
		{
			AddJournalQuestEntry("NewTradeRoutes", 31, TRUE);
			return;
		}
		if(nDxnOpen == 1)
		{
			AddJournalQuestEntry("NewTradeRoutes", 12, TRUE);
			return;
		}
    }
if(nDanOpen == 1 && nDxnOpen ==1)
     {
        AddJournalQuestEntry("NewTradeRoutes", 22, TRUE);
        return;
     }
if(nDanOpen == 1)
     {
        AddJournalQuestEntry("NewTradeRoutes", 21, TRUE);
        return;
     }
if(nDxnOpen == 1)
     {
        AddJournalQuestEntry("NewTradeRoutes", 12, TRUE);
        return;
     }
AddJournalQuestEntry("NewTradeRoutes", 11);
}
Hassat Hunter is offline   you may: quote & reply,
Old 04-03-2012, 04:54 AM   #8
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Oh sweet, thanks HH. It appears as though that should work in KotOR 1, judging by nwscript. I'll try it and report back.


EDIT: Alright, it works. Though, I found that since the dialogue option that assigns the entry is still available after you recieve the entry, you can advance the plot to a different journal entry and then come back, talk to the person, and then have the old entry assigned again. Here's how I set up my scripts to stop this from happening:

Code:
void main(){

	object oPC=GetFirstPC();

        object oNPC = GetObjectByTag("50aa_comm");

  int iResult = GetLocalBoolean(oNPC, 40);

if ( iResult == FALSE) {

 int bAllowOverrideHigher=TRUE;

  		AddJournalQuestEntry("DT_MERC", 30, bAllowOverrideHigher);

 DelayCommand(0.1, ExecuteScript("dt_comm_flse", OBJECT_SELF));


}


return;
  
}
Code:
void main()
{

object oNPC = GetObjectByTag("50aa_comm");

    SetLocalBoolean(oNPC, 40, TRUE);

}


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version

Last edited by Fallen Guardian; 04-03-2012 at 05:11 AM.
Fallen Guardian is offline   you may: quote & reply,
Old 04-03-2012, 06:14 AM   #9
Hassat Hunter
Forumite
 
Join Date: Jan 2010
Posts: 560
Pretty sure you can do that in 1 script... (just add the SetLocalBoolean immediately after the journal entry.
Hassat Hunter is offline   you may: quote & reply,
Old 04-03-2012, 12:51 PM   #10
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Yeah, but I'd already set up a similar situation like this and I'm too lazy to recompile it.


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version
Fallen Guardian is offline   you may: quote & reply,
Old 04-05-2012, 03:35 PM   #11
Fallen Guardian
Wandering the Galaxy...
 
Fallen Guardian's Avatar
 
Join Date: Aug 2010
Location: Unknown Regions
Posts: 1,286
Current Game: Knights of the Old Republic
Veteran Modder Helpful! 
Okay, so I've been trying to use this script:

Code:
void main()
{

     object oPC=GetFirstPC();

	object oNPC = GetObjectByTag("d14ab_dcm"); 

  int iResult = GetLocalBoolean(oNPC, 21);

if ( iResult == FALSE) {

  AddJournalQuestEntry("DT_Q4", 25);


}

if ( iResult == TRUE) {

  		AddJournalQuestEntry("DT_Q4", 20);
  
   }
}
Yet for some reason when iResult is true, the journal entry isn't given. Now this is designed so that no matter what, whichever entry is going to be given it's already higher than the previous entry, thus no need for int bOverrideHigher. Now I tried using the type of script VP suggested on April 2nd, but then neither entry would be given. So, I decided to use the revised format that VP suggested, leading to my script above. Is there something I should change to make my script work?


The truly fallen cannot return to the light. If someone "falls" and "returns," they never really, truly fell.

Current Work in Progress: Dantooine Tension

Released Works
Blaster Pistol Enhancement
Dustil Restoration
Ebon Hawk Texture Enhancement
Gaffi Stick Improvement
Weapon Model Overhaul Texture Rework (Thanks to Toasty Fresh!)
Sunry Murder Recording Enhancement
VP's Hi Poly Tin Cans - KotOR 1 Version
Fallen Guardian is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Conditional Script Help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:58 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.