Skip to content

Update, Click and Init scripts

Bobuxstation edited this page Mar 20, 2023 · 4 revisions

Welcome to the update script documentation!

Update script are scripts you can write for each mesh that runs once every rendered frame. Update scripts are useful for creating looped animations or to update leaderboards.

Welcome to the click script documentation!

Click script are scripts you can write for each mesh that runs when the mesh is clicked in the HorangHill client. Click scripts are useful for creating coins, buttons and more.

Interacting with the mesh

Removing the mesh from the scene

The current mesh is declared as mesh and the scene is declared as scene to remove the mesh you can do the following:

scene.remove(mesh)

Welcome to the init script documentation!

Init script are scripts you can write for each mesh that runs when the mesh is loaded in the HorangHill client. Unlike the others, init script only runs once when it is loaded in the scene.

Changing the scene's look

Changing the Skybox

To change the background skybox in HorangHill, You can make a part that have a size of (0, 0, 0 aka invisible) then in the init script we can add the following:

scene.background = new THREE.Color(0x005A9C);

The Client UI

Spawning a button in the sidebar

You can spawn HTML elements in the client sidebar, this can be useful for showing the player stats or can act as clickable buttons here is an example:

var button = document.createElement('a')
button.innerText = "Hello, Horanger!"
document.getElementById('topsidebar').appendChild(button)

Toggling sidebar with ESC key

This is an example on how to toggle the sidebar when the ESC key is pressed.

document.addEventListener('keydown', function(event) {
    if(event.keyCode == 27) {
        toggleSideBar()
    }
});