Primeros pasos con Scripting

Overte has a powerful scripting interface, in fact many of the features you might use whilst exploring Overte's worlds run on the scripting engine. The tablet you use to access apps, the community apps themselves, even the entities which make up much of the world; all of them are powered by scripts. You can modify many of these existing scripts, and even write your own scripts to reshape the Overte experience into your own.

Esta página asegura que sepas qué tipo de script usar y te ayuda a comenzar a ejecutar tus propios scripts simples.

Conceptos Básicos de JavaScript en Overte

Overte scripting runs on the V8 scripting engine, with support for both JavaScript and WebAssembly. To access the Overte API you will need to use JavaScript.

Nota

Tenga en cuenta que cualquier funcionalidad que se ejecute en páginas web (como cookies, almacenamientos locales o bases de datos) no funciona con entornos 3D como Overte. Por este motivo, no se pueden utilizar marcos de JavaScript como Angular, React, Express, jQuery, Vue, etc.

Es probable que interactúes principalmente con estas APIs de Overte:

API(s)

Descripción

Referencia de API: Entidades

Lets you manipulate the entities around you, as long as you have permissions to do so. This means you can add, remove, and edit entities. Everyone has access to get properties of an entity, which can be used to find Entities in range, direction, collision, or raytrace.

Referencia de API: MyAvatar

AvatarManager

Referencia de API: MyAvatar

Lets you get information on an Avatar, or manipulate your own client-only MyAvatar. The information here will always be the avatar information of the client running the script. AvatarList and AvatarManager are basically the same.

Referencia de API: Archivo

Allows you to connect callbacks from your client to a script, such as functionality that is dependent on time (Script.update, Script.setTime, Script.setInterval, etc), connect paths relatively to Assets (Script.relativePath), refer to other scripts (Script.include), or create events which occur when the script is turned off (Script.scriptEnding).

There are many other APIs available, which we encourage you to make use of as you become more comfortable scripting in Overte.

Tipos de Scripts

Tipo de script

Descripción

Scripts de interfaz

Los scripts de interfaz se ejecutan mientras tengas abierta la interfaz. Con estos scripts puedes realizar tareas de creación única o modificar la experiencia del usuario con nuevos menús, superposiciones, ajustes, complementos y extensiones.

Scripts de Asignación de Clientes

Los scripts de asignación de clientes coordinan las acciones entre entidades y avatares en tu dominio. Estos scripts continúan ejecutándose incluso cuando cierras la interfaz.

Scripts de Avatar

Los scripts de avatar se ejecutan en un avatar y pueden darle efectos únicos, como cabello que se mueve.

Script de Entidad de Cliente

Client entity scripts are scripts attached to entities that run locally in response to each user in a domain. With these scripts, you can customize what happens when a user encounters an entity by loading it into view.

Scripts de la Entidad del Servidor

Server entity scripts are scripts attached to entities that do not require a user to trigger. These scripts control entities so that their behavior is seen or heard by everyone in the domain.

Permisos de Scripting

Cada propietario de dominio tiene la capacidad de restringir los permisos de creación y edición. Si el script que deseas ejecutar agrega o edita entidades y no tienes permiso para hacerlo, no verás los objetos creados o modificados. Sin embargo, aún verás el script listado en la ventana de Scripts en Ejecución.

Ejecutando la ventana de Scripts

The Running Scripts window can be used to load, run and stop scripts from a URL or from a local file. Overte also provides a number of sample scripts for you to try out.

Para abrir la ventana Scripts en Ejecución, ve a Editar > Scripts en Ejecución o presiona Ctrl + J en tu teclado.

Scripts de ejemplo

Overte incluye una colección de scripts diseñados para mejorar tu experiencia de usuario y proporcionarte herramientas para desarrollar tu propio contenido. Te animamos a que consideres estos scripts como recurso para aprender a programar el tuyo.

Nota

Loading (or running) a script lets you test the functionality and see how it behaves. If you want to view the actual code, you will need to open the file in the text editor of your choice. In the 'Running Scripts' window, click 'Reveal Scripts Folder' and browse to the JavaScript file that you want to view.

Estos son los scripts que tenemos disponibles:

Directorio de Scripts

Descripción

android

Estos scripts fueron creados para ejecutarse en dispositivos Android.

communityScripts

These scripts were contributed by the community to improve the default Overte experience.

desarrollador

Estos scripts fueron creados para uso interno y depuración, pero están disponibles porque los desarrolladores avanzados pueden encontrarlos útiles al crear contenido. Estos scripts no son de "nivel inicial" y no se garantiza que funcionen ni que estén documentados.

módulos

Estos scripts crean herramientas externas que simplifican la programación en Overte. Por ejemplo, el módulo AppUI te ayuda a crear una aplicación para tableta, mientras que el módulo Request procesa solicitudes HTTP.

sistema

Estos scripts son fundamentales para la estabilidad y usabilidad de Overte. No se recomienda realizar cambios en estos scripts, ni es sencillo hacerlo, ya que podrías necesitar privilegios de 'administrador'.

tutoriales

Estos scripts ofrecen ejemplos de lo que puedes hacer con scripts en Overte. Algunos ejemplos incluyen: crear mariposas, hacer que tu avatar aplauda y agregar sonido ambiental a tu dominio.

Cargar y Ejecutar un Script

Para ejecutar un script:

  1. Abre la ventana 'Scripts en Ejecución'.

  2. For scripts hosted on the internet, click 'From URL'. Enter the URL of your script file and click 'OK'.

  3. Para scripts en tu computadora local, haz clic en 'Desde Disco'. Navega hasta tu archivo de script y haz clic en 'Abrir'.

  4. Para cargar un script de ejemplo, navega hasta el script en la parte inferior de la ventana 'Scripts en Ejecución'.

Nota

Any scripts you load from the 'Running Scripts' window will load automatically the next time you start Overte.

Recargar o Detener un Script

Para recargar o detener un script, abre la ventana 'Scripts en Ejecución' y haz una de las siguientes acciones:

  • Para recargar todos los scripts en ejecución, haz clic en el botón 'Recargar Todos' en la parte superior de la ventana.

  • Para recargar un script específico, haz clic en la flecha circular junto al script.

  • To stop all running scripts, click the 'Remove All' button at the top of the 'Running Scripts' window.

  • Para detener un script específico, haz clic en la 'X' junto al script.

Nota

By stopping a script, you are in effect removing that script from the running list. You will need to find and load that script again to have it appear in the list. If you Remove All scripts you can get the default scripts back by selecting Load Defaults

Consola de script

La Consola de Scripting te permite probar y ejecutar fragmentos cortos de script rápidamente en Overte para ver cómo funcionan. Para abrir la consola, ve al menú 'Desarrollador', luego a Scripting > Consola. Si el menú 'Desarrollador' no es visible, primero ve al menú 'Configuración' y haz clic en 'Menú Desarrollador'.

../_images/scripting-console.png

Ventana de Depuración

The Debug Window shows the output generated by your running scripts. This lets you watch the script(s) in action and make sure that it is running as you intended. If the script fails, the debugger can help you identify what went wrong, and point you to specific lines of code where the error occurred. To open the Debug Window, go to the 'Developer' menu, then Scripting > Script Log (HMD Friendly). If the Developer menu is not visible, first go to the 'Settings' menu and click 'Developer' Menu.

../_images/debug-window.png

Nota

To debug a server entity script you should instead use the Server Entity Script Log to view the output of your script.

Ver también