Added Player Action Enums to scripts

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-06-25 20:32:59 +05:30
parent 21c1f43ba3
commit 3437977806
2 changed files with 5 additions and 8 deletions

View File

@ -1,6 +1,6 @@
void added_script()
{
displayMessage(getKeyBinding("DRIFT") + getKeyBinding("ACCEL") + "This trigger was added by another script");
displayMessage(getKeyBinding(PA::FIRE) + getKeyBinding(PA::ACCEL) + "This trigger was added by another script");
jumpKartTo( 0, 67.90, 99.49 );
Vec3 a;
Vec3 b;

View File

@ -84,15 +84,12 @@ namespace Scripting
void getKeyBinding(asIScriptGeneric *gen)
{
//currently just test if it works
std::string *str = (std::string*)gen->GetArgAddress(0);
int Enum_value = (int)gen->GetArgDWord(0);
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration();
irr::core::stringw control;
//TODO : bind Enumerables?
if (*str == "DRIFT")control = config->getBindingAsString(PA_DRIFT);
if (*str == "FIRE")control = config->getBindingAsString(PA_FIRE);
if (*str == "ACCEL")control = config->getBindingAsString(PA_ACCEL);
PlayerAction ScriptAction = (PlayerAction)Enum_value;
control = config->getBindingAsString(ScriptAction);
std::string key = std::string(irr::core::stringc(control).c_str());
void *key_pointer = &key;
gen->SetReturnObject(key_pointer);
@ -125,7 +122,7 @@ namespace Scripting
r = engine->RegisterGlobalFunction("void disableTrigger(string &in)", asFUNCTION(disableTrigger), asCALL_GENERIC); assert(r >= 0);
r = engine->RegisterGlobalFunction("void createTrigger(string &in,float x,float y,float z, float distance)",
asFUNCTION(createTrigger), asCALL_GENERIC); assert(r >= 0);
r = engine->RegisterGlobalFunction("string getKeyBinding(string &in)", asFUNCTION(getKeyBinding), asCALL_GENERIC); assert(r >= 0);
r = engine->RegisterGlobalFunction("string getKeyBinding(int input)", asFUNCTION(getKeyBinding), asCALL_GENERIC); assert(r >= 0);
/*