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.
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.
About the author
#2
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?
05/25/2006 (12:42 pm)
I deleted the config.cs and still doesn't workI'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
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.
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
moveMap.bindCmd(keyboard, "g", "commandToServer(\'throw\',\"Crossbow\");", "");
or
moveMap.bind(keyboard, "g", Crossbow);
05/25/2006 (1:17 pm)
Try thesemoveMap.bindCmd(keyboard, "g", "commandToServer(\'throw\',\"Crossbow\");", "");
or
moveMap.bind(keyboard, "g", Crossbow);
#5
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?
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?
Torque Owner J. Alan Atherton