Game Development Community

Need Script help wont let me post :|

by Robert Melais · in Torque Game Builder · 01/16/2009 (3:17 pm) · 3 replies

Is thier a IRC Channel or anything for help on this. This is my 12th atempt to post and so far all post give me a Application Error from the website.

This is the Function, when the Player Score hits 20, its supposed to load a new level. When you hit score 20, just crashes. Every commented line does the same thing. Rather I call a outside function, or attempt to load the level/endlevel inside it, all crash application.

function FishFood::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if(%dstObj.class $= "PlayerFish")
{
%srcObj.spawn();
%dstObj.modifyLife($FoodValue);
$FishScore = 30;
FishGUIScore.text = "Score:" SPC $FishScore;
if($FishScore >= 20)
{
//$FishLevel = 2;
//sceneWindow2D.endLevel();
//sceneWindow2D.loadLevel("game/data/levels/level2.t2d");
//exec("./Levels.cs");
//StartMeNow(1);
}
}
else if (%dstObj.class $= "Fish")
{
%srcObj.spawn();
}
}

#1
01/18/2009 (11:58 am)
I'm still extremely new to Torque, but let me see if I can help. First, I think you have the commands in your function backwards...Instead of this:

$FishLevel = 2; 
sceneWindow2D.endLevel(); 
sceneWindow2D.loadLevel("game/data/levels/level2.t2d"); 
exec("./Levels.cs"); 
StartMeNow(1);

do this:

$FishLevel = 2; 
exec("./Levels.cs"); 
sceneWindow2D.loadLevel("game/data/levels/level2.t2d"); 
StartMeNow(1); 
sceneWindow2D.endLevel();

I think once you do ".endlevel" it stops execution at that line for the current level.
#2
01/19/2009 (6:53 am)
Actually, all those commands will be executed simultaneously. Call exec("./Levels.cs"); somewhere else in your code, like the game.cs. try doing a search for the other exec statements and stick it with those.

Patrick
#3
01/19/2009 (7:59 am)
This is usually done with a scheduled command.