|
BookieScript
BookieScript is the scripting language used to create Bookie plugins.
Featured, Information, Phase-Implementation NOTE: The BookieScript specification listed here is based on it's implementation in the unreleased Bookie 0.5 and as such, is subject to change. We recommend waiting for the 0.5 release before learning BookieScript. About BookieScriptBookieScript is the scripting language used in conjunction with GML to create plugins for Bookie. It gives you full control over both scrollbars, theme manipulation, and full access to the GM core running underneath Bookie. TutorialIn this tutorial, I will show you how to make a plugin that enables the use of the W, A, S and D keys to scroll the currently loaded image in Bookie. Firstly, let me introduce you to your new best friend, bs_attachevent();. In linear mode, the script executes line by line and stops when it reaches the end. This is fine for simple plugins, but if you want to add interactivity like keyboard/mouse input or functions that execute every frame (similar to the step event in GM), you need to 'attach' the event to the Bookie window. This is where bs_attachevent(); comes in. Let's take a look at the completed plugin: bs_attachevent("step","if(bs_keypress('W')){bs_vscrollbar_scrollup();}");
bs_attachevent("step","if(bs_keypress('A')){bs_hscrollbar_scrollleft();}");
bs_attachevent("step","if(bs_keypress('S')){bs_vscrollbar_scrolldown();}");
bs_attachevent("step","if(bs_keypress('D')){bs_hscrollbar_scrollright();}");Let's take a look at the first line: bs_attachevent("step","if(bs_keypress('W')){bs_vscrollbar_scrollup();}");bs_attachevent(); is used here to attach a string of BookieScript code to the Bookie window. You can also see the "step" parameter. bs_attachevent(); requires two parameters: The first parameter tells Bookie how to execute the script. There are three options for this first parameter: init, step and close. init executes the event once, when Bookie opens, step executes the event every frame, and close executes the event once, just before Bookie is closed (useful for saving settings/config). Let's look at the line of BookieScript code next: if (bs_keypress('W'))
{
bs_vscrollbar_scrollup();
}This is quite a simple piece of code. If the key 'W' is pressed, the vertical scrollbar scrolls up. This is repeated for the A, S and D keys, and each event is attached to the window. That's all there is to it! Save it as something like script.bs and run Bookie with the -script script.bs parameters to check it out. |