Skip to content

Instantly share code, notes, and snippets.

@lostkagamine
Last active January 28, 2018 19:41
Show Gist options
  • Save lostkagamine/3eee4d983587ca2ac16d5ba04e4db1ee to your computer and use it in GitHub Desktop.
Save lostkagamine/3eee4d983587ca2ac16d5ba04e4db1ee to your computer and use it in GitHub Desktop.
System Viewer for Hackmud. Also doubles as junk culler.
function(context, args)
{
var args = args || {};
var cull = args.mode == 'cull';
var upgs = #hs.sys.upgrades(); // get all upgrades
var crarities = args.rarities || [0, 1];
var cexclude = args.exclude_type || ['tool', 'script_space'];
var showloaded = !!args.show_loaded;
var ctiers = args.tiers || [1];
var rarities = ['n00b', 'kiddie', 'h4x0r', 'h4rdc0re', '|_|b3|2', '31337']
var showk3ys = !!args.k3ys || cull;
if (!cull) {
var ctiers = args.tiers || [1, 2, 3];
var cexclude = args.exclude_type || [];
var crarities = args.rarities || [0, 1, 2, 3, 4, 5]
}
function include(array, thing) { return array.indexOf(thing) != -1; }
var things = [];
var str = '';
var help = `
\`LSysView\` by \`Nry00001\`
This is a script that lets you view all your upgrades, kinda like sys.upgrades, but in a prettier manner.
It is also an automatic culler for T1/low-rarity "junk" upgrades.
To activate cull mode, pass {mode: "cull"} to the script.
\`HCustomisation:\`
To show loaded upgrades, pass {show_loaded: true} to the script.
The rarities option allows you to specify rarities to view/cull, in numerical values.
For example, {rarities: [0, 1]} (the default in cull mode) would only view/cull rarities \`0n00b\` and \`1kiddie\`.
The tiers option allows you to specify tiers to view/cull, in numerical values.
For example, {tiers: [1]} (the default in cull mode) would only view/cull tier 1 upgrades.
The exclude_type option allows you to specify types to exclude from viewing/culling, as strings.
For example, {exclude_type: ["script"]} would exclude scripts from being culled/viewed.
The k3ys option allows you to cull k3ys (why would you want to??). k3ys are normally visible in View Mode, but won't be culled unless you say so.
\`HDefaults:\`
View Mode: Everything! View mode will view all your upgrades.
Cull Mode: No k3ys, only rarities n00b and kiddie, only tier 1.
`;
if (args == {} || args.help) {
return help;
}
function process_upgrades(upgs) {
let m = [];
for (let i=0; i<upgs.length;i++) {
let upg = upgs[i]
if (!showloaded) { if (upg.loaded){ continue; } }
if (!include(ctiers, upg.tier)) continue;
if (!include(crarities, upg.rarity)) continue;
if (include(cexclude, upg.type)) continue;
if (!showk3ys) { if (upg.k3y) continue; } //no culling k3ys!!!
m.push(upg)
}
return m
}
upgs = process_upgrades(upgs);
for (let i=0; i<upgs.length;i++) {
let upg = upgs[i]
str += `[\`L${upg.i}\`] \`${upg.rarity}${upg.name}\` (T\`${upg.tier-1}${upg.tier}\` / \`${upg.rarity}${rarities[upg.rarity]}\`)${upg.loaded?' `D[LOADED]`':''}\n`
things.push(upg);
}
if (cull) { #ls.sys.cull({i: things.map(i => i.i) /* lul i.i */, confirm:true}); /* BAD */ };
return `${cull ? `${str}\nCulled ${things.length} upgrades.` : `${str}\n\`D- VIEW MODE -\` To learn more about cull mode, pass {help:true}.`}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment