Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
staplegun
Sep 21, 2003

I've been running my head into a wall trying to figure out how I can pass a location with arguments to my script so I wouldn't have to keep on hardcoding params and reuploading the script for it to work.

Right now, my script works appropriately when I invoke it like this:

>sec_chk(o:#s.testloc.test)

that uses hardcoded variables in the script like so
code:
var o = args.o.call({arg1:"foo", arg2:"bar"})
Which isn't really flexible, since every time I switch to a new system I'll have to edit/reup the script. Ideally, I'd invoke my script, like this:

>sec_chk{o:#s.testloc.test{arg1:"foo", arg2:"bar"}}

But I don't think that's gonna be at all viable, probably because of some misconceptions about the function of scriptors, or at the very least just because I can't get the parser to stop freaking out over nested curly braces (which can't be escaped here). So, I started thinking of other ways that I could get a list of arguments the avoid the issue, mainly a loop that iterates through Object.keys(args) to just pull out the variables that I specify in the script and then just reassemble them. That hasn't worked out very well and I'm pretty sure I'm missing a simpler way to do all this, any ideas?

Adbot
ADBOT LOVES YOU

staplegun
Sep 21, 2003


Works perfectly, thanks for the help.

I don't think it will really help anyone, but here's the barely functioning script. It'll just run get_access_level and get_level on all the addresses in a given page. The hope is that it will quickly determine for you if there's any script that may have been planted in a bunch of innocuous-looking locations.

code:
function (context, args) {
	//invoke with sec_chk{o:testloc.test, fArgs:{arg1:"foo", arg2:"bar", arg3:"whatever"}}
	var o = args.o.call(args.fArgs)
	
	o = o.toString()
	var entry = o.split(",")
	var ret = ""
	
	for (var i=0;i<entry.length;i++) {
		ret += entry[i]+":\t\t\t"+#s.scripts.get_access_level({name:entry[i]})+"\t\t"+#s.scripts.get_level({name:entry[i]})+"\n"
	}
	return ret
}
I should probably work on making the output less ugly, but at least it's working and I can move on for now

staplegun
Sep 21, 2003

Arghonautz posted:

Nearly all my coding has been done in C# in unity, is their an equivalent to Debug.Log in this that i can use to get output part-way through a script, or post messages to the console as the script runs? Need to be able to see where things are going wrong!

I'm interested in this too, I've been using returning a tell to myself using
code:
ret=#s.chats.tell({to:"staplegun", msg:i})
as some basic feedback to figure out where my script is at but it really feels like a bad way of accomplishing it.

  • Locked thread