From acd11ce7386b3214a4295ba45fd5458d977081aa Mon Sep 17 00:00:00 2001 From: Sachith Hasaranga Seneviratne Date: Sat, 12 Jul 2014 09:13:47 +0530 Subject: [PATCH] Added sound trigger (one time and cyclic) --- data/scripts/farm/triggers.as | 15 +++++++++------ src/scriptengine/script_track.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/data/scripts/farm/triggers.as b/data/scripts/farm/triggers.as index 883ec88eb..4463a2fae 100644 --- a/data/scripts/farm/triggers.as +++ b/data/scripts/farm/triggers.as @@ -27,12 +27,15 @@ void haybail_deactivate() */ - displayMessage("Haybail reactivated"); - //enableAnimation("hayBail.b3d"); - squashKart(0,35.0); //id of kart,time to squash - TrackObject @t_obj = getTrackObject("hayBail.b3d"); - Animator @haybailAnimator = t_obj.getAnimator(); - haybailAnimator.setPaused(false); + displayMessage("Haybail reactivated"); + //enableAnimation("hayBail.b3d"); + squashKart(0,35.0); //id of kart,time to squash + TrackObject @t_obj = getTrackObject("hayBail.b3d"); + Animator @haybailAnimator = t_obj.getAnimator(); + haybailAnimator.setPaused(false); + TrackObject @moo_sound = getTrackObject("cow"); + SoundEmitter @cowmoo = moo_sound.getSoundEmitter(); + cowmoo.playOnce(); } diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index ff2845a48..054cfc246 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -83,6 +83,14 @@ namespace Scripting { ((TrackObjectPresentationSound*)memory)->stopSound(); } + void playOnce(void *memory) + { + ((TrackObjectPresentationSound*)memory)->triggerSound(false); //false = once + } + void playLoop(void *memory) + { + ((TrackObjectPresentationSound*)memory)->triggerSound(true); //true = loop + } void setLoop(int start, int end, void *memory) { ((TrackObjectPresentationMesh*)(memory))->setLoop(start,end); @@ -182,6 +190,8 @@ namespace Scripting r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter @getSoundEmitter()", asMETHOD(TrackObject, getSound), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundEmitter", "void move(Vec3 &in)", asFUNCTION(movePresentation), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("SoundEmitter", "void stop()", asFUNCTION(stop), asCALL_CDECL_OBJLAST); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundEmitter", "void playOnce()", asFUNCTION(playOnce), asCALL_CDECL_OBJLAST); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundEmitter", "void playLoop()", asFUNCTION(playLoop), asCALL_CDECL_OBJLAST); assert(r >= 0);