Started adding configuration key bindings to scripting to move all tutorial messages to scripting
This commit is contained in:
parent
588ec991a8
commit
a219585a41
11
data/scripts/greenvalley/sheep_approach.as
Normal file
11
data/scripts/greenvalley/sheep_approach.as
Normal file
@ -0,0 +1,11 @@
|
||||
void onTrigger()
|
||||
{
|
||||
|
||||
//TrackObject @t_obj = getTrackObject("anim_sheep2.b3d");
|
||||
//t_obj.setEnable(false);
|
||||
//Mesh @sheepMesh = t_obj.getMesh();
|
||||
//displayMessage("moo");
|
||||
//sheepMesh.setLoop(6,9); //rapid-nod sheep
|
||||
runScript("sheep_dance");
|
||||
|
||||
}
|
10
data/scripts/greenvalley/sheep_dance.as
Normal file
10
data/scripts/greenvalley/sheep_dance.as
Normal file
@ -0,0 +1,10 @@
|
||||
void onTrigger()
|
||||
{
|
||||
|
||||
TrackObject @t_obj = getTrackObject("anim_sheep2.b3d");
|
||||
//t_obj.setEnable(false);
|
||||
Mesh @sheepMesh = t_obj.getMesh();
|
||||
//displayMessage("moo");
|
||||
sheepMesh.setLoop(1,3); //rapid-nod sheep
|
||||
//runScript("sheep_approach");
|
||||
}
|
8
data/scripts/greenvalley/start.as
Normal file
8
data/scripts/greenvalley/start.as
Normal file
@ -0,0 +1,8 @@
|
||||
void onStart()
|
||||
{
|
||||
|
||||
displayMessage("Track Loaded");
|
||||
//For green valley sheep test. See sheep_approach.as
|
||||
createTrigger("sheep_approach",-5.48,7.21,0.49,20.0);
|
||||
|
||||
}
|
10
data/scripts/greenvalley/update.as
Normal file
10
data/scripts/greenvalley/update.as
Normal file
@ -0,0 +1,10 @@
|
||||
void onUpdate()
|
||||
{
|
||||
|
||||
TrackObject @t_obj = getTrackObject("anim_sheep2.b3d");
|
||||
Mesh @sheepMesh = t_obj.getMesh();
|
||||
if (sheepMesh.getCurrentFrame()==2){
|
||||
sheepMesh.setLoop(8,48);
|
||||
sheepMesh.setCurrentFrame(9);
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@
|
||||
#include "tracks/track.hpp"
|
||||
#include "animations/three_d_animation.hpp"
|
||||
#include <iostream> //debug
|
||||
#include "input/input_manager.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
|
||||
namespace Scripting
|
||||
{
|
||||
@ -79,6 +81,16 @@ namespace Scripting
|
||||
{
|
||||
((TrackObjectPresentationMesh*)(memory))->getCurrentFrame();
|
||||
}
|
||||
void getKeyBinding(asIScriptGeneric *gen)
|
||||
{
|
||||
//currently just test if it works
|
||||
std::string *str = (std::string*)gen->GetArgAddress(0);
|
||||
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
|
||||
DeviceConfig* config = device->getConfiguration();
|
||||
irr::core::stringw skid = config->getBindingAsString(PA_DRIFT);
|
||||
std::string key = std::string(irr::core::stringc(skid).c_str());
|
||||
gen->SetReturnObject(&key);
|
||||
}
|
||||
void getTrackObject(asIScriptGeneric *gen)
|
||||
{
|
||||
std::string *str = (std::string*)gen->GetArgAddress(0);
|
||||
@ -99,6 +111,7 @@ namespace Scripting
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
int r;
|
||||
void getKeyBinding(asIScriptGeneric *gen)
|
||||
|
||||
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);
|
||||
@ -107,6 +120,9 @@ namespace Scripting
|
||||
r = engine->RegisterGlobalFunction("void disableTrigger(string &in)", asFUNCTION(disableTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void createTrigger(string &in,float x,float y,float z, float distance)",
|
||||
asFUNCTION(createTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void getKeyBinding(string &in)", asFUNCTION(displayMessage), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
|
||||
/*
|
||||
//Test singleton, and various calling conventions
|
||||
// Register the track object manager as a singleton. The script will access it through the global property
|
||||
|
Loading…
x
Reference in New Issue
Block a user