Added animation enabling and reactivation

This commit is contained in:
sachith500 2014-05-22 12:39:46 +05:30
parent 5056f2cc7e
commit 4578ddc073
5 changed files with 33 additions and 11 deletions

View File

@ -0,0 +1,11 @@
void onTrigger()
{
/*to activate this add the following line to stk-assets/farm/scene.xml
<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"/>
*/
displayMessage("Haybail reactivated");
enableAnimation("hayBail.b3d");
squashKart(0,35.0); //id of kart,time to squash
}

View File

@ -5,7 +5,7 @@ void onTrigger()
<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"/>
*/
displayMessage("Wow! Such Message. Very Script... wow");
displayMessage("Haybail deactivated");
disableAnimation("hayBail.b3d");
//squashKart(0,35.0); //id of kart,time to squash
squashKart(0,35.0); //id of kart,time to squash
}

View File

@ -36,6 +36,7 @@ using namespace irr;
// Function prototypes for binding.
void displayMessage(asIScriptGeneric *gen);
void disableAnimation(asIScriptGeneric *gen);
void enableAnimation(asIScriptGeneric *gen);
void squashKart(asIScriptGeneric *gen);
ScriptEngine::ScriptEngine(){
@ -67,7 +68,10 @@ void disableAnimation(asIScriptGeneric *gen){
std::string *str = (std::string*)gen->GetArgAddress(0);
World::getWorld()->getTrack()->getTrackObjectManager()->disable(*str);
}
void enableAnimation(asIScriptGeneric *gen){
std::string *str = (std::string*)gen->GetArgAddress(0);
World::getWorld()->getTrack()->getTrackObjectManager()->enable(*str);
}
void squashKart(asIScriptGeneric *gen){
int id = (int)gen->GetArgDWord(0);
float time = gen->GetArgFloat(1);
@ -182,6 +186,7 @@ void ScriptEngine::configureEngine(asIScriptEngine *engine)
r = engine->RegisterGlobalFunction("void displayMessage(string &in)", asFUNCTION(displayMessage), asCALL_GENERIC); assert(r>=0);
r = engine->RegisterGlobalFunction("void disableAnimation(string &in)", asFUNCTION(disableAnimation), asCALL_GENERIC); assert(r>=0);
r = engine->RegisterGlobalFunction("void enableAnimation(string &in)", asFUNCTION(enableAnimation), asCALL_GENERIC); assert(r>=0);
r = engine->RegisterGlobalFunction("void squashKart(int id, float time)", asFUNCTION(squashKart), asCALL_GENERIC); assert(r>=0);
// It is possible to register the functions, properties, and types in
@ -217,9 +222,6 @@ int ScriptEngine::compileScript(asIScriptEngine *engine, std::string scriptName)
int len = ftell(f);
fseek(f, 0, SEEK_SET);
// On Win32 it is possible to do the following instead
// int len = _filelength(_fileno(f));
// Read the entire file
std::string script;
script.resize(len);
@ -230,9 +232,7 @@ int ScriptEngine::compileScript(asIScriptEngine *engine, std::string scriptName)
std::cout << "Failed to load script file." << std::endl;
return -1;
}
//std::cout<<script<<std::endl;
//script = "float calc(float a, float b){ return 23;}//asfafagadbsgsgsbfdxhbdhdhdfhdfbdfbdbfg";
//len = script.size();
// Add the script sections that will be compiled into executable code.
// If we want to combine more than one file into the same script, then
// we can call AddScriptSection() several times for the same module and

View File

@ -91,7 +91,7 @@ void TrackObjectManager::disable(std::string name){
TrackObject* curr;
for_in (curr,m_all_objects){
if (curr->getName() == (name)){
//OutputDebugString("came here2");
curr->setEnable(false);
}
@ -101,7 +101,7 @@ void TrackObjectManager::enable(std::string name){
TrackObject* curr;
for_in (curr,m_all_objects){
if (curr->getName() == (name)){
//OutputDebugString("came here2");
curr->setEnable(true);
}

View File

@ -803,6 +803,17 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
ScriptEngine* m_script_engine = World::getWorld()->getScriptEngine();
m_script_engine->runScript(m_action);
}
else if (m_action == "haybail-activate")
{
/*to activate this add the following line to stk-assets/farm/scene.xml
<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"/>
*/
m_action_active=false;
ScriptEngine* m_script_engine = World::getWorld()->getScriptEngine();
m_script_engine->runScript(m_action);
}
else if (m_action == "tutorial_giftboxes")
{
m_action_active = false;