.cs files not showing on TGB
by ani · in Torque Game Builder · 11/15/2009 (11:29 pm) · 7 replies
hi, I recently got TGB.I've been following tutorials on writing behaviors and I wrote one today using the Notepad and I saved it as a .cs file , then I put it on my game's behavior folder and reloaded the project but when I go to the behaviors list on TGB ,after clicking on the object I want to use it on,the behavior just doesn't show up,it doesn't appear.I downloaded a sample of a .cs file and put it into the same behaviors folder ,did the same thing I did before and it showed.I don't know why it's not reading the .cs files that I write on my computer.Please I need help, I've tried everything.
~Anilu~
~Anilu~
#2
~Anilu~
11/16/2009 (8:56 pm)
hi, thanks for answering.I am writing the scripts using the notepad.I can't check for errors because they won't even open on the game engine,they don't show up on the behaviors list.I downloaded the Demo version of Torsion and wrote them there and they worked.I think I am going to have to buy Torsion u.u .Thanks for the answer, have a nice day.~Anilu~
#3
11/16/2009 (10:40 pm)
You can always open up the console.log file to see what the errors are.
#4
Some people use Notepad++ as editor. but i use UltraEdit. there is torque script syntax that you can import in it, so you can see highlighted code.
11/17/2009 (7:08 am)
You open the console with ~ key while in the running game. And you can close it with ctrl+~Some people use Notepad++ as editor. but i use UltraEdit. there is torque script syntax that you can import in it, so you can see highlighted code.
#5
11/17/2009 (11:49 am)
Did notepad save it as a .cs.txt file?
#6
Now I have another question, how can I write a simple scoring behavior?I tried using the one on the TGB documentation(with a game I'm trying to make)but it doesn't work ,this is what I am using:
To display the score:
if (!isObject(DisplayScoreBehavior))
{
%template = new BehaviorTemplate(DisplayScoreBehavior);
%template.friendlyName = "Display Score";
%template.behaviorType = "GUI";
%template.description = "Allows a text object to display the score";
}
function DisplayScoreBehavior::onAddToScene(%this, %scenegraph)
{
$currentScore = 0;
%this.owner.text = "Score:" SPC $currentScore;
}
function DisplayScoreBehavior::updateScore(%this)
{
%this.owner.text = "Score:" SPC $currentScore;
}
And to ScorePoints:
if (!isObject(ScorePointsBehavior))
{
%template = new BehaviorTemplate(ScorePointsBehavior);
%template.friendlyName = "Score Points";
%template.behaviorType = "Game";
%template.description = "Gives the object a point value for scoring purposes";
%template.addBehaviorField(pointValue, "How much the object is worth", int, 10);
%template.addBehaviorField(counter, "The score counter object", object, "", t2dSceneObject);
}
function ScorePointsBehavior::onRemoveFromScene(%this, %scenegraph)
{
%counter = %this.counter.getBehavior("DisplayScoreBehavior");
if (!isObject(%counter))
return;
$currentScore = $currentScore + %this.pointValue;
%counter.updateScore();
}
I am using the DisplayScore one on the score box and the scorePoints one on the enemy.I want to make it so that when I shoot an enemy I score points.Please help me.
~Anilu~
11/17/2009 (12:13 pm)
Hi, notepad saved it as a .cs file.I checked for errors and It didn't find any.It's just not reading them, but when I save it using torsion it works just fine.I guess I'm going to keep using torsion or try UltraEdit :S.Now I have another question, how can I write a simple scoring behavior?I tried using the one on the TGB documentation(with a game I'm trying to make)but it doesn't work ,this is what I am using:
To display the score:
if (!isObject(DisplayScoreBehavior))
{
%template = new BehaviorTemplate(DisplayScoreBehavior);
%template.friendlyName = "Display Score";
%template.behaviorType = "GUI";
%template.description = "Allows a text object to display the score";
}
function DisplayScoreBehavior::onAddToScene(%this, %scenegraph)
{
$currentScore = 0;
%this.owner.text = "Score:" SPC $currentScore;
}
function DisplayScoreBehavior::updateScore(%this)
{
%this.owner.text = "Score:" SPC $currentScore;
}
And to ScorePoints:
if (!isObject(ScorePointsBehavior))
{
%template = new BehaviorTemplate(ScorePointsBehavior);
%template.friendlyName = "Score Points";
%template.behaviorType = "Game";
%template.description = "Gives the object a point value for scoring purposes";
%template.addBehaviorField(pointValue, "How much the object is worth", int, 10);
%template.addBehaviorField(counter, "The score counter object", object, "", t2dSceneObject);
}
function ScorePointsBehavior::onRemoveFromScene(%this, %scenegraph)
{
%counter = %this.counter.getBehavior("DisplayScoreBehavior");
if (!isObject(%counter))
return;
$currentScore = $currentScore + %this.pointValue;
%counter.updateScore();
}
I am using the DisplayScore one on the score box and the scorePoints one on the enemy.I want to make it so that when I shoot an enemy I score points.Please help me.
~Anilu~
#7
11/17/2009 (5:54 pm)
You know what can cause a problem. If you are saving cs file in a different encoding. I think thy all MUST be ANSII, not UTF-8 or anything else. Otherwise TGB throws an error in a first line of script file.
Associate William Lee Sims
Machine Code Games