Game Development Community

I really don't know what I'm doing wrong

by Donald McMullen · in Torque Game Engine · 03/27/2008 (11:32 pm) · 16 replies

Ok, I'm just starting using TGE, I have been working through the intro and I get to the point where i can make a
button to open mymission (that I have named test1.mis) I have made the function to start the mission "start();".
The command works in the console. But If i put the command in the button it does nothing.
I have also tried following the tutorial word for word "IE:GameOne" and the buttons still don't work.

I would kill so many men just to figure this out.

The Following are all of the script changes i have made.

If anyone could show me how to get this to work I would be a very happy TGE user.

.................I could just be pants on head retarded........



/-----------------------------------------------------------------------------
// LOAD MY MISSION

function start()
{
// make sure we are not connected to a server already
disconnect();

// Create the server and load the mission
createServer("SinglePlayer", expandFilename("./data/missions/test1.mis"));

// Make a local connection
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs("Player");
%conn.setJoinPassword("None");
%conn.connectLocal();
}

//-----------------------------------------------------------------------------
// Package overrides to initialize the game
package ttb {

function onStart()
{
// Initialize the client and the server
Parent::onStart();
initServer();
initClient();
$Editor::newMissionOverride = "Test1/data/missions/test1.mis";
}

//-----------------------------------------------------------------------------

$defaultGame = "Test1";
$displayHelp = false;


//-------------------------------------------------

#1
03/28/2008 (4:59 am)
From what I see, ( and I'm no master) you may need to fix this one line:
change:
createServer("SinglePlayer", expandFilename("./data/missions/test1.mis"));

To:

createServer("SinglePlayer", expandFilename("./[b]Your game folder[/b]/data/missions/test1.mis"));
I think you have to start from the game folder. IE: starter.fps, starter.racing, demo, Game1, etc....
Try that and see if it works. Also, make sure capital and lower case letters are correct. (I don't know if torque looks at that or not, but its good practice to make sure your caps are correct anyway)
#2
03/28/2008 (11:52 am)
Still no go.. The button just highlights when clicked, as if my commands where never entered.
#3
03/28/2008 (11:58 am)
Quote:
But If i put the command in the button it does nothing.

Exactly how did you "put the command in the button"?

You may want to post the GUI object's TorqueScript (which is found in the .gui file you saved the GUI under).
#4
03/28/2008 (12:07 pm)
Mine uses:
createServer(%serverType, "MOD_FOLDER_NAME/data/missions/test1.mis");

Basically, doesn't use the expand filename.

If you decide to keep the expandFilename, you should probably use:
expandFilename("~/data/missions/test1.mis")
where the purpose of the expandFilename is to replace the "~" with the mod folder name.
It also can act to replace the starting "./" with the current folder.
But doing: ("./Your game folder/data/missions/test1.mis"));
would cause an error if your game folder was XXX,
resulting in something like: xxx/xxx/data/missions/test1.mis

from console.cc: expandScriptFilename
if (dStrncmp(src, "~/", 2) == 0)
      // tilde path means load from current codeblock/mod root
      slash = dStrchr(cbName, '/');
   else if (dStrncmp(src, "./", 2) == 0)
      // dot path means load from current codeblock/mod path

edit:
following Stephen's suggestion, one of my button command fields looks like this:

Command = "MM_SetMission(\"XXX/data/missions/XXX.mis\");";

where MM_SetMission is my MainMenuGui method to set a mission from an input string,
XXX is the mod folder name.
Notice that the quotes around the mission name have to be escaped with backslashes.
#5
03/28/2008 (1:04 pm)
Just to clear some things up:

my command field looks like this "start();"

i have also tried "start()", "start();" and just start()

I am so confused, if my function works in the console "start()" why can't it work in a button?

//-----------------------------------------------------------------------------
// LOAD MY MISSION

function start()
{
// make sure we are not connected to a server already
disconnect();

// Create the server and load the mission
createServer("SinglePlayer",("./Test1/data/missions/test1.mis"));

// Make a local connection
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs("Player");
%conn.setJoinPassword("None");
%conn.connectLocal();
}
#6
03/28/2008 (1:09 pm)
Try

command = "start();";

You need a semi-colon at the end of the command inside the quotes as well as at the end of the line itself.

If it's not that, than you'll need to post the section of your script that includes the command= line as Stephen suggests.

Also, after you click the button, look in the console.log (or just drop down the console) and see if you get any kind of error message.
#7
03/28/2008 (1:21 pm)
Several possibilities to consider:


Remember that stock buttons don't respond to mouse down, but to mouse up.

Put a break point in your Torquescript IDE and find out whether Start is being called and follow the execution through line by line, or put some echo() commands into it to find out what is happening.

(Maybe it is called but the createServer fails. )

Check the console for error messages.
#8
03/28/2008 (1:28 pm)
I'm getting a parse error now.

Btw thanks for all the help thus far, you guys rock.
#9
03/28/2008 (1:43 pm)
Try putting something like:
echo("Start has been called!");
inside your start() function to make sure it's getting called. If it's not, try opening your console(~), and typing "start();" as a test.

Let us know what happens from there.
#10
03/28/2008 (2:08 pm)
Like this? /-----------------------------------------------------------------------------
// LOAD MY MISSION

function start()
echo("Start has been called!");

or Like this?

//-----------------------------------------------------------------------------
// LOAD MY MISSION

function start(echo("Start has been called!");)
#11
03/28/2008 (2:09 pm)
This is the correct way.

// LOAD MY MISSION

function start()
echo("Start has been called!");
#12
03/28/2008 (2:45 pm)
Well I get the message in the console.

the function still works, just the button still plays dumb...*cries*
#13
03/28/2008 (2:49 pm)
Well I just started the GettingStarted.pdf all over again.. (no file or script changes) just GameOne.

Button still plays dumb, BUT! no more parse errors.
#14
03/28/2008 (2:56 pm)
Well I just started the GettingStarted.pdf all over again.. (no file or script changes) just GameOne.

Button still plays dumb, BUT! no more parse errors.
#15
03/28/2008 (3:04 pm)
Don't forget the pesky braces:
function start() 
{
	echo("Start has been called!");
}

Using CodeWeaver or Torsion IDEs for script debugging will keep you better aware of parse errors. (They let you know as you are typing, before running the program.)
#16
03/28/2008 (5:34 pm)
Hi,
Can you tell me where your start button is? Is it in the gameTSCtrl?
I guess it is not. Am I right?