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.

Suggestions for Debugging Scripts

Page: 1 of 1
 tk102
03-28-2004, 3:29 AM
#1
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.
 greymeister
03-28-2004, 5:00 AM
#2
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 (c) 2002 Bioware Corp.

#include "k_inc_debug"

void main()
{
AddAvailableNPCByObject(NPC_CANDEROUS,GetObjectByT ag("canderous"));
AddPartyMember(NPC_CANDEROUS,GetObjectByTag("canderous"));
}


Have you tried including for logging?
 tk102
03-28-2004, 5:14 AM
#3
I've seen that script, but what if you already have Canderous in your party?

What do you mean "including for logging"?
 Helodermatid
03-28-2004, 5:26 AM
#4
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. :)
 tk102
03-28-2004, 5:42 AM
#5
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.
 tk102
03-28-2004, 6:36 AM
#6
Here's another:

SetGlobalFadeIn();

I suppose you could vary the color and the timing to mean different things during debugging.
 tk102
04-11-2004, 5:38 PM
#7
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 (http://webpages.charter.net/krumsick/kotor) 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).
 tk102
04-11-2004, 6:18 PM
#8
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.
 shosey
04-12-2004, 6:50 PM
#9
is there a way for the little text bubble to be displayed on screen. Like when you talk to npc's that don't really start a dialog with you - just have a bubble say something?
 tk102
04-12-2004, 6:53 PM
#10
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.
 beancounter
09-02-2004, 7:45 PM
#11
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.
 shosey
09-02-2004, 7:56 PM
#12
thats pretty cool, good find!
 tk102
09-02-2004, 9:11 PM
#13
I'm glad you found this thread and reposted that beancounter. I have this thread bookmarked. :)
 Darth333
09-02-2004, 9:20 PM
#14
Originally posted by tk102
I have this thread bookmarked. :)
T7nowhere took care of that long ago: it is stickied in his tutorial sticky ;)
( don't tell me you don't read the stickies tk102 :mad: :D )
Page: 1 of 1