I've expanded upon my CLI Support Made Easy to build a fully functional file reader/writer for each script.
So assume you're launching a fighting script with the following CLI:
-script Fighter:scrub.ini.noob.ini.body.green-d'hide-body.legs.green-d'hide-chaps
That'll get converted to:
scrub.ini -to- OSBot/data/Fighter/scrub.ini
noob.ini -to- OSBot/data/Fighter/noob.ini
body:green d'hide body
legs:green d'hide chaps
Also, there'll be a OSBot/data/Fighter/default.ini created too. The default.ini file is where you specify parameters you want to share for every bot.
These files will be created automatically (if they're not already present) and loaded:
Anything that you put in the CLI that isn't a .ini file, those will be added (and override) all the key/values plucked from the files. This is similar to when you add inline CSS to HTML elements and how that potentially overrides the CSS loaded in from .css files.
Example script code:
@ScriptManifest(author = "", info = "", logo = "", name = "Fighter", version = 0)
public class CLITest extends Script {
NPC npc;
ScriptFile scriptFile;
Properties cli;
@Override
public void onStart() throws InterruptedException {
String parameters = getParameters();
try {
if (parameters != null && !parameters.isEmpty()) {
scriptFile = ScriptFile.compileAndCollateScriptIniFiles(getName(), getVersion(), getParameters());
cli = scriptFile.getProperties();
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public int onLoop() throws InterruptedException {
npc = npcs.closest(cli.getProperty("target", "Guard"));
return 250;
}
}
So let's say we had noob.ini and we wanted to target a tramp
The script will then use that
But let's say you didn't specify "target", probably because you misspelled it
The CLI parameter "target" isn't specified, so the script will look for a guard instead
Source code: