History

Add JSDoc for Entity preload and unload signals

David Rowe committed 8 years ago

Commit a1fc1c41 parent 9b80c501 file · +33 −0Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+33−0
@@ -2161,6 +2161,32 @@ void ScriptEngine::loadEntityScript(const EntityItemID& entityID, const QString& · 2160 unmodified lines
21612161 }, forceRedownload);
21622162 }
21632163
2164+/**jsdoc
2165+ * Triggered when the script starts for a user.
2166+ * <p>Note: Can only be connected to via <code>this.preload = function (...) { ... }</code> in the entity script.</p>
2167+ * <table><tr><th>Available in:</th><td>Client Entity Scripts</td><td>Server Entity Scripts</td></tr></table>
2168+ * @function Entities.preload
2169+ * @param {Uuid} entityID - The ID of the entity that the script is running in.
2170+ * @returns {Signal}
2171+ * @example <caption>Get the ID of the entity that a client entity script is running in.</caption>
2172+ * var entityScript = (function () {
2173+ * this.entityID = Uuid.NULL;
2174+ *
2175+ * this.preload = function (entityID) {
2176+ * this.entityID = entityID;
2177+ * print("Entity ID: " + this.entityID);
2178+ * };
2179+ * );
2180+ *
2181+ * var entityID = Entities.addEntity({
2182+ * type: "Box",
2183+ * position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -5 })),
2184+ * dimensions: { x: 0.5, y: 0.5, z: 0.5 },
2185+ * color: { red: 255, green: 0, blue: 0 },
2186+ * script: "(" + entityScript + ")", // Could host the script on a Web server instead.
2187+ * lifetime: 300 // Delete after 5 minutes.
2188+ * });
2189+ */
21642190 // since all of these operations can be asynch we will always do the actual work in the response handler
21652191 // for the download
21662192 void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, const QString& scriptOrURL, const QString& contents, bool isURL, bool success , const QString& status) {
@@ -2345,6 +2371,13 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 178 unmodified lines
23452371 processDeferredEntityLoads(entityScript, entityID);
23462372 }
23472373
2374+/**jsdoc
2375+ * Triggered when the script terminates for a user.
2376+ * <p>Note: Can only be connected to via <code>this.unoad = function () { ... }</code> in the entity script.</p>
2377+ * <table><tr><th>Available in:</th><td>Client Entity Scripts</td><td>Server Entity Scripts</td></tr></table>
2378+ * @function Entities.unload
2379+ * @returns {Signal}
2380+ */
23482381 void ScriptEngine::unloadEntityScript(const EntityItemID& entityID, bool shouldRemoveFromMap) {
23492382 if (QThread::currentThread() != thread()) {
23502383 #ifdef THREAD_DEBUGGING