Storyboard Lua API

gre.set_data ( table )

Sets one or more items in the engine’s data manager.  Each index and value in the table passed in will be set in the data manager using the index’s name as the key.

function lua_fuc( mapargs, stringargs )
  local data_table  = {}
  data_table["variable_name"] = "variable data"
  gre.set_data( data_table )
end
            

gre.get_data ( val1 [ ,val2 , ...] )

Gets one or more data entries from the data manager. Each value passed in as a parameter has a lookup in the data manager using the value as the key. This function returns a table using all the values as indexes and the corresponding value is the data returned from the data manager. A nil is returned for any values that do not match a key in the data manager.

function get_data_fuc( mapargs, stringargs )
  local data_table  = {}
  data_table = gre.get_data("variable_name")
  print("variable_name = "..data_table["variable_name"])
end
            

gre.send_event (  event_name, channel )

Send an event to the application or to a Storyboard IO channel.  channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

To send to the event  to the application :

gre.send_event("my_event")

To send the event to a Storyboard IO channel via parameters:

gre.send_event("my_event", “io_channel_name”)

gre.send_event_target (  event_name, target, channel )

Send an event to a targeted model element (control, layer instance or screen).  channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.send_event_data (  event_name, format_string, data, channel )

Send an event with custom data to the application or to a Storyboard IO channel.   data is a lua table where the indexes match the values from the format string. channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.touch ( x , y, channel )

Send a touch event to the application at the co-ordinates passed in through the parameters.  channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.key_up ( scancode, channel )

Send a key_up event to the application with the scancode passed in the parameters. channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the global Lua variable "GREIONAME" is set to a string value, then that value will be used as the channel name, otherwise ...

If the script is being run within the Storyboard Engine (as opposed to via the standalone Lua interpreter) then the channel used will be the one associated with the application, otherwise ...

If the environment variable GREIONAME is set then it will be used.

gre.key_down ( scancode, channel )

Send a key_down event to the application with the scancode passed in the parameters. channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.key_repeat ( scancode, channel )

Send a key_repeat event to the application with the scancode passed in the parameters. channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.redraw (x, y, w, h, channel)

Force a screen redraw.  channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.layer_move(key_name, dx, dy, x, y)

Move a layer to a new position.  Key_name is the name of the layer or a variable. Setting dx and or dy will move the layer by the specified delta from its current position.  Dx and dy can be 0 to set an absolute position using x and y.

gre.control_move(key_name, dx, dy, x, y)

Move a layer to a new position.  Key_name is the name of the control or a variable.  Setting dx and or dy will move the layer by the specified delta from its current position.  Dx and dy can be 0 to set an absolute position using x and y.

gre.get_control_attrs(key_name, tags …)

Get attributes for a control.  Key name is the name of the control or a variable.  Tags can be a list of the following values:

        x, y, hidden, active

A table with the results is returned.

function check_if_hidden()
  local dk_data = {}
  -- check if my_control is currently hidden
  dk_data = gre.get_control_attrs("my_control", "hidden")
  if dk_data["hidden"] == 1 then
    print("my_control is currently hidden")
  else
    print("my_control is currently visible")
  end
end
            

gre.get_layer_attrs(key_name, tags …)

Get attributes for a layer.  Key name is the name of the layer or a variable.  Tags can be a list of the following values:

        x, y, alpha, hidden, active

A table with the results is returned.

gre.get_table_attrs(key_name, tags …)

Get attributes for a table.  Key name is the name of the control or a variable.  Tags can be any of the control tags mentioned in section 6.1.12 and any of the following values:

        rows : The number of rows in the table
        cols: The number of columns in the table
        visible_rows: The number of visible rows
        visible_cols:  the number of visible columns
        active_row: The active cell row
        active_col:  The active cell column
        row: The row index of the upper left column
        col: The column index of the upper left column

gre.set_control_attrs(key_name, tags …)

Set attributes for a control.  Key name is the name of the control or a variable.  Table contains the tags and values for the attributes to set.

        x,  y, width, height, hidden, active

function set_control_hidden()
  local dk_data = {}
  dk_data["hidden"] == 1
  gre.set_control_attrs("my_control", dk_data)        
end
            

gre.set_layer_attrs(key_name, table)

Set attributes for a layer.  Key name is the name of the layer or a variable.  Table contains the tags and values for the attributes to set.

        alpha, hidden, active

gre.set_layer_attrs_global(key_name, table)

Set attributes for a layer globally on all instances of the layer on all screens.  Key name is the name of the layer or a variable.  Table contains the tags and values for the attributes to set.

        alpha, hidden, active

gre.get_string_size(font, font_size, string, length, width)

Calculate the area in pixels which the given string will occupy on the screen. Optionally calculate how many characters can fit into a predefined screen area.


Parameters:
                
        string  The string to render
        font  The name of the font to render int
        font_size  The size of the font to render in  
        string_length  The length of the string to render or 0 for all (optional)
        width a clip size for the string, used to calculate how many characters can fit in an area
                
Returns:
                
        A table containing the following values:
        "nchars" number of characters that will fit in clip if specified
  "width" string width clipped by clip
  "height" string height cliped by clip
        

gre.quit (channel)

Send QUIT event to application to force shutdown.  channel is an optional parameter and if channel is not passed then the channel will be chosen as follows:

If the environment variable GREIONAME is set then it will be used otherwise the default channel is used.

gre.mstime ()

Retrieve the current time in milliseconds. This call provides a higher resolution than the standard Lua os.clock() or os.date() functions.