mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:10:49 +02:00
Update tutorial to work with fire
This commit is contained in:
parent
3fb3e5cf4c
commit
92670ed001
2 changed files with 73 additions and 38 deletions
|
@ -362,7 +362,7 @@ Step1BlockData = {
|
||||||
},
|
},
|
||||||
"shape": "Cube",
|
"shape": "Cube",
|
||||||
"type": "Box",
|
"type": "Box",
|
||||||
"userData": "{}",
|
"userData": JSON.stringify({ hifiHomeKey: { reset: true } }),
|
||||||
};
|
};
|
||||||
|
|
||||||
StepGunData = [
|
StepGunData = [
|
||||||
|
|
|
@ -264,11 +264,12 @@ stepRaiseAboveHead.prototype = {
|
||||||
|
|
||||||
this.checkIntervalID = null;
|
this.checkIntervalID = null;
|
||||||
function checkForHandsAboveHead() {
|
function checkForHandsAboveHead() {
|
||||||
print("Checking...");
|
print("Checking for hands above head...");
|
||||||
if (MyAvatar.getLeftPalmPosition().y > (MyAvatar.getHeadPosition().y + 0.1)) {
|
if (MyAvatar.getLeftPalmPosition().y > (MyAvatar.getHeadPosition().y + 0.1)) {
|
||||||
Script.clearInterval(this.checkIntervalID);
|
Script.clearInterval(this.checkIntervalID);
|
||||||
this.checkIntervalID = null;
|
this.checkIntervalID = null;
|
||||||
playSuccessSound();
|
playSuccessSound();
|
||||||
|
location = "/tutorial";
|
||||||
onFinish();
|
onFinish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,12 +314,16 @@ var stepNearGrab = function(name) {
|
||||||
}
|
}
|
||||||
stepNearGrab.prototype = {
|
stepNearGrab.prototype = {
|
||||||
start: function(onFinish) {
|
start: function(onFinish) {
|
||||||
|
this.finished = false;
|
||||||
|
this.onFinish = onFinish;
|
||||||
|
|
||||||
setControllerVisible("trigger", true);
|
setControllerVisible("trigger", true);
|
||||||
var tag = this.tag;
|
var tag = this.tag;
|
||||||
|
|
||||||
// Spawn content set
|
// Spawn content set
|
||||||
//spawnWithTag(Step1EntityData, null, tag);
|
//spawnWithTag(Step1EntityData, null, tag);
|
||||||
showEntitiesWithTag(this.tag, { visible: true });
|
showEntitiesWithTag(this.tag, { visible: true });
|
||||||
|
showEntitiesWithTag('bothGrab', { visible: true });
|
||||||
|
|
||||||
var basketColliderID = findEntity({ name: NEAR_BASKET_COLLIDER_NAME }, 10000);
|
var basketColliderID = findEntity({ name: NEAR_BASKET_COLLIDER_NAME }, 10000);
|
||||||
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
||||||
|
@ -344,30 +349,28 @@ stepNearGrab.prototype = {
|
||||||
//Vec3.distance(
|
//Vec3.distance(
|
||||||
//}
|
//}
|
||||||
|
|
||||||
function onHit() {
|
Messages.subscribe("Entity-Exploded");
|
||||||
onFinish();
|
Messages.messageReceived.connect(this.onMessage.bind(this));
|
||||||
}
|
|
||||||
|
|
||||||
// When block collides with basket start step 2
|
|
||||||
function checkCollides() {
|
|
||||||
var dist = Vec3.distance(basketPosition, Entities.getEntityProperties(this.boxID, 'position').position);
|
|
||||||
print(this.tag, "CHECKING...", dist);
|
|
||||||
if (dist < 0.15) {
|
|
||||||
Script.clearInterval(this.checkCollidesTimer);
|
|
||||||
this.checkCollidesTimer = null;
|
|
||||||
playSuccessSound();
|
|
||||||
Script.setTimeout(onHit.bind(this), 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.checkCollidesTimer = Script.setInterval(checkCollides.bind(this), 500);
|
|
||||||
|
|
||||||
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
||||||
},
|
},
|
||||||
cleanup: function() {
|
onMessage: function(channel, message, seneder) {
|
||||||
setControllerVisible("trigger", false);
|
if (this.finished) {
|
||||||
if (this.checkCollidesTimer) {
|
return;
|
||||||
Script.clearInterval(this.checkCollidesTimer);
|
|
||||||
}
|
}
|
||||||
|
if (channel == "Entity-Exploded") {
|
||||||
|
print("TUTORIAL: Got entity-exploded message");
|
||||||
|
var data = parseJSON(message);
|
||||||
|
if (data.entityID == this.boxID) {
|
||||||
|
this.finished = true;
|
||||||
|
this.onFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cleanup: function() {
|
||||||
|
print("cleaning up near grab");
|
||||||
|
this.finished = true;
|
||||||
|
setControllerVisible("trigger", false);
|
||||||
hideEntitiesWithTag(this.tag, { visible: false});
|
hideEntitiesWithTag(this.tag, { visible: false});
|
||||||
deleteEntitiesWithTag(this.tempTag);
|
deleteEntitiesWithTag(this.tempTag);
|
||||||
}
|
}
|
||||||
|
@ -387,6 +390,9 @@ var stepFarGrab = function(name) {
|
||||||
}
|
}
|
||||||
stepFarGrab.prototype = {
|
stepFarGrab.prototype = {
|
||||||
start: function(onFinish) {
|
start: function(onFinish) {
|
||||||
|
this.finished = false;
|
||||||
|
this.onFinish = onFinish;
|
||||||
|
|
||||||
setControllerVisible("trigger", true);
|
setControllerVisible("trigger", true);
|
||||||
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
||||||
farGrabEnabled: true,
|
farGrabEnabled: true,
|
||||||
|
@ -421,27 +427,42 @@ stepFarGrab.prototype = {
|
||||||
this.boxID = createBlock.bind(this)();
|
this.boxID = createBlock.bind(this)();
|
||||||
print("Created", this.boxID);
|
print("Created", this.boxID);
|
||||||
|
|
||||||
function onHit() {
|
Messages.subscribe("Entity-Exploded");
|
||||||
onFinish();
|
Messages.messageReceived.connect(this.onMessage.bind(this));
|
||||||
}
|
|
||||||
|
|
||||||
// When block collides with basket start step 2
|
// When block collides with basket start step 2
|
||||||
var checkCollidesTimer = null;
|
//var checkCollidesTimer = null;
|
||||||
function checkCollides() {
|
// function checkCollides() {
|
||||||
print("CHECKING...");
|
// print("CHECKING...");
|
||||||
if (Vec3.distance(basketPosition, Entities.getEntityProperties(this.boxID, 'position').position) < 0.2) {
|
// if (Vec3.distance(basketPosition, Entities.getEntityProperties(this.boxID, 'position').position) < 0.2) {
|
||||||
Script.clearInterval(checkCollidesTimer);
|
// Script.clearInterval(checkCollidesTimer);
|
||||||
playSuccessSound();
|
// playSuccessSound();
|
||||||
Script.setTimeout(onHit.bind(this), 1000);
|
// Script.setTimeout(onHit.bind(this), 1000);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
checkCollidesTimer = Script.setInterval(checkCollides.bind(this), 500);
|
// checkCollidesTimer = Script.setInterval(checkCollides.bind(this), 500);
|
||||||
|
|
||||||
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
||||||
},
|
},
|
||||||
|
onMessage: function(channel, message, seneder) {
|
||||||
|
if (this.finished) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (channel == "Entity-Exploded") {
|
||||||
|
print("TUTORIAL: Got entity-exploded message");
|
||||||
|
var data = parseJSON(message);
|
||||||
|
if (data.entityID == this.boxID) {
|
||||||
|
this.finished = true;
|
||||||
|
this.onFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
cleanup: function() {
|
cleanup: function() {
|
||||||
|
//Messages.messageReceived.disconnect(this.onMessage.bind(this));
|
||||||
|
this.finished = true;
|
||||||
setControllerVisible("trigger", false);
|
setControllerVisible("trigger", false);
|
||||||
hideEntitiesWithTag(this.tag, { visible: false});
|
hideEntitiesWithTag(this.tag, { visible: false});
|
||||||
|
hideEntitiesWithTag('bothGrab', { visible: false});
|
||||||
deleteEntitiesWithTag(this.tempTag);
|
deleteEntitiesWithTag(this.tempTag);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -524,7 +545,7 @@ stepEquip.prototype = {
|
||||||
|
|
||||||
// When block collides with basket start step 2
|
// When block collides with basket start step 2
|
||||||
function checkCollides() {
|
function checkCollides() {
|
||||||
print("CHECKING FOR PING PONG...");
|
//print("CHECKING FOR PING PONG...");
|
||||||
var ammoIDs = findEntities({ name: GUN_AMMO_NAME }, 15);
|
var ammoIDs = findEntities({ name: GUN_AMMO_NAME }, 15);
|
||||||
for (var i = 0; i < ammoIDs.length; ++i) {
|
for (var i = 0; i < ammoIDs.length; ++i) {
|
||||||
if (Vec3.distance(basketPosition, Entities.getEntityProperties(ammoIDs[i], 'position').position) < 0.25) {
|
if (Vec3.distance(basketPosition, Entities.getEntityProperties(ammoIDs[i], 'position').position) < 0.25) {
|
||||||
|
@ -590,6 +611,16 @@ stepEquip.prototype = {
|
||||||
var stepTurnAround = function(name) {
|
var stepTurnAround = function(name) {
|
||||||
this.tag = name;
|
this.tag = name;
|
||||||
this.tempTag = name + "-temporary";
|
this.tempTag = name + "-temporary";
|
||||||
|
|
||||||
|
|
||||||
|
//var name = "mapping-name";
|
||||||
|
//var mapping = Controller.newMapping(name);
|
||||||
|
//mapping.from([Controller.Actions.StepYaw]).to(function() {
|
||||||
|
// print("STEPYAW");
|
||||||
|
//});
|
||||||
|
//Script.scriptEnding.connect(function() {
|
||||||
|
// Controller.disableMapping(name);
|
||||||
|
//});
|
||||||
}
|
}
|
||||||
stepTurnAround.prototype = {
|
stepTurnAround.prototype = {
|
||||||
start: function(onFinish) {
|
start: function(onFinish) {
|
||||||
|
@ -730,9 +761,13 @@ function showEntitiesWithTag(tag) {
|
||||||
editEntitiesWithTag(tag, function(entityID) {
|
editEntitiesWithTag(tag, function(entityID) {
|
||||||
var userData = Entities.getEntityProperties(entityID, "userData").userData;
|
var userData = Entities.getEntityProperties(entityID, "userData").userData;
|
||||||
var data = parseJSON(userData);
|
var data = parseJSON(userData);
|
||||||
|
var collisionless = data.visible === false ? true : false;
|
||||||
|
if (data.collidable !== undefined) {
|
||||||
|
collisionless = data.collidable === true ? false : true;
|
||||||
|
}
|
||||||
var newProperties = {
|
var newProperties = {
|
||||||
visible: data.visible == false ? false : true,
|
visible: data.visible == false ? false : true,
|
||||||
collisionless: data.visible == false ? true : false ,
|
collisionless: collisionless,
|
||||||
//collisionless: data.collisionless == true ? true : false,
|
//collisionless: data.collisionless == true ? true : false,
|
||||||
};
|
};
|
||||||
Entities.editEntity(entityID, newProperties);
|
Entities.editEntity(entityID, newProperties);
|
||||||
|
@ -769,7 +804,7 @@ function startTutorial() {
|
||||||
new stepTeleport("teleport"),
|
new stepTeleport("teleport"),
|
||||||
new stepFinish("finish"),
|
new stepFinish("finish"),
|
||||||
]
|
]
|
||||||
location = "/tutorial";
|
location = "/tutorial_begin";
|
||||||
startNextStep();
|
startNextStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue