Crash when loading a level
by Ricardo Vladimiro · in Torque Game Builder · 03/22/2007 (1:58 am) · 5 replies
Hi everyone
I've got a problem here. I'm using this line:
The thing is, when I run it inside TGB it works fine, when I build the game and run the exe it crashes the game.
The weird part is that I had this working on the prototype with some minor changes:
- The function where that line lies is called by call ( %function ), on the prototype it ran outside any level.
- $resources was not used, but the full path was written
I'm clueless here. Any thoughts?
I've got a problem here. I'm using this line:
schedule ( 100, 0, sceneWindow2D.loadLevel ( $resources @ "/data/levels/testBoardMode.t2d" ));
The thing is, when I run it inside TGB it works fine, when I build the game and run the exe it crashes the game.
The weird part is that I had this working on the prototype with some minor changes:
- The function where that line lies is called by call ( %function ), on the prototype it ran outside any level.
- $resources was not used, but the full path was written
I'm clueless here. Any thoughts?
#2
Solved the problem. So the schedule not called from an object crashes when called from inside a level? Any ideas?
Thank you for the help Igor, much appreciated.
03/22/2007 (8:13 am)
SceneWindow2D.schedule ( 100, "loadLevel", $resources @ "/data/levels/testBoardMode.t2d");Solved the problem. So the schedule not called from an object crashes when called from inside a level? Any ideas?
Thank you for the help Igor, much appreciated.
#3
The actual function and the variables you are passing need to be comma separated as well.
You need to quote the passed function reference so that the engine can parse them correctly.
The 0 you pass as the second parameter is the object reference. If you a pass a zero it will not pass an obect reference to the function. If you specify an object id or use the alternate syntax that Igor used that object reference will be passed to your function.
I hope that un-muddies the water slightly. I spent a bit of time in the past trying to understand how schedule handled things.
03/22/2007 (11:12 am)
The problem with the way you tried to do it in your example is that you are trying to reference the method of an actual instance of the object. TGB doesnt know how to find the function. To accomplish it the way you have it layed out above you would reference the class that the object is constructed from. schedule(100, sceneWindow2d, "sceneWindow::loadlevel", $resources @ "/data/levels/testBoardMode.t2d"); OR //I find this the easiest when accessing class methods. sceneWindow2D.schedule ( 100, "loadLevel", $resources @ "/data/levels/testBoardMode.t2d"); OR you could say schedule(100, 0, "sceneWindow::loadlevel", sceneWindow2d, $resources @ "/data/levels/testBoardMode.t2d");All these work the same internally, we are just using different methods to pass the object id.
The actual function and the variables you are passing need to be comma separated as well.
You need to quote the passed function reference so that the engine can parse them correctly.
The 0 you pass as the second parameter is the object reference. If you a pass a zero it will not pass an obect reference to the function. If you specify an object id or use the alternate syntax that Igor used that object reference will be passed to your function.
I hope that un-muddies the water slightly. I spent a bit of time in the past trying to understand how schedule handled things.
#4
The actual function and the variables you are passing need to be comma separated as well.
You need to quote the passed function reference so that the engine can parse them correctly.
The 0 you pass as the second parameter is the object reference. If you a pass a zero it will not pass an obect reference to the function. If you specify an object id or use the alternate syntax that Igor used that object reference will be passed to your function.
I hope that un-muddies the water slightly. I spent a bit of time in the past trying to understand how schedule handled things.
03/22/2007 (11:20 am)
The problem with the way you tried to do it in your example is that you are trying to reference the method of an actual instance of the object. TGB doesnt know how to find the function. To accomplish it the way you have it layed out above you would reference the class that the object is constructed from. schedule(100, sceneWindow2d, "sceneWindow::loadlevel", $resources @ "/data/levels/testBoardMode.t2d"); OR //I find this the easiest when accessing class methods. sceneWindow2D.schedule ( 100, "loadLevel", $resources @ "/data/levels/testBoardMode.t2d"); OR you could say schedule(100, 0, "sceneWindow::loadlevel", sceneWindow2d, $resources @ "/data/levels/testBoardMode.t2d");All these work the same internally, we are just using different methods to pass the object id.
The actual function and the variables you are passing need to be comma separated as well.
You need to quote the passed function reference so that the engine can parse them correctly.
The 0 you pass as the second parameter is the object reference. If you a pass a zero it will not pass an obect reference to the function. If you specify an object id or use the alternate syntax that Igor used that object reference will be passed to your function.
I hope that un-muddies the water slightly. I spent a bit of time in the past trying to understand how schedule handled things.
#5
I used the 0 because it's mentioned in the script reference and it work on the prototype. Why did it work on the prototype? I believe it worked because it was outside any level. I had a function that incremented a global variable which was the level name after the level exited. And then I used the schedule with it to load a new level.
Anyway, I'm just glad it works.
03/22/2007 (11:53 am)
Thank you for explaining.I used the 0 because it's mentioned in the script reference and it work on the prototype. Why did it work on the prototype? I believe it worked because it was outside any level. I had a function that incremented a global variable which was the level name after the level exited. And then I used the schedule with it to load a new level.
Anyway, I'm just glad it works.
Torque Owner Igor Kuryatnikov
sceneWindow2D.schedule ( 100, "loadLevel", $resources @ "/data/levels/testBoardMode.t2d");
EDIT: or this (to be sure):
%path = $resources @ "/data/levels/testBoardMode.t2d";
sceneWindow2D.schedule ( 100, "loadLevel", %path);