Files

64 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# potion_rain.js — q() (satır 160)
[← potion_rain.js](index.md) · [← Master](../../wiki.md)
Parça 1/11 · [sonraki](q-2.md)
```javascript
function q(s) {
return '"' + String(s).replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
}
function clampNum(name, v) {
var L = LIMITS[name];
v = Number(v);
if (!isFinite(v)) v = L.def;
if (v < L.min) v = L.min;
if (v > L.max) v = L.max;
return L.min < 1 ? Math.round(v * 100) / 100 : Math.round(v);
}
function getNum(st, name) {
return st.has(K_NUM + name) ? clampNum(name, st.getNumber(K_NUM + name)) : LIMITS[name].def;
}
function getFlag(st, key, def) {
return st.has(key) ? st.getNumber(key) === 1 : def;
}
function getIndex(st, key, len) {
var i = Math.floor(st.getNumber(key));
return (i >= 0 && i < len) ? i : 0;
}
function readConfig(p) {
var st = p.getStates();
var cfg = {
kind: KINDS[getIndex(st, K_KIND, KINDS.length)],
pot: getIndex(st, K_POT, POTIONS.length),
mode: getFlag(st, K_MODE, false) ? 1 : 0,
shape: getFlag(st, K_SHAPE, false) ? 1 : 0,
timed: getFlag(st, K_TIMED, false),
spin: getFlag(st, K_SPIN, true),
ipot: getFlag(st, K_IPOT, false),
skin: trim(st.getString(K_SKIN)),
morph: trim(st.getString(K_MORPH))
};
for (var name in LIMITS) cfg[name] = getNum(st, name);
return cfg;
}
// Tur yere degince iksir patlatir mi
function carriesPotion(k, cfg) {
if (k.type === "vanilla") return k.key === "potion";
return k.type === "skin" || k.type === "custom" || cfg.ipot;
}
function areaText(cfg) {
return cfg.shape === 1 ? (cfg.width + "x" + cfg.depth + " kare") : ("r" + cfg.radius + " daire");
}
// =====================================================================
// MORPH / NBT URETIMI
```