Skip to content
Speljohan edited this page Mar 17, 2013 · 3 revisions

Scripting

Scripting in the client is done using a heavily customized Ruby engine, using what is called a Domain Specific Language (DSL in short). This is to ensure the barrier for learning stays as low as possible.

Configuration

Every script needs a Configuration block at the top to be loaded properly. Here's a template:

configuration do
  name        "Configuration Example"
  description "This is an example of a configuration block."
  author      "Mike Tyson"
  version     "1.0"
end

Functions

For a list of the current functions available, see: Functions

Triggers

At the core of the engine you have Triggers. A trigger is an event sent to the script from the client itself. An example of handling a trigger is:

on :init do
  puts "Hello, World!"
end

where :init is the id of the trigger. For a list of triggers currently employed, see: Triggers

Actions

An action is an event that has been triggered by a user. Actions are defined by the script developers, and are currently only available for View components (what you use to display a Tab in the client).

Example:

action :clicked, "my_id" do
  message "You clicked me!"
end

This action is triggered by a component with the id "my_id" being clicked by a user. To bind a component like this, in the definition of your component you would do:

bind "my_id"

Views

A View is a set of components used to display data to the user. This can either be done in its own frame, or within the client as a Tab. If it is being done within a Tab, you must declare this in the :swing_ui trigger, example:

on :swing_ui, :threaded => false do | ui|
  view ui do
    label do
      text "Hello There!"
    end
  end
end

Or as a frame:

frame do
  size 400, 400
  title "My frame"
  label do
    text "Hello, world!"
  end
end

For a list of components currently employed, see: View Components

Other Information

Beyond these "special" ways of doing things, you can use any kind of Ruby code if you feel you need to.

Clone this wiki locally