mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 18:55:37 +02:00
Merge pull request #1810 from birarda/master
scripting nomenclature changes
This commit is contained in:
commit
579c601ff7
23 changed files with 42 additions and 37 deletions
assignment-client/src
examples
clap.jscollidingParticles.jscontrollerExample.jscount.jsdrumStick.jseditParticleExample.jsfindParticleExample.jsfountain.jsgameoflife.jsgun.jslookWithMouse.jsmovingVoxel.jspaintGun.jsparticleBird.jsparticleModelExample.jsplaySound.jsrideAlongWithAParticleExample.jstoyball.jsvoxelBird.js
libraries/script-engine/src
|
@ -101,6 +101,9 @@ void Agent::run() {
|
|||
|
||||
// give this AvatarData object to the script engine
|
||||
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");
|
||||
|
||||
// register ourselves to the script engine
|
||||
_scriptEngine.registerGlobalObject("Agent", this);
|
||||
|
||||
_scriptEngine.setScriptContents(scriptContents);
|
||||
_scriptEngine.run();
|
||||
|
|
|
@ -21,9 +21,14 @@
|
|||
|
||||
class Agent : public ThreadedAssignment {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool isAvatar READ isAvatar WRITE setIsAvatar)
|
||||
public:
|
||||
Agent(const QByteArray& packet);
|
||||
|
||||
void setIsAvatar(bool isAvatar) { _scriptEngine.setIsAvatar(isAvatar); }
|
||||
bool isAvatar() const { return _scriptEngine.isAvatar(); }
|
||||
|
||||
public slots:
|
||||
void run();
|
||||
|
||||
|
|
|
@ -62,4 +62,4 @@ function maybePlaySound() {
|
|||
}
|
||||
|
||||
// Connect a call back that happens every frame
|
||||
Agent.willSendVisualDataCallback.connect(maybePlaySound);
|
||||
Script.willSendVisualDataCallback.connect(maybePlaySound);
|
|
@ -132,7 +132,7 @@ function draw() {
|
|||
print(scriptB);
|
||||
numberParticlesAdded++;
|
||||
} else {
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
print("Particles Stats: " + Particles.getLifetimeInSeconds() + " seconds," +
|
||||
|
@ -150,5 +150,5 @@ function draw() {
|
|||
// register the call back so it fires before each data send
|
||||
print("here...\n");
|
||||
Particles.setPacketsPerSecond(40000);
|
||||
Agent.willSendVisualDataCallback.connect(draw);
|
||||
Script.willSendVisualDataCallback.connect(draw);
|
||||
print("and here...\n");
|
||||
|
|
|
@ -82,7 +82,7 @@ function touchEndEvent(event) {
|
|||
}
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(checkController);
|
||||
Script.willSendVisualDataCallback.connect(checkController);
|
||||
|
||||
// Map keyPress and mouse move events to our callbacks
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
|
@ -199,4 +199,4 @@ function scriptEnding() {
|
|||
Controller.releaseTouchEvents();
|
||||
}
|
||||
|
||||
Agent.scriptEnding.connect(scriptEnding);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
|
@ -20,7 +20,7 @@ function scriptEnding() {
|
|||
}
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(displayCount);
|
||||
Script.willSendVisualDataCallback.connect(displayCount);
|
||||
|
||||
// register our scriptEnding callback
|
||||
Agent.scriptEnding.connect(scriptEnding);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
|
@ -69,4 +69,4 @@ function checkSticks() {
|
|||
}
|
||||
|
||||
// Connect a call back that happens every frame
|
||||
Agent.willSendVisualDataCallback.connect(checkSticks);
|
||||
Script.willSendVisualDataCallback.connect(checkSticks);
|
|
@ -44,7 +44,6 @@ var particleID = Particles.addParticle(originalProperties);
|
|||
|
||||
function moveParticle() {
|
||||
if (count >= moveUntil) {
|
||||
//Agent.stop();
|
||||
|
||||
// delete it...
|
||||
if (count == moveUntil) {
|
||||
|
@ -54,8 +53,8 @@ function moveParticle() {
|
|||
|
||||
// stop it...
|
||||
if (count >= stopAfter) {
|
||||
print("calling Agent.stop()");
|
||||
Agent.stop();
|
||||
print("calling Script.stop()");
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
count++;
|
||||
|
@ -86,5 +85,5 @@ function moveParticle() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(moveParticle);
|
||||
Script.willSendVisualDataCallback.connect(moveParticle);
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ function findParticles() {
|
|||
// run for a while, then clean up
|
||||
// stop it...
|
||||
if (iteration >= 100) {
|
||||
print("calling Agent.stop()");
|
||||
Agent.stop();
|
||||
print("calling Script.stop()");
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
print("--------------------------");
|
||||
|
@ -122,7 +122,7 @@ function findParticles() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(findParticles);
|
||||
Script.willSendVisualDataCallback.connect(findParticles);
|
||||
|
||||
// register our scriptEnding callback
|
||||
Agent.scriptEnding.connect(scriptEnding);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
|
@ -60,8 +60,8 @@ function makeFountain() {
|
|||
totalParticles++;
|
||||
}
|
||||
if (totalParticles > 100) {
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
}
|
||||
}
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(makeFountain);
|
||||
Script.willSendVisualDataCallback.connect(makeFountain);
|
|
@ -128,6 +128,6 @@ print("step()...");
|
|||
}
|
||||
|
||||
print("here");
|
||||
Agent.willSendVisualDataCallback.connect(step);
|
||||
Script.willSendVisualDataCallback.connect(step);
|
||||
Voxels.setPacketsPerSecond(200);
|
||||
print("now here");
|
||||
|
|
|
@ -99,4 +99,4 @@ function checkController() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(checkController);
|
||||
Script.willSendVisualDataCallback.connect(checkController);
|
||||
|
|
|
@ -70,5 +70,5 @@ MyAvatar.bodyPitch = 0;
|
|||
MyAvatar.bodyRoll = 0;
|
||||
|
||||
// would be nice to change to update
|
||||
Agent.willSendVisualDataCallback.connect(update);
|
||||
Agent.scriptEnding.connect(scriptEnding);
|
||||
Script.willSendVisualDataCallback.connect(update);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
|
|
@ -41,4 +41,4 @@ function moveVoxel() {
|
|||
|
||||
Voxels.setPacketsPerSecond(300);
|
||||
// Connect a call back that happens every frame
|
||||
Agent.willSendVisualDataCallback.connect(moveVoxel);
|
||||
Script.willSendVisualDataCallback.connect(moveVoxel);
|
|
@ -93,4 +93,4 @@ function checkController() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(checkController);
|
||||
Script.willSendVisualDataCallback.connect(checkController);
|
||||
|
|
|
@ -95,7 +95,7 @@ function moveBird() {
|
|||
var nowTimeInSeconds = new Date().getTime() / 1000;
|
||||
if ((nowTimeInSeconds - startTimeInSeconds) >= birdLifetime) {
|
||||
print("our bird is dying, stop our script");
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -171,4 +171,4 @@ function moveBird() {
|
|||
}
|
||||
}
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(moveBird);
|
||||
Script.willSendVisualDataCallback.connect(moveBird);
|
||||
|
|
|
@ -37,8 +37,8 @@ var ballParticleID = Particles.addParticle(ballProperties);
|
|||
function endAfterAWhile() {
|
||||
// stop it...
|
||||
if (count >= stopAfter) {
|
||||
print("calling Agent.stop()");
|
||||
Agent.stop();
|
||||
print("calling Script.stop()");
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
print("count =" + count);
|
||||
|
@ -47,5 +47,5 @@ function endAfterAWhile() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(endAfterAWhile);
|
||||
Script.willSendVisualDataCallback.connect(endAfterAWhile);
|
||||
|
||||
|
|
|
@ -17,4 +17,4 @@ function maybePlaySound() {
|
|||
}
|
||||
|
||||
// Connect a call back that happens every frame
|
||||
Agent.willSendVisualDataCallback.connect(maybePlaySound);
|
||||
Script.willSendVisualDataCallback.connect(maybePlaySound);
|
|
@ -37,7 +37,7 @@ function rideWithParticle() {
|
|||
y: propertiesA.position.y + 2,
|
||||
z: propertiesA.position.z };
|
||||
} else {
|
||||
Agent.stop();
|
||||
Script.stop();
|
||||
}
|
||||
|
||||
iteration++;
|
||||
|
@ -46,5 +46,5 @@ function rideWithParticle() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(rideWithParticle);
|
||||
Script.willSendVisualDataCallback.connect(rideWithParticle);
|
||||
|
||||
|
|
|
@ -226,4 +226,4 @@ function checkController() {
|
|||
|
||||
|
||||
// register the call back so it fires before each data send
|
||||
Agent.willSendVisualDataCallback.connect(checkController);
|
||||
Script.willSendVisualDataCallback.connect(checkController);
|
||||
|
|
|
@ -130,4 +130,4 @@ function moveBird() {
|
|||
|
||||
Voxels.setPacketsPerSecond(10000);
|
||||
// Connect a call back that happens every frame
|
||||
Agent.willSendVisualDataCallback.connect(moveBird);
|
||||
Script.willSendVisualDataCallback.connect(moveBird);
|
|
@ -133,7 +133,7 @@ void ScriptEngine::init() {
|
|||
QScriptValue injectionOptionValue = _engine.scriptValueFromQMetaObject<AudioInjectorOptions>();
|
||||
_engine.globalObject().setProperty("AudioInjectionOptions", injectionOptionValue);
|
||||
|
||||
registerGlobalObject("Agent", this);
|
||||
registerGlobalObject("Script", this);
|
||||
registerGlobalObject("Audio", &_audioScriptingInterface);
|
||||
registerGlobalObject("Controller", _controllerScriptingInterface);
|
||||
registerGlobalObject("Data", &_dataServerScriptingInterface);
|
||||
|
|
|
@ -31,8 +31,6 @@ const QString NO_SCRIPT("");
|
|||
|
||||
class ScriptEngine : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool isAvatar READ isAvatar WRITE setIsAvatar)
|
||||
public:
|
||||
ScriptEngine(const QString& scriptContents = NO_SCRIPT, bool wantMenuItems = false,
|
||||
const QString& scriptMenuName = QString(""), AbstractMenuInterface* menu = NULL,
|
||||
|
|
Loading…
Reference in a new issue