master
Raw Download raw file
 1function (context, args) {
 2	// if you're running out of characters, you COULD delete this if block, to save on character count. You lose a help message, but it drops the script to below 500 (counted) characters.
 3	if (!args || !args.target) {
 4		return {
 5			ok: false,
 6			msg: "Call me with {target:#s.some.script} as the arguments (for 'some.script' that exists, such as accts.balance)"
 7		}
 8	}
 9
10	var target = args.target;
11	// scripts.get_level returns a number inside scripts, or a string like 'FULLSEC' or 'MIDSEC' on command line
12	var sec_level = #s.scripts.get_level({name:target.name});
13	
14	var l = #s.scripts.lib();
15	
16	// is it less than FULLSEC? if so, warn the user
17	if (sec_level < 4 && !args.override) {
18		var sec_level_name = l.security_level_names[sec_level];
19		return {
20			ok: false,
21			msg: "The script you have passed is " + sec_level_name + ". Are you sure you want to continue? If so, pass override:true"
22		};
23	}
24	
25	var result = target.call(args.passthru);
26	
27	return {
28		ok: true,
29		msg: "Target called. See 'debug' below to inspect the output.",
30		debug: result,
31	}
32}