Scripted plugins

Charlie Brej plymouth at brej.org
Wed May 6 15:41:35 PDT 2009


Just to keep everyone updated. I was meaning, over the new year, to create a 
scripting language to allow elements of the theme to be described. I got 
distracted half way though but just got back to it. I have currently got it to 
execute expressions so we can set the plugin variables (like the ones Ray allows 
to be set using the .plymouth files) to values which are not constant.

e.g.
HorizontalPosition = ScreenWidth / 4 - 100;
VerticalPosition = ScreenHeight / 2 - 50;


What you do is to populate the variable pool with data like ScreenWidth, and 
then execute the script. It then sets some additional variables (if it does not 
set them they are unset and a default value is used).

I should have something to that effect by tomorrow afternoon, but ultimately 
what I was hoping to do is to allow the script to specify the images (dealing 
with strings), their placement, their movement/transformations etc.

Thanks to the separation of themes and plugins what I was hoping to make is a 
single plugin called something like "scriptable" and have multiple themes which 
define their custom behaviours.

I was hoping to allow a description like this:

//CapitalisedNames are system supplied

image = ImageNew("bubble.png");
sprite = SpriteNew();
sprite.original_image = image; // the sprite object has some predefined
sprite.rot_distance = 100;     // important fields like x,y,image
                                // anything else can be set and is preserved

if (ScreenWidth > ScreenHeight)
{                         // ScreenWidth and ScreenHeight are system set values
   sprite.rot_distance = ScreenHeight / 2 - ImageHeight(image)
}
else
{
   sprite.rot_distance = (ScreenWidth / 2 - ImageWidth(image)
}

refreshfunc = function (sprite)
{
   theta = Progress * 2 * 3.1415;   // theta is a local and will be destroyed
                                    // when the function ends

   sprite.x = ScreenWidth / 2 - ImageWidth(image) + Cos(theta) * sprite.rot_dist;
   sprite.y = ScreenHeight/ 2 - ImageHeight(image)+ Sin(theta) * sprite.rot_dist;

   sprite.image = ImageRotate(sprite.original_image, theta);
}                                  // The old sprite.image will be freed is the
                                    // refcount reaches zero

refreshfunc(sprite); // call now to initialise the values

sprite.refresh_function = refreshfunc; // tell the system to call this function
                                       // every frame


More information about the plymouth mailing list