Game Development Community

New Keyboard Input

by Jeff Leonard · in Technical Issues · 05/14/2006 (5:51 pm) · 5 replies

So I'm working with the starter.fps that has come with the Torque Engine.

I'm new to this scripting thing, I'm used to Standard OO development. Classes, etc.

What I can't seem to do is find out how the default.bind.cs is linked to the code. I tried to add a 'throw weapon' command and it doesn't compile when I run Torque.

Can someone please help me with this script and what the heck its doing? If I could figure out which functions its calling, it would help me a lot

Thanks.

#1
05/16/2006 (8:46 am)
You must delete the client/config.cs script to compile changes in default.bind.cs. Don't worry, it will be regenerated from the default.bind.cs. Just make sure you haven't made any custom changes to config.cs, or if you have, put them in default.bind.cs.
#2
05/25/2006 (12:42 pm)
I deleted the config.cs and still doesn't work

I'm trying to add in


moveMap.bindCmd(keyboard, "g", "commandToServer('throw',\"Crossbow\");", "");


I'm using the example FPS
I used the use command from before

moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Crossbow\");", "");

so what am I missing?
#3
05/25/2006 (1:14 pm)
Divide and conquer is a very useful debugging technique for all programming environments.

you're introducing two things at once here: a "throw" command, and a keyBinding.
test them seperately.

first, try binding a new key to the already existing "use" command.
if that works, you know the problem is in "throw".

PS
you might have to delete both config.cs and config.dso.
#4
05/25/2006 (1:17 pm)
Try these
moveMap.bindCmd(keyboard, "g", "commandToServer(\'throw\',\"Crossbow\");", "");

or

moveMap.bind(keyboard, "g", Crossbow);
#5
05/25/2006 (1:39 pm)
Still nothing.
I'm compling the default binds. I got 'g' to fire the crossbow so that's done. what I'm trying to do is call this function

function ShapeBase::throw(%this,%data,%amount)
{
// Throw objects from inventory. The onThrow method is
// responsible for decrementing the inventory.
if (%this.getInventory(%data) > 0) {
%obj = %data.onThrow(%this,%amount);
if (%obj) {
%this.throwObject(%obj);
return true;
}
}
return false;
}

I believe that this line;
moveMap.bindCmd(keyboard, "1", "commandToServer('use',\"Crossbow\");", "");
is calling this function

function ShapeBase::use(%this,%data)
{
// Use an object in the inventory.
if (%this.getInventory(%data) > 0)
return %data.onUse(%this);
return false;
}

Those 2 functions are in the same file, "inventory.cs" so I don't see how its not working. Or is there something I need to add to the starter.fps in order to allow me to throw items away?