Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Vivid Interface Designer Wiki › Guides › Use JavaScript to Calculate and Display Custom Values

Use JavaScript to Calculate and Display Custom Values

Enable JavaScript Mode

The mod supports JavaScript for complex calculations and custom logic. In your configuration, enable JavaScript scripting mode for your HUD elements.

Writing a Simple Formula

1. Create a new script block in your config

2. Write JavaScript that returns a number or string

3. Example: calculate your hunger saturation percentage, distance to spawn, or time played

4. Reference game variables provided by the mod (such as player position, health, or dimension data)

Practical Example

You might write a script that displays your approximate coordinates rounded to whole numbers, or calculates how many more hits you can take before dying based on current health. The mod exposes player and world data as JavaScript objects you can access.

Debugging Your Script

If your custom value doesn't appear, check your browser console or mod logs for JavaScript errors. Start with simple math operations before moving to complex logic. Test incrementally—write one line, verify it works, then add more.