Skip to content

Commit

Permalink
Merge pull request #1215 from overte-org/fix/script_context_prop
Browse files Browse the repository at this point in the history
Fix missing properties in Script API
  • Loading branch information
ksuprynowicz authored Nov 1, 2024
2 parents 8b4207d + a9e46f8 commit 9d15fc4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
3 changes: 0 additions & 3 deletions libraries/script-engine/src/ScriptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ class EntityScriptDetails {
*/
class ScriptManager : public QObject, public EntitiesScriptEngineProvider, public std::enable_shared_from_this<ScriptManager> {
Q_OBJECT
Q_PROPERTY(QString context READ getContext)
Q_PROPERTY(QString type READ getTypeAsString)
Q_PROPERTY(QString fileName MEMBER _fileNameString CONSTANT)
public:
static const QString SCRIPT_EXCEPTION_FORMAT;
static const QString SCRIPT_BACKTRACE_SEP;
Expand Down
23 changes: 23 additions & 0 deletions libraries/script-engine/src/ScriptManagerScriptingInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class TestQObject : public QObject {

class ScriptManagerScriptingInterface : public QObject {
Q_OBJECT
Q_PROPERTY(QString context READ getContext)
Q_PROPERTY(QString type READ getTypeAsString)
Q_PROPERTY(QString fileName READ getAbsoluteFilename CONSTANT)
public:
ScriptManagerScriptingInterface(ScriptManager *parent);

Expand Down Expand Up @@ -96,6 +99,26 @@ class ScriptManagerScriptingInterface : public QObject {
*/
Q_INVOKABLE QString getContext() const { return _manager->getContext(); }

/*@jsdoc
* Gets the type of script that is running: Interface, avatar, client entity, server entity, or assignment client.
* @function Script.getTypeAsString
* @returns {string} The type of script that is running:
* <ul>
* <li><code>"client"</code>: An Interface script.</li>
* <li><code>"entity_client"</code>: A client entity script.</li>
* <li><code>"avatar"</code>: An avatar script.</li>
* <li><code>"entity_server"</code>: A server entity script.</li>
* <li><code>"agent"</code>: An assignment client script.</li>
* </ul>
*/
Q_INVOKABLE QString getTypeAsString() const { return _manager->getTypeAsString(); }

/*@jsdoc
* Gets the filename of the script file.
* @function Script.getAbsoluteFilename
* @returns {string} The filename of the script file.
*/
Q_INVOKABLE QString getAbsoluteFilename() const { return _manager->getAbsoluteFilename(); }

/*@jsdoc
* Checks whether the script is running as an Interface or avatar script.
Expand Down

0 comments on commit 9d15fc4

Please sign in to comment.