Added animation enabling and reactivation
This commit is contained in:
parent
5056f2cc7e
commit
4578ddc073
11
src/scriptengine/haybail-activate.as
Normal file
11
src/scriptengine/haybail-activate.as
Normal 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
|
||||||
|
}
|
@ -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"/>
|
<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");
|
disableAnimation("hayBail.b3d");
|
||||||
//squashKart(0,35.0); //id of kart,time to squash
|
squashKart(0,35.0); //id of kart,time to squash
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ using namespace irr;
|
|||||||
// Function prototypes for binding.
|
// Function prototypes for binding.
|
||||||
void displayMessage(asIScriptGeneric *gen);
|
void displayMessage(asIScriptGeneric *gen);
|
||||||
void disableAnimation(asIScriptGeneric *gen);
|
void disableAnimation(asIScriptGeneric *gen);
|
||||||
|
void enableAnimation(asIScriptGeneric *gen);
|
||||||
void squashKart(asIScriptGeneric *gen);
|
void squashKart(asIScriptGeneric *gen);
|
||||||
|
|
||||||
ScriptEngine::ScriptEngine(){
|
ScriptEngine::ScriptEngine(){
|
||||||
@ -67,7 +68,10 @@ void disableAnimation(asIScriptGeneric *gen){
|
|||||||
std::string *str = (std::string*)gen->GetArgAddress(0);
|
std::string *str = (std::string*)gen->GetArgAddress(0);
|
||||||
World::getWorld()->getTrack()->getTrackObjectManager()->disable(*str);
|
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){
|
void squashKart(asIScriptGeneric *gen){
|
||||||
int id = (int)gen->GetArgDWord(0);
|
int id = (int)gen->GetArgDWord(0);
|
||||||
float time = gen->GetArgFloat(1);
|
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 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 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);
|
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
|
// 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);
|
int len = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
// On Win32 it is possible to do the following instead
|
|
||||||
// int len = _filelength(_fileno(f));
|
|
||||||
|
|
||||||
// Read the entire file
|
// Read the entire file
|
||||||
std::string script;
|
std::string script;
|
||||||
script.resize(len);
|
script.resize(len);
|
||||||
@ -230,9 +232,7 @@ int ScriptEngine::compileScript(asIScriptEngine *engine, std::string scriptName)
|
|||||||
std::cout << "Failed to load script file." << std::endl;
|
std::cout << "Failed to load script file." << std::endl;
|
||||||
return -1;
|
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.
|
// 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
|
// 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
|
// we can call AddScriptSection() several times for the same module and
|
||||||
|
@ -91,7 +91,7 @@ void TrackObjectManager::disable(std::string name){
|
|||||||
TrackObject* curr;
|
TrackObject* curr;
|
||||||
for_in (curr,m_all_objects){
|
for_in (curr,m_all_objects){
|
||||||
if (curr->getName() == (name)){
|
if (curr->getName() == (name)){
|
||||||
//OutputDebugString("came here2");
|
|
||||||
curr->setEnable(false);
|
curr->setEnable(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ void TrackObjectManager::enable(std::string name){
|
|||||||
TrackObject* curr;
|
TrackObject* curr;
|
||||||
for_in (curr,m_all_objects){
|
for_in (curr,m_all_objects){
|
||||||
if (curr->getName() == (name)){
|
if (curr->getName() == (name)){
|
||||||
//OutputDebugString("came here2");
|
|
||||||
curr->setEnable(true);
|
curr->setEnable(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -803,6 +803,17 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
|
|||||||
ScriptEngine* m_script_engine = World::getWorld()->getScriptEngine();
|
ScriptEngine* m_script_engine = World::getWorld()->getScriptEngine();
|
||||||
m_script_engine->runScript(m_action);
|
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")
|
else if (m_action == "tutorial_giftboxes")
|
||||||
{
|
{
|
||||||
m_action_active = false;
|
m_action_active = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user