From cbebfcd42823ca8603ae1e5e47a6e5d980b13ad5 Mon Sep 17 00:00:00 2001 From: Sachith Hasaranga Seneviratne Date: Tue, 15 Jul 2014 22:19:41 +0530 Subject: [PATCH] Changed trigger creation method to use Vec3 --- data/scripts/farm/start.as | 8 +++++--- src/scriptengine/script_track.cpp | 11 ++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/data/scripts/farm/start.as b/data/scripts/farm/start.as index bce6997c1..861438c67 100644 --- a/data/scripts/farm/start.as +++ b/data/scripts/farm/start.as @@ -1,9 +1,11 @@ void onStart() { displayMessage("Track Loaded"); - //For green valley sheep test. See sheep_approach.as - createTrigger("haybail_deactivate", 69.97 ,8.08 ,-107.84, 20.00); //follows xzy for now - createTrigger("haybail",100.72, 10.20,-26.22 , 30.00); + + Vec3 creationloc = Vec3(69.97 ,8.08 ,-107.84); + Vec3 creationloc2 = Vec3(100.72, 10.20,-26.22); + createTrigger("haybail_deactivate", creationloc, 20.00); + createTrigger("haybail",creationloc2 , 30.00); TrackObject @t_obj = getTrackObject("cow"); SoundEmitter @cowmoo = t_obj.getSoundEmitter(); diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index 054cfc246..9492aac73 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -141,7 +141,7 @@ namespace Scripting r = engine->RegisterGlobalFunction("void enableAnimation(string &in)", asFUNCTION(enableAnimation), asCALL_GENERIC); assert(r >= 0); r = engine->RegisterGlobalFunction("void enableTrigger(string &in)", asFUNCTION(enableTrigger), asCALL_GENERIC); assert(r >= 0); 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)", + r = engine->RegisterGlobalFunction("void createTrigger(string &in,Vec3 &in, float distance)", asFUNCTION(createTrigger), asCALL_GENERIC); assert(r >= 0); r = engine->RegisterGlobalFunction("string getKeyBinding(int input)", asFUNCTION(getKeyBinding), asCALL_GENERIC); assert(r >= 0); @@ -262,10 +262,11 @@ namespace Scripting void createTrigger(asIScriptGeneric *gen) { std::string *script_name = (std::string*)gen->GetArgAddress(0); - float x = gen->GetArgFloat(1); - float y = gen->GetArgFloat(2); - float z = gen->GetArgFloat(3); - float distance = gen->GetArgFloat(4); //triggering distance + Vec3 *creation_loc = (Vec3*)gen->GetArgAddress(1); + float x = creation_loc->getX(); + float y = creation_loc->getY(); + float z = creation_loc->getZ(); + float distance = gen->GetArgFloat(2); //triggering distance core::vector3df posi(x, y, z); core::vector3df hpr(0, 0, 0); core::vector3df scale(1.0f, 1.0f, 1.0f);