mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
fix canRez logic in tribble script: only need canRezTemp, and fail hard rather than retry
This commit is contained in:
parent
4c5bf3119e
commit
76d9d4c635
1 changed files with 40 additions and 36 deletions
|
@ -54,42 +54,46 @@ function randomVector(range) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.setInterval(function () {
|
if (!Entities.canRezTmp()) {
|
||||||
if (!Entities.serversExist() || !Entities.canRez()) {
|
Window.alert("Cannot create temp objects here.");
|
||||||
return;
|
Script.stop();
|
||||||
}
|
} else {
|
||||||
if (totalCreated >= NUMBER_TO_CREATE) {
|
Script.setInterval(function () {
|
||||||
print("Created " + totalCreated + " tribbles.");
|
if (!Entities.serversExist()) {
|
||||||
Script.stop();
|
return;
|
||||||
}
|
}
|
||||||
|
if (totalCreated >= NUMBER_TO_CREATE) {
|
||||||
|
print("Created " + totalCreated + " tribbles.");
|
||||||
|
Script.stop();
|
||||||
|
}
|
||||||
|
|
||||||
var i, numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
|
var i, numToCreate = RATE_PER_SECOND * (SCRIPT_INTERVAL / 1000.0);
|
||||||
var parameters = JSON.stringify({
|
var parameters = JSON.stringify({
|
||||||
moveTimeout: MOVE_TIMEOUT,
|
moveTimeout: MOVE_TIMEOUT,
|
||||||
moveRate: MOVE_RATE,
|
moveRate: MOVE_RATE,
|
||||||
editTimeout: EDIT_TIMEOUT,
|
editTimeout: EDIT_TIMEOUT,
|
||||||
editRate: EDIT_RATE,
|
editRate: EDIT_RATE,
|
||||||
debug: {flow: false, send: false, receive: false}
|
debug: {flow: false, send: false, receive: false}
|
||||||
});
|
|
||||||
for (i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) {
|
|
||||||
Entities.addEntity({
|
|
||||||
userData: parameters,
|
|
||||||
type: TYPE,
|
|
||||||
name: "tribble-" + totalCreated,
|
|
||||||
position: Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })),
|
|
||||||
dimensions: {x: SIZE, y: SIZE, z: SIZE},
|
|
||||||
color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
|
|
||||||
velocity: VELOCITY,
|
|
||||||
angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
|
|
||||||
damping: DAMPING,
|
|
||||||
angularDamping: ANGULAR_DAMPING,
|
|
||||||
gravity: GRAVITY,
|
|
||||||
collisionsWillMove: true,
|
|
||||||
lifetime: LIFETIME,
|
|
||||||
script: Script.resolvePath("tribbleEntity.js")
|
|
||||||
});
|
});
|
||||||
|
for (i = 0; (i < numToCreate) && (totalCreated < NUMBER_TO_CREATE); i++) {
|
||||||
|
Entities.addEntity({
|
||||||
|
userData: parameters,
|
||||||
|
type: TYPE,
|
||||||
|
name: "tribble-" + totalCreated,
|
||||||
|
position: Vec3.sum(center, randomVector({ x: RANGE, y: RANGE, z: RANGE })),
|
||||||
|
dimensions: {x: SIZE, y: SIZE, z: SIZE},
|
||||||
|
color: {red: Math.random() * 255, green: Math.random() * 255, blue: Math.random() * 255},
|
||||||
|
velocity: VELOCITY,
|
||||||
|
angularVelocity: Vec3.multiply(Math.random(), ANGULAR_VELOCITY),
|
||||||
|
damping: DAMPING,
|
||||||
|
angularDamping: ANGULAR_DAMPING,
|
||||||
|
gravity: GRAVITY,
|
||||||
|
collisionsWillMove: true,
|
||||||
|
lifetime: LIFETIME,
|
||||||
|
script: Script.resolvePath("tribbleEntity.js")
|
||||||
|
});
|
||||||
|
|
||||||
totalCreated++;
|
totalCreated++;
|
||||||
}
|
}
|
||||||
}, SCRIPT_INTERVAL);
|
}, SCRIPT_INTERVAL);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue