Jump to content

Home

Suggestions for Debugging Scripts


tk102

Recommended Posts

Hey all,

Has anyone found a simple function (like a one or two-liner) that can be used for debugging scripts during the game?

 

So far I've tried the following functions to no avail:

PrintString

DebugString

SpeakString

AurPostString

 

I'm sure somebody out there has a clever debug technique.

Link to comment
Share on other sites

I'm not sure if you've already looked here, but I saw this in the uncompiled scripts area:

 

//:: k_act_canderadd

/*

adds canderous to the party

*/

//:: Created By: Jason Booth

//:: Copyright © 2002 Bioware Corp.

 

#include "k_inc_debug"

 

void main()

{

AddAvailableNPCByObject(NPC_CANDEROUS,GetObjectByTag("canderous"));

AddPartyMember(NPC_CANDEROUS,GetObjectByTag("canderous"));

}

 

 

Have you tried including for logging?

Link to comment
Share on other sites

Actually I would like to know this as well. I have tried most of the SpeakString type functions listed in nwscript but none of them seems to do anything. Maybe Bioware disabled these in the release version?

 

In any case, right now I am using

 

object oPC = GetFirstPC();

AssignCommand(oPC,PlayAnimation(26,1.0,5.0));

 

I use different animations if there are more than one line or branch which I need to test.

 

I am sure there are more efficient methods out there, so let us know if you find anything. :)

Link to comment
Share on other sites

H -- glad you're still here. I saw the ShipBuild function is used to turn off debug functions in the k_inc_debug.nss script. Maybe Bioware decided to go one step further and integrate that function into the debug functions themselves.

 

So we have these debug methods.

  • Spawn Characters
  • Play animations

 

I was looking for writing something to the Feedback screen or show a "Credits Earned" or "Darkside Points Gained" icon at the top of the screen.

Link to comment
Share on other sites

  • 2 weeks later...

Here's one more way:

 

First give yourself a global variable to work with by adding a new row to globalcat.2da and saving it in the override folder. Call it something like DEBUG_NUM and make it a Number.

 

Then in your script you can simply call:

SetGlobalNumber("DEBUG_NUM",55);

to set the number to 55 or whatever. After your script fires during the game, save the game and use Global Variable Comparison Tool to see what the value of DEBUG_NUM has changed to.

 

There are such things as Global Strings as well, but the comparison tool doesn't support them (yet).

Link to comment
Share on other sites

Okay the Global Comparison Tool has been updated to include String comparisons so you can now add a new string to the globalcat.2da and then invoke

SetGlobalString("DEBUG_STR","My debug string");

.

Then the comparison tool will show you what the value is. GFF Editor will too if you prefer.

 

That is probably the closest we'll get to the coveted "PrintString" command.

 

Edit: After reading the hoopla in nwscript.nss about 'don't use this function [setGlobalString] without permission', I thought I'd better try it. It works fine.

Link to comment
Share on other sites

Wouldn't that be sweet? There are functions that are supposed to do that like SpeakString etc. However, it seems that Bioware in their infinite wisdom disabled all of those functions when they distributed the game.

 

NWN has the functions available evidently.

Link to comment
Share on other sites

  • 4 months later...

I posted this a month or so ago, but I figured I would add it to the sticky post to help anyone new to scripting KOTOR.

 

The command SendMessageToPC will print a message to the ingame feedback screen. The proper syntax is:

 

object oPC=GetFirstPC();

string cmMessage = "This is a test";

 

SendMessageToPC(oPC, cmMessage);

 

This script will print out "This is a test" in the Feedback screen. You can also print out variables, as long as you convert them to a string. It is also helpful to include the creatures name in your debug string so you know what creature is firing the script. Try the following:

 

object oPC=GetFirstPC();

string cmMessage = GetName(OBJECT_SELF) + "-" + "This is a test";

 

SendMessageToPC(oPC, cmMessage);

 

I hope this helps.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...