Script crashes?
by Robert Melais · in Torque Game Builder · 01/16/2009 (3:12 pm) · 0 replies
Since the site isnt up i guess all the way on that TND thing and the docs that come with TGB dosent really have much info on thier scripts, hopeing someone can help me here. I decided to expand the Fish game tutoiral and mess around with diffrent things to get the hang of diffrent things with the scripts. I have no clue why but right now when I run a function from inside the FishFood cs file when the "score" gets so high it just crashes out. Im using that CodeWeavers for the scripting, and it dosent say any errors. The Function it calls, Works, it starts the game in the first place. Its called, get the Level decided where your starting game at, sets globals, loads the level. Works to start the game. If i call it from the FishFood.cs file, crashes. Also crashes if i just try to loadLevel, endLevel, addToLevel, or almost any function like that. Can someone tell me what i have to do to make it run?
Here is the FishFood.cs part = the commented out lines all crash when run
function FishFood::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if(%dstObj.class $= "PlayerFish")
{
%srcObj.spawn();
%dstObj.modifyLife($FoodValue);
$FishScore++;
FishGUIScore.text = "Score:" SPC $FishScore;
if($FishScore >= 20)
{
$FishLevel = 2;
//sceneWindow2D.endLevel();
//sceneWindow2D.loadLevel("game/data/levels/level2.t2d");
//StartMeNow(1);
}
}
else if (%dstObj.class $= "Fish")
{
%srcObj.spawn();
}
}
The Function that starts the whole game ...
function StartMeNow(%level)
{
sceneWindow2D.endLevel();
$FishLevel = %level;
FishGUILevel.text = "Level:" SPC $FishLevel;
if($FishLevel = 1)
{
$FishMinSpeed = 0;
$FishMaxSpeed = 0;
$PlayerFishHSpeed = 15;
$PlayerFishVSpeed = 30;
$FishDrain = 5;
$FoodMinSpeed = 5;
$FoodMaxSpeed = 30;
exec("./Player.cs");
exec("./FishFood.cs");
sceneWindow2D.loadLevel("game/data/levels/level1.t2d");
}
else if($FishLevel = 2)
{
$FishMinSpeed = 5;
$FishMaxSpeed = 15;
$PlayerFishHSpeed = 15;
$PlayerFishVSpeed = 30;
$FishDrain = 2;
sceneWindow2D.loadLevel("game/data/levels/level2.t2d");
}
}
The function StartMeNow(%level) is called when the game starts after you click a button, it executes the command function StartMeNow(1); to start a new game. With or without the function the FishFood.cs crashes as soon as the player gets 20 score. The Concole just stops logging no errors in it, and i did a Debug run in the codeweavers and it only says what the console says. Any ideas please?
Here is the FishFood.cs part = the commented out lines all crash when run
function FishFood::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if(%dstObj.class $= "PlayerFish")
{
%srcObj.spawn();
%dstObj.modifyLife($FoodValue);
$FishScore++;
FishGUIScore.text = "Score:" SPC $FishScore;
if($FishScore >= 20)
{
$FishLevel = 2;
//sceneWindow2D.endLevel();
//sceneWindow2D.loadLevel("game/data/levels/level2.t2d");
//StartMeNow(1);
}
}
else if (%dstObj.class $= "Fish")
{
%srcObj.spawn();
}
}
The Function that starts the whole game ...
function StartMeNow(%level)
{
sceneWindow2D.endLevel();
$FishLevel = %level;
FishGUILevel.text = "Level:" SPC $FishLevel;
if($FishLevel = 1)
{
$FishMinSpeed = 0;
$FishMaxSpeed = 0;
$PlayerFishHSpeed = 15;
$PlayerFishVSpeed = 30;
$FishDrain = 5;
$FoodMinSpeed = 5;
$FoodMaxSpeed = 30;
exec("./Player.cs");
exec("./FishFood.cs");
sceneWindow2D.loadLevel("game/data/levels/level1.t2d");
}
else if($FishLevel = 2)
{
$FishMinSpeed = 5;
$FishMaxSpeed = 15;
$PlayerFishHSpeed = 15;
$PlayerFishVSpeed = 30;
$FishDrain = 2;
sceneWindow2D.loadLevel("game/data/levels/level2.t2d");
}
}
The function StartMeNow(%level) is called when the game starts after you click a button, it executes the command function StartMeNow(1); to start a new game. With or without the function the FishFood.cs crashes as soon as the player gets 20 score. The Concole just stops logging no errors in it, and i did a Debug run in the codeweavers and it only says what the console says. Any ideas please?