Layer add

From Sim Innovations Wiki
Jump to navigation Jump to search


layer_id = layer_add(z_order, callback)

layer_add is used to create a new layer. This function only works in a panel lua file.The layer will have the same dimensions as the panel it is created in.

Return value

Argument Type Description
layer_id ID This value can be used for further reference. Functions such as visible can use this layer_id. Its good practice to store this layer_id in your logic code.


# Argument Type Description
1 z_order Number The Z order. Lowest value is drawn at the back, highest is drawn on the top. The panel root lua is always drawn at order 0.
2 callback Function Callback function. Add GUI nodes (such as img_add, txt_add. etc. etc.) you create within this function will be added to this layer.


-- Create a layer with an image and text object
layer_id = layer_add(-4, function()
  txt_add("Hello world", "size: 20; color: black;", 0, 100, 60, 40) 

-- You can apply node function on the layer, such as move, visible, opacity etc.
opacity(layer_id, 0.5)