LucasForums

LucasForums (http://www.lucasforums.com/index.php)
-   Tutorials: Scripting (http://www.lucasforums.com/forumdisplay.php?f=597)
-   -   Debugging Scripts with SendMessageToPC function (http://www.lucasforums.com/showthread.php?t=125847)

tk102 03-28-2004 02:29 AM

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

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

Original thread

beancounter 09-02-2004 06:45 PM

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:
Code:

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:
Code:

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

SendMessageToPC(oPC, cmMessage);

Or if you want a 1-liner:
Code:

SendMessageToPC(GetFirstPC(),"OBJECT_SELF's  name is: "+GetName(OBJECT_SELF));
I hope this helps.


All times are GMT -4. The time now is 11:24 AM.

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