From b2a563c746bcccc688ad83b2159d6a79c379a847 Mon Sep 17 00:00:00 2001 From: Sachith Hasaranga Seneviratne <sachith500@gmail.com> Date: Wed, 13 Aug 2014 11:57:49 +0530 Subject: [PATCH] Fixed the ID for script created triggers were not being added to the track_object instance --- data/scripts/farm/start.as | 6 ++++-- data/scripts/farm/triggers.as | 8 ++++---- src/scriptengine/script_track.cpp | 1 + src/tracks/track_object.hpp | 1 + src/tracks/track_object_presentation.hpp | 2 ++ 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/data/scripts/farm/start.as b/data/scripts/farm/start.as index 861438c67..641f968fb 100644 --- a/data/scripts/farm/start.as +++ b/data/scripts/farm/start.as @@ -4,8 +4,10 @@ void onStart() 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); + createTrigger("haybail_deactivate", creationloc, 20.00); + createTrigger("haybail_activate",creationloc2 , 30.00); + //disableTrigger("haybail_deactivate"); + //disableTrigger("haybail_activate"); TrackObject @t_obj = getTrackObject("cow"); SoundEmitter @cowmoo = t_obj.getSoundEmitter(); diff --git a/data/scripts/farm/triggers.as b/data/scripts/farm/triggers.as index 001a157e3..6f19aa34b 100644 --- a/data/scripts/farm/triggers.as +++ b/data/scripts/farm/triggers.as @@ -1,8 +1,8 @@ -void haybail() +void haybail_activate() { -/*to activate this add the following line to stk-assets/farm/scene.xml +/*to activate this you may also add the following line to stk-assets/farm/scene.xml (instead of creating it via the start script -<object type="action-trigger" action="haybail" distance="30.0" xyz="100.72 10.20 -26.22" hpr="0.0 -0.0 0.0" scale="7.00 7.00 7.00"/> +<object type="action-trigger" action="haybail_activate" distance="30.0" xyz="100.72 10.20 -26.22" hpr="0.0 -0.0 0.0" scale="7.00 7.00 7.00"/> */ displayMessage("Haybail deactivated"); @@ -24,7 +24,7 @@ void haybail_deactivate() { /*to activate this add the following line to stk-assets/farm/scene.xml -<object type="action-trigger" action="haybail-activate" distance="10.0" xyz="69.97 8.08 -107.84" hpr="0.0 -0.0 0.0" scale="7.00 7.00 7.00"/> +<object type="action-trigger" action="haybail-deactivate" distance="10.0" xyz="69.97 8.08 -107.84" hpr="0.0 -0.0 0.0" scale="7.00 7.00 7.00"/> */ displayMessage("Haybail reactivated"); diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index 65b4b9d73..cef82b8b1 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -180,6 +180,7 @@ namespace Scripting new TrackObjectPresentationActionTrigger(posi, *script_name, distance); TrackObject* tobj = new TrackObject(posi, hpr, scale, "none", newtrigger, false /* isDynamic */, NULL /* physics settings */); + tobj->setID(*script_name); World::getWorld()->getTrack()->getTrackObjectManager()->insertObject(tobj); } diff --git a/src/tracks/track_object.hpp b/src/tracks/track_object.hpp index db32df8fb..db03d1ea6 100644 --- a/src/tracks/track_object.hpp +++ b/src/tracks/track_object.hpp @@ -109,6 +109,7 @@ public: * e.g. be overwritten by physical objects etc. */ virtual void handleExplosion(const Vec3& pos, bool directHit) {}; void setEnable(bool mode); + void setID(std::string obj_id) { m_id = obj_id; } const std::string& getLodGroup() const { return m_lod_group; } diff --git a/src/tracks/track_object_presentation.hpp b/src/tracks/track_object_presentation.hpp index 3ef74a31c..161c88646 100644 --- a/src/tracks/track_object_presentation.hpp +++ b/src/tracks/track_object_presentation.hpp @@ -353,6 +353,8 @@ public: virtual void onTriggerItemApproached(Item* who) OVERRIDE; virtual void reset() OVERRIDE { m_action_active = true; } + + virtual void setEnable(bool status) OVERRIDE{ m_action_active = status; } };