Game Development Community

More advanced 'bindCmd' problem

by Nicolai Dutka · in Torque Game Engine Advanced · 07/07/2009 (9:29 am) · 2 replies

I am trying to create an advanced 'bindCmd' but I am having some issues...

The closest I could get to what I need is this:
%type         = guiTextEditType.getText();
  %data         = guiTextEditData.getText();
  %tex          = guiTextEditTex.getText();
  %xform        = guiTextEditXform.getText();
  %damage       = guiTextEditDamage.getText();
  %value        = guiTextEditValue.getText();
  %key          = guiTextEditKey.getText();
  %keyType      = guiTextEditKeyType.getText();
  %animated     = guiTextEditAnimated.getText();
  %timer        = guiTextEditTimer.getText();
  %switchDoor   = guiTextEditSwitchDoor.getText();
  %action       = guiTextEditAction.getText();
  %target       = guiTextEditTarget.getText();
  %end          = guiTextEditEnd.getText();
  %child        = guiTextEditChild.getText();

 MoveMap.bindCmd(keyboard,guiTextEditBind.getText(),"makeObject(\"%type\",\"%dataCheck\",\"%tex\",\"%xform\",\"%damage\",\"%value\",\"%key\",\"%keyType\",\"%animated\",\"%timer\",\"%switchDoor\",\"%action\",\"%target\",\"%end\",\"%child\");","");

The problem is apparent, I am using local variables and when the button is pressed, I get errors about 'could not find %type', 'could not find %dataCheck', etc, etc.

I could simply change all the variables to be $global, but that's where I run into another problem... The same function needs to be run using up to 10 different keybinds and each one needs to do something different, hence the local variables... As you can see, I am not hard-coding which keyboard key to use, I am reading in from a text edit box. This is so my team can bind the makeObject function to the numbers 1 through 0 on the keyboard top row... So, global variables will not work here...

Any ideas?


#1
07/07/2009 (3:43 pm)
even something as simple as the following is giving me a "parse error":

MoveMap.bindCmd(keyboard,1,"makeObject("@%obj@");","");
#2
07/07/2009 (4:36 pm)
Ok, I managed to get this working. The problem was, one of the 'type' of objects that can be made in our game is a 'switch' used to open doors and such. Unfortunately, '$type[switch]' results in a parse error because 'switch' is built-in console command derived from the C++ command of the same name. To fix that part, I simply renamed all of our 'switch' objects to 'lever' objects.

Now that I am not getting parse errors, I was able to come up with a solution:

$type[guiTextEditBind.getText()]         = %type;
    $dataCheck[guiTextEditBind.getText()]    = %dataCheck;
    $tex[guiTextEditBind.getText()]          = %tex;
    $xForm[guiTextEditBind.getText()]        = %xForm;
    $damage[guiTextEditBind.getText()]       = %damage;
    $value[guiTextEditBind.getText()]        = %value;
    $key[guiTextEditBind.getText()]          = %key;
    $keyType[guiTextEditBind.getText()]      = %keyType;
    $animated[guiTextEditBind.getText()]     = %animated;
    $timer[guiTextEditBind.getText()]        = %timer;
    $leverDoor[guiTextEditBind.getText()]    = %leverDoor;
    $action[guiTextEditBind.getText()]       = %action;
    $target[guiTextEditBind.getText()]       = %target;
    $end[guiTextEditBind.getText()]          = %end;
    $child[guiTextEditBind.getText()]        = %child;
    MoveMap.bindCmd(keyboard,guiTextEditBind.getText(),"makeObject("@$type[guiTextEditBind.getText()]@","@$dataCheck[guiTextEditBind.getText()]@","@$tex[guiTextEditBind.getText()]@","@$xform[guiTextEditBind.getText()]@","@$damage[guiTextEditBind.getText()]@","@$value[guiTextEditBind.getText()]@","@$key[guiTextEditBind.getText()]@","@$keyType[guiTextEditBind.getText()]@","@$animated[guiTextEditBind.getText()]@","@$timer[guiTextEditBind.getText()]@","@$leverDoor[guiTextEditBind.getText()]@","@$action[guiTextEditBind.getText()]@","@$target[guiTextEditBind.getText()]@","@$end[guiTextEditBind.getText()]@","@$child[guiTextEditBind.getText()]@");","");

Hope this helps someone else out there!