Game Development Community

Unkown command

by Mehmet Emre Yorulmaz · in Torque 2D Beginner · 02/17/2015 (6:57 am) · 4 replies

This is the controls cs document i was working with when i encountered the error.

function InputManager::Init_controls(%this)
{

new ActionMap(controls);
controls.bindCmd(keyboard, "a", "Player.moveleft();", "Player.stopmovel();");
controls.bindCmd(keyboard, "d", "Player.moveright();", "Player.stopmover();");
controls.bindCmd(keyboard, "w", "Player.forward();", "Player.stopforward();");
controls.bindCmd(keyboard, "s", "Player.backward();", "Player.stopbackward();");
controls.push();
}

function Player::forward(%this){
%this.setLinearVelocityY(27);}
function Player::stopforward(%this){
%this.setLinearVelocityY(0);}
function Player::backward(%this){
%this.setLinearVelocityY(-27);}
function Player::stopbackward(%this){
%this.setLinearVelocityY(0);}
function Player::moveleft(%this){
%this.setLinearVelocityX(-27);}
function Player::stopmovel(%this){
%this.setLinearVelocityX(0);}
function Player::moveright(%this){
%this.setLinearVelocityX(+27);}
function Player::stopmover(%this){
%this.setLinearVelocityX(0);}


No matter what i do the moveright and stopmover commands dont seem to work,i keep getting the following error;
"<input> (0) Unknown command moveright.
Object player(1182) Player -> sprite -> spritebase -> sceneobject -> behaviorcomponent -> dynamicconsolemethodcomponent -> simcomponent simobject "

#1
02/17/2015 (10:49 pm)
Use whitespace - it's free and it makes your code easier to read.

Remove the + from your moveright() method and see if that helps.
function InputManager::Init_controls(%this)
{
   new ActionMap(controls);
   controls.bindCmd(keyboard, "a", "Player.moveleft();", "Player.stopmovel();");
   controls.bindCmd(keyboard, "d", "Player.moveright();", "Player.stopmover();");
   controls.bindCmd(keyboard, "w", "Player.forward();", "Player.stopforward();");
   controls.bindCmd(keyboard, "s", "Player.backward();", "Player.stopbackward();");
   controls.push();
}

function Player::forward(%this)
{
   %this.setLinearVelocityY(27);
}

function Player::stopforward(%this)
{
   %this.setLinearVelocityY(0);
}

function Player::backward(%this)
{
   %this.setLinearVelocityY(-27);
}

function Player::stopbackward(%this)
{
   %this.setLinearVelocityY(0);
}

function Player::moveleft(%this)
{
   %this.setLinearVelocityX(-27);
}

function Player::stopmovel(%this)
{
   %this.setLinearVelocityX(0);
}

function Player::moveright(%this)
{
   %this.setLinearVelocityX(27); // remove the +
}

function Player::stopmover(%this)
{
   %this.setLinearVelocityX(0);
}
#2
02/17/2015 (11:32 pm)
hello Mehmet ,
I dont have t2d but , i recently encountered something like this playing around with TGE v1.1.2 demo .

It is certain that this function isnt available to the obj (forgive my possibly unclear jargon , Im just a piddler) seeking to access it .

check your console log , make sure your newly edited stuff has compiled successfully , without errors . youll see "compiling filename.cs ..." followed by either "loading compiled filename.cs.dso.." or an ERROR message describing the error/s .

Do you use a function for overwriting these default keybinds ?
You may need to perform the majical delete the old presetkey.cs.dso file trick .(rename it to presetkeysOLD.cs.dso if you dont want to delete it just yet)

make sure all functions are available in the new key configuration.cs file .

These suggestions could quite possibly be completely off the mark . Im sure that your filenames are probably different though , maybe , generally , the same idea . So , hope it helps :) , Good Luck

EDIT : OOPS I didnt notice Mr. Ranft's response .
I thought that this was still unanswered . Oh well :)
#3
02/18/2015 (7:42 am)
Thanks again Mr.Ranft, i guess the whitespaces would have helped me notice that tiny "+":D
And thank you too Mr.Burch for trying to help out i really appreciate it.
#4
02/18/2015 (1:20 pm)
No problem!