Indicatore di Stato Sanguinante e Morto
(Contribuito da Ken Bauer)
Questo script aggiunge automaticamente il marcatore Rosso per rappresentare lo stato "sanguinante" per ogni token che scende sotto la metà della sua salute, e il marcatore "morto" per chi scende a 0 o meno. Si presume che la salute sia memorizzata nella Barra 1.
on("change:graphic", function(obj) {
if(obj.get("bar1_max") === "") return;
if(obj.get("bar1_value") <= obj.get("bar1_max") / 2) {
obj.set({
status_redmarker: true
});
}
else{
obj.set({
status_redmarker: false
})
}
if(obj.get("bar1_value") <= 0) {
obj.set({
status_dead: true
});
}
else {
obj.set({
status_dead: false
});
}
});
L'oscurità si avvicina...
Questo script riduce il raggio di luce di un token del 10% ogni volta che il token si muove. Ideale per simulare la "finita carica delle lampade" o situazioni ad alto stress simili.
on("change:token", function(obj, prev) {
//Fallo solo se ci siamo effettivamente spostati.
if(obj.get("left") == prev["left"] && obj.get("top") == prev["top"]) return;
obj.set({
light_radius: Math.floor(obj.get("light_radius") * 0.90)
});
});
sendChat as a Player or Character
(Contributed by Brian Shields)
This is a few lines you can use in a chat:message event script to ensure you're sending a message with sendChat accurately as either a Player or a Character, depending on who triggered the event.
on("chat:message", function(msg) {
var message = '';
// Determine the contents of `message'
var characters = findObjs({_type: 'character'});
var speaking;
characters.forEach(function(chr) { if(chr.get('name') == msg.who) speaking = chr; });
if(speaking) sendChat('character|'+speaking.id, message);
else sendChat('player|'+msg.playerid, message);
});