Switch set position

From Sim Innovations Wiki
Jump to navigation Jump to search



switch_set_position is used to set a switch to a certain position.

Return value

This function won't return any value.


# Argument Type Description
1 switch_id Number Reference to the switch
2 position Number The position you want to switch to get.


-- This function will be called when the switch changed position
-- Position being the new position. Ranging from 0 .. number of positions configured 
function callback(position)
  print("switch position has been changed to position " .. position)
-- Add a switch with 3 states (a, b and c)
-- The callback function will be called when the switch changes position
switch_id = switch_add("a.png", "b.png", "c.png", 100, 100, 100, 100, callback)

-- Start the switch on position 1 (default is position 0)
switch_set_position(switch_id, 1)