Sign in to follow this  
TimBob12

Conditional Scripts

Recommended Posts

Script Condidionals

 

Hello There,

When I was making my Tatooine Job Office (http://www.lucasforums.com/showthread.php?t=206577)

 

I wanted to find how to only make certain conversation options available after certain conditions had been met. Now I couldn't find a dedicated tutorial anywhere so I had to ask.

 

So I thought I'd make it easier by writing this tutorial. This is my first tutorial so go easy on me :)

 

Things you will need:

 

KOTOR Tool

 

 

Things you should read:

 

http://www.lucasforums.com/showthread.php?t=143412

http://www.lucasforums.com/showthread.php?t=143681

http://www.lucasforums.com/showthread.php?t=143390

 

 

Right Script Conditionals. What can they do?

 

Script conditionals can be used when you want something (usually a dialog option) to only be displayed once a certain condition has been met. Some of the common conditions used are:

  • Global Variables
  • Local Variables
  • Item in PC Inventory
  • Certain Classes

 

 

There are many other conditions but as long as the condition returns either TRUE or FALSE then it will work.

 

Lets start Scripting!

 

First of all if you have only coded a little bit in KOTOR before then this will look completely different.

 

int StartingConditional() 
{
 int iResult;

 iResult = ((GetGlobalBoolean( "your_global_bool" ) == TRUE) );

 return iResult;  

}

 

Right lets break this down.

 

int StartingConditional() 

 

This starting line is different than most scripts in KOTOR for one reason. In most scripts you do not require an outcome as they usually make something happen. We however want an outcome so the dialogue (or whatever) knows what to do / display.

 

Most scripts start with:

 

void main()

 

Void is used when no output is required and means nothing or to get rid of.

Int is a variable type meaning that it has to be filled by something.

The StartingConditional() part tells the game that it is to be used as a Starting Conditional

 

Script.

 

The next bit

 

int iResult;

 

Here you are declaring the variable "iResult". You will use this variable to store the outcome and tell the game what to do. If you've never used variables before get used to it because they are VITAL to scripting.

 

Then next bit

 

 iResult = ((GetGlobalBoolean( "your_global_bool" ) == TRUE) );

 

This is the most important part of your script. It determines what must happen for the conversation option to become available and then puts it into the "iResult" variable. In this example it gets whether a global bool is TRUE and then outputs TRUE into "iResult"but there are other options such as

 

 object oW1 = GetObjectByTag("black_market_pad");

 iResult = GetIsObjectValid(oW1);

 

This checks for the existance of "black_market_pad" in the PC's inventory and puts TRUE in the

"iResult" variable.

 

The last bit

return iResult;  

 

This simply tells the script YES or NO / TRUE or FALSE. If the script sees TRUE it will display the dialog option.

 

Then you must simply compile the script and put the resulting file in the same place as your dialog. (For information on compiling scripts see one of the top links)

 

To put it into the acttual dialog find the line you want to hide until the condition has been met and in the box that says

 

"Script that determines availablilty" put the name of your script file (minus the extension)

 

Thats it.

 

Hope this helped.

 

If you have any questions at all I will do my best to answer them.

 

Thanks

 

TB12


  • Thanks 1

Share this post


Link to post
Share on other sites

Oh, you silly script-kiddies.

It's so much easier to do this inside the .dlg editor (note the one in KOTOR tool doesn't work with KOTOR2 !!!) than with a script as long as you only need to check for 2 specific things.

 

So my advice; don't use a script unless you really need to check for 3 specific things in a single convobranch. Sure, you could use a continue, but that looks sloppy and amateuristic so scripts are important for that professional feel.

 

Anyway, continue on ;D.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this