-
Notifications
You must be signed in to change notification settings - Fork 1
Advanced Examples
Leroy edited this page Feb 15, 2026
·
2 revisions
This example shows how to use Painter.vars to update a bar smoothly.
// Server Script
PlayerEvents.tick(event => {
const { player } = event;
// Set unique variable for this player
Painter.vars.set('hp_' + player.uuid, player.health);
Painter.sync(player);
});
PlayerEvents.loggedIn(event => {
Painter.paint(event.player, {
hp_bar: {
type: 'gradient',
x: 10, y: 10,
w: '$hp_' + event.player.uuid + ' * 5', // 5 pixels per HP point
h: 10,
colorL: '#FF0000',
colorR: '#FF5555',
draw: 'gui'
}
});
});Using math to scroll a texture.
Painter.paint(event.player, {
scrolling_bg: {
type: 'rectangle',
w: '$screenW', h: '$screenH',
texture: 'minecraft:textures/block/nether_portal.png',
u0: 'time * 0.1',
v0: 'time * 0.1',
u1: '(time * 0.1) + 1',
v1: '(time * 0.1) + 1'
}
});Using the hsv() function for a smooth rainbow cycle without any server-side tick logic.
Painter.paint(event.player, {
rainbow_msg: {
type: 'text',
text: 'RAINBOWS!',
x: 10, y: 50,
color: 'hsv(time * 0.2, 1, 1)', // Cycles through the full hue spectrum
draw: 'gui'
}
});Combining variables with text $var injection for a live-updating label.
// Server Script
PlayerEvents.tick(event => {
const { player } = event;
Painter.vars.set('mana_' + player.uuid, getMana(player));
Painter.sync(player);
});
PlayerEvents.loggedIn(event => {
const uid = event.player.uuid;
Painter.paint(event.player, {
mana_label: {
type: 'text',
text: 'Mana: $mana_' + uid,
x: 10, y: 30,
color: 'rgb(0.2, 0.6, 1)',
draw: 'gui'
},
mana_bar: {
type: 'rectangle',
x: 10, y: 42,
w: '$mana_' + uid + ' * 2',
h: 6,
color: 'rgb(0.2, 0.6, 1)',
draw: 'gui'
}
});
});