How to use the Startup LoliCode feature

With version 0.2.5, the Startup LoliCode feature was introduced.

It allows you to execute some code when the job starts, and set some global variables that all the bots will be able to access when the parallelized workload actually starts.

In order to use it, simply toggle the Startup LoliCode box and write some LoliCode in it, that will set a global variable.

For example, in order to grab a session cookie at the start and use it for all your jobs, you could write the following

BLOCK:HttpRequest
  url = "https://httpbin.org/cookies/set/test/123"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

globals.Cookie = data.COOKIES["test"];

Then, in your config, you will be able to access the globals.Cookie variable to get the value of the cookie.

When executing a job, the Startup LoliCode script will run as soon as you press the Start button, before all the bots are started.

This is also useful if you want to read the lines from a file to a list, store the list as a global variable and then take random items from that list in the usual body of your config.

From now on, you can forget the tricky “check if the global variable is declared or not” section at the top of your config when using global variables in a multi-threaded environment, since you can simply initialize your global variables in the Startup LoliCode script and you are guaranteed that they will be available later in the normal script.

Please provide feedback if you have any issues with this, thanks!

Cheers,

Ruri

13 Likes