Added additional script support for removing track objects tested with farm track with the haybail.as script

This commit is contained in:
Sachith Hasaranga Seneviratne
2014-03-17 18:12:03 +05:30
parent 35be1f142a
commit 9ac9cfbdca
3 changed files with 13 additions and 6 deletions

View File

@@ -6,4 +6,5 @@ void onTrigger()
*/
displayMessage("Everything Disappeared!");
disableAnimation("hayBail.b3d");
}

View File

@@ -16,9 +16,12 @@
#include <angelscript.h>
#include "script_engine.hpp"
#include "scriptstdstring.h"
#include "modes/world.hpp"
#include "tracks/track_object_manager.hpp"
#include "tracks/track.hpp"
#define UINT unsigned int
typedef unsigned int DWORD;
//#define UINT unsigned int
//typedef unsigned int DWORD;
using namespace irr;
@@ -63,7 +66,10 @@ void dispmsg(asIScriptGeneric *gen){
irr::core::stringw out = irr::core::stringw((*input).c_str()); //irr::core::stringw supported by message dialogs
new TutorialMessageDialog((out),true);
}
void disableAnimation(asIScriptGeneric *gen){
std::string *str = (std::string*)gen->GetArgAddress(0);
World::getWorld()->getTrack()->getTrackObjectManager()->disable(*str);
}
std::string ScriptEngineOne::doit(std::string scriptName)
{
//displaymsg();
@@ -237,7 +243,7 @@ void ConfigureEngine(asIScriptEngine *engine)
}
r = engine->RegisterGlobalFunction("void displayMessage(string &in)", asFUNCTION(dispmsg), asCALL_GENERIC); assert(r>=0);
r = engine->RegisterGlobalFunction("void disableAnimation(string &in)", asFUNCTION(disableAnimation), asCALL_GENERIC); assert(r>=0);
// It is possible to register the functions, properties, and types in
// configuration groups as well. When compiling the scripts it then
// be defined which configuration groups should be available for that

View File

@@ -722,10 +722,11 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
}
else if (m_action == "haybail")
{
if (World::getWorld()->getTrack()->getTrackObjectManager()->getStatus("hayBail.b3d"))
/*if (World::getWorld()->getTrack()->getTrackObjectManager()->getStatus("hayBail.b3d"))
World::getWorld()->getTrack()->getTrackObjectManager()->disable("hayBail.b3d");
else
World::getWorld()->getTrack()->getTrackObjectManager()->enable("hayBail.b3d");
*/
//Check performance
/*
clock_t t1,t2;
@@ -739,7 +740,6 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
*/
ScriptEngineOne* m_script_engine = new ScriptEngineOne();
m_script_engine->doit(m_action);
}